Compare commits

..
951 Commits
Author SHA1 Message Date
Syoyo Fujita 147a00a601 Prevent duplicated key generation when serializing lights + RapidJSON backend. Fixes #420 2023-06-04 05:45:24 +09:00
Syoyo Fujita 350c296802 Merge pull request #418 from agnat/fix_get_file_size_bug
[Bugfix] Actually invoke the user-supplied function instead of subtracting from a pointer...
2023-04-26 19:28:58 +09:00
David Siegel cc93e1fd25 Fix: Actually invoke the user-supplied function 2023-04-26 12:13:41 +02:00
Syoyo Fujita 59cc44ad4f Merge pull request #417 from syoyo/filesize-check
Fix to #416
2023-04-23 23:15:07 +09:00
Syoyo Fujita 1a5046e06b Fix MSVC compile failure on AppVeyor CI. 2023-04-23 23:08:41 +09:00
Syoyo Fujita 877d856e71 Format error message.
Add regression test of issue-416.
2023-04-23 21:47:31 +09:00
Syoyo Fujita b534b6b0d8 Fix syntax. 2023-04-23 21:40:23 +09:00
Syoyo Fujita ecfd37dee2 - Add GetFileSizeInBytes Filesystem Callback
- Add feature to limit file size for external resources(images, buffers)
- Use strlen to correctly retrieve a string from a string which contains multiple null-characters.
- Return fail when opening a directory(Posix only). Fixes #416
2023-04-23 21:31:30 +09:00
Syoyo Fujita 5c06b7d03b Merge pull request #415 from louwaque/release
Fix serialization of AnimationChannel::target_node when it is zero
2023-04-19 05:17:06 +09:00
Loïc Escales a75355b018 Fix serialization of AnimationChannel::target_node when it is zero 2023-04-18 21:03:39 +02:00
Syoyo Fujita a977f7a16f Merge pull request #412 from agnat/add_char_pointer_ctor
Fix #411 by adding a Value(const char *) constructor.
2023-04-10 19:11:35 +09:00
Syoyo Fujita 5a6c55870e Deprecate ubuntu-18.04 image and update CI build configuration. 2023-04-10 18:51:29 +09:00
David Siegel 49caa65177 Fix #411 by adding a Value(const char *) constructor.
Avoid implicit conversion of pointers to bool. Closes #411.
2023-04-08 23:44:53 +02:00
Syoyo Fujita d71c6f61f3 Merge pull request #409 from NeilBickford-NV/nbickford/update-stb-image
Updates stb_image and stb_image_write
2023-03-30 18:13:12 +09:00
Neil Bickford b5d27fd151 stb_image: Apply https://github.com/nothings/stb/pull/1443 2023-03-29 12:00:24 -07:00
Neil Bickford af4456ba68 stb_image: Apply https://github.com/nothings/stb/pull/1454 2023-03-29 11:57:27 -07:00
Neil Bickford 344669ddf6 Update stb_image and stb_image_write to latest nothings/stb dev branch: https://github.com/nothings/stb/commit/9f1776a36d2a3d63c52f705c3a84b372cfed4340 2023-03-29 11:56:13 -07:00
Syoyo Fujita 967c98dd90 Merge pull request #408 from marco-langer/feature/ostream_error_handling
Added error checking to ostream writing
2023-03-13 21:18:02 +09:00
Marco Langer 7658624bb4 Added error handling to ostream writing 2023-03-12 19:26:05 +01:00
Syoyo Fujita 84a83d39f5 Merge pull request #407 from DavidSM64/release
Added detail namespace to prevent json namespace conflicts
2023-02-19 02:08:19 +09:00
David 03ad33cc8d Fixed global namespace issue 2023-02-15 23:35:51 -06:00
David 3831802717 Fix RapidJSON implementation (hopefully) 2023-02-15 23:21:09 -06:00
David 1f9a4b97a3 Added detail namespace to prevent namespace conflicts 2023-02-15 22:56:18 -06:00
Syoyo Fujita 6dba104c54 Merge pull request #405 from tioez326/patch-2
Fix typo
2023-02-10 21:00:27 +09:00
tioez326 b5e1b35ef1 Fix typo 2023-02-10 12:09:12 +01:00
Syoyo Fujita 52b73c7f0b Update README.md 2023-01-16 05:46:11 +09:00
Syoyo Fujita 98adbb3fb3 Merge pull request #401 from jmousseau/animation-channel-node-optionality
Fix animation channel target node optionality
2023-01-16 05:33:40 +09:00
Jack Mousseau 283b552a4e Fix animation channel target node optionality 2023-01-15 11:45:45 -08:00
Syoyo Fujita c2ca97b38b v2.8.1 2023-01-13 18:15:21 +09:00
Syoyo Fujita f051892c55 Merge pull request #399 from e2e4e6/texture_sampler_name_fix
Missed serialization texture sampler name fixed.
2023-01-13 18:13:12 +09:00
s00665032 137a7ca999 Missed serialization texture sampler name fixed.
According to the glTF 2.0 specification it exists, the internal tinygltf structure contains 'name' field as well.
2023-01-13 12:52:08 +07:00
Syoyo Fujita 477d977fea Merge pull request #398 from nicolas-raoul/patch-1
Fixed typo
2023-01-12 16:21:35 +09:00
Nicolas Raoul 8cd5e759d0 Fixed typo 2023-01-12 15:29:32 +09:00
Syoyo Fujita a6c3945ed3 Bump version 2.8.0. 2023-01-10 20:42:24 +09:00
Syoyo Fujita 6614bddef3 Merge pull request #397 from pknowlesnv/encode_image_uri
urlencode image urls
2023-01-10 20:31:39 +09:00
Pyarelal Knowles 385946dfd8 add URI encode/decode API
Tinygltf is able to write files defined by a URI, so it needs to be able
to decode it. Since it may also modify the path where the image is saved
it may need to re-encode the URI too. This patch provides an API to set
URI encoding and decoding callbacks and exposes the default decode
method.

Uses the existing dlib::urldecode as a decode default. The encode
callback is left null, matching existing behaviour.

Updates the WriteImageDataFunction signature to include
tinygltf::URICallbacks.

Decodes the image and buffer uris before using them as a filename.

If the encode callback is set, encodes the written image location in the
default WriteImageDataFunction and encodes generated buffer locations
when writing .bin files.

Adds a save+load step to the test image-uri-spaces to verify uri
encoding.
2023-01-09 20:54:29 -08:00
Syoyo Fujita 03bbe0921c Merge pull request #396 from pknowlesnv/image_write_failure
propagate image writing failures
2022-12-30 17:59:41 +09:00
Pyarelal Knowles a9121550b9 SerializeGltfImage: add missing & std::string ref
Hopefully the compiler would optimize this away but better to avoid the
copy in the first place.
2022-12-29 14:12:29 -08:00
Pyarelal Knowles d2b0af6915 propagate image writing failures
Modifies UpdateImageObject() so that Returning false from the
WriteImageDataFunction callback results in the WriteGltfScene*() call
returning false.

Does not call WriteImageDataFunction if there is no image data.

Adds test case serialize-image-failure to verify the callback return
code is able to cause an overall failure to save the gltf.
2022-12-29 13:50:17 -08:00
Syoyo Fujita 695608dd11 Update readme. 2022-12-29 21:50:47 +09:00
Syoyo Fujita 584f1dfbe4 Merge branch 'release' of github.com:syoyo/tinygltf into release 2022-12-29 21:13:48 +09:00
Syoyo Fujita a40ca4c5ab Merge pull request #393 from pknowlesnv/serialize_const
allow serializing a const Model
2022-12-29 21:00:24 +09:00
Pyarelal Knowles de75d87cfd allow serializing a const Model
Adds 'const' to all Serialize*() methods.

Updates WriteImageData callback to take a URI out pointer that was
previously being written to the Image::uri, which is now const.

This breaks the WriteImageData API and as a side effect, Image::uri will
no longer contain the written image URI after saving.

Adds test serialize-const-image, which verifies the model's image is not
changed (because it's const), but the uri written to the gltf json is
still correct.

Adds test serialize-image-callback that defines a WriteImageDataFunction
and also verifies the uri can be overwritten.
2022-12-28 17:20:09 -08:00
Syoyo Fujita cf11842e64 Merge pull request #395 from ethanpepro/cmake-export
Add CMake export configuration
2022-12-28 18:33:36 +09:00
James Luke 38003032e3 Add CMake export configuration 2022-12-27 21:12:54 -05:00
Syoyo Fujita 186016bf11 Merge branch 'release' of github.com:syoyo/tinygltf into release 2022-12-03 19:42:27 +09:00
Syoyo Fujita 5ee08f9274 Remove Python 2 description. 2022-12-03 19:40:50 +09:00
Syoyo Fujita aa613a1f57 Update README.md
Remove Python 2.x description
2022-12-03 19:40:45 +09:00
Syoyo Fujita 222454cc6d Create FUNDING.yml 2022-12-03 18:33:05 +09:00
Syoyo Fujita 16c2d3a8bf Merge pull request #390 from eduardodoria/patch-1
Added Supernova Engine to Projects using TinyGLTF
2022-11-07 21:18:50 +09:00
Eduardo Doria 186093657a Added Supernova Engine to Projects using TinyGLTF 2022-11-07 08:53:47 -03:00
Syoyo Fujita 9bdd256625 Merge pull request #388 from stromaster/patch-1
Avoid multiple asset_manager definitions on Android
2022-10-31 17:40:40 +09:00
Serdar Kocdemir 264ae4c131 Avoid multiple asset_manager definition on Android
Using TINYGLTF_IMPLEMENTATION to make the actual definition of the 'asset_manager' global variable.
2022-10-30 22:32:59 +00:00
Syoyo Fujita 091a1fcc1a Merge pull request #386 from geometrian/master
Fix Clang Compile Warnings/Errors (and Typos)
2022-10-08 19:08:22 +09:00
imallett 3a295887d6 Patch to fix previous commit for MinGW. 2022-10-07 11:20:39 -07:00
imallett d9ce9eb9d2 Fix a gazillion typos. 2022-10-07 10:37:09 -07:00
imallett 56e1098993 Fix various type mismatches and header include case (fixes compile warnings on Clang). 2022-10-07 10:35:16 -07:00
Syoyo Fujita 9bb5806df4 Merge pull request #385 from operatios/master
Fix UTF-8 filepath on LLVM MinGW
2022-09-25 05:35:36 +09:00
operatios 1668d1ecc5 Fix UTF-8 filepath on LLVM MinGW 2022-09-24 22:37:14 +03:00
Syoyo Fujita 6e8a858c45 Add WASI build procedure. 2022-09-22 04:36:58 +09:00
Syoyo Fujita e0b625561c v2.6.3 2022-09-19 03:36:58 +09:00
Syoyo Fujita 18450eafe7 Merge pull request #382 from syoyo/glb-zero-chunk
Fix parsing GLB file with empty Chunk1(BIN data).
2022-09-19 03:34:09 +09:00
Syoyo Fujita e9fbc03e2d Clear error/warn message. 2022-09-19 03:29:57 +09:00
Syoyo Fujita 612e57816f Fix handling <4 byte BIN data.
Fix handling GLB file with empty CHUNK1(BIN).
2022-09-18 21:01:39 +09:00
Kh4n a778c089d1 readd toplevel makefile 2022-09-17 15:39:28 -05:00
Kh4n 387fd61b83 update test to match gltf-validator 2022-09-17 13:02:39 -05:00
Kh4n 6514490090 update gitignore to remove test file
readd accidental removals in gitignore

undo autoformat

more undo autoformatting
2022-09-17 12:52:59 -05:00
Kh4n 6b7ec9f494 added tests to cover empty, empty buffer, and single byte buffer cases 2022-09-17 12:28:39 -05:00
Syoyo Fujita c670f08a3b Fix parsing GLB file with empty Chunk1(BIN data). 2022-09-17 19:52:25 +09:00
Syoyo Fujita eec4c98862 Add note on v2.6.2(Fix out-of-bounds access of accessors. PR#379) 2022-09-16 17:27:20 +09:00
Syoyo Fujita c7e911cf11 Merge pull request #380 from AlvaroBarua/master
Fixes compiler warning on VS (Unreachable code detected)
2022-09-11 17:56:55 +09:00
AlvaroBarua 43172238f7 Fixes compiler warning on VS (Unreachable code detected) 2022-09-11 00:41:43 +01:00
Syoyo Fujita 0cc23356dc Merge pull request #379 from nirmal/patch-1
Fix possible out of bounds index in LoadFromString
2022-09-07 01:52:55 +09:00
Nirmal Patel e413216722 Fix possible out of bounds index in LoadFromString 2022-09-06 09:16:31 -07:00
Syoyo Fujita 4581d37bec v2.6.1 2022-09-06 22:02:31 +09:00
Syoyo Fujita 966a9d0df7 Merge pull request #374 from syoyo/glb_chunk_check
Better GLB data size check when reading.
2022-09-06 21:35:47 +09:00
Syoyo Fujita 64452bb5fa Merge pull request #377 from zbendefy/master
Auto detect C++14 standard version
2022-09-06 14:01:26 +09:00
zbendefy 69eeea145b Auto detect C++14 standard version 2022-09-05 23:54:57 +02:00
Syoyo Fujita 24e539621d Merge pull request #376 from kacprzak/master
Read from moved object
2022-09-03 01:16:41 +09:00
Marcin Kacprzak f4f5c3cf3a Fix read from moved object. 2022-09-02 16:15:54 +02:00
Marcin Kacprzak b12a54ed15 Silence MS code analysis tool. 2022-09-02 16:13:11 +02:00
Syoyo Fujita 240d993f94 Create codeql-analysis.yml 2022-09-02 05:09:09 +09:00
Syoyo Fujita 46ee8b4276 GLB: Fix interger-overflow when calculating JSON Chunk size.
GLB: Check BIN Chunk size.
GLB: Chenk byte alignment of each chunk.
2022-08-26 22:06:53 +09:00
Syoyo Fujita 3bddc09af4 Update README. 2022-08-19 18:21:24 +09:00
Syoyo Fujita 9117abb45d Merge branch 'master' of github.com:syoyo/tinygltf 2022-08-16 20:11:52 +09:00
Syoyo Fujita 52ff00a384 Do not expand file path since its not necessary for glTF asset path(URI) and for security reason(wordexp). 2022-08-16 20:08:45 +09:00
Syoyo Fujita 0fa56e239c Merge pull request #367 from fynv/master
Sparse accessor: typo fix
2022-08-14 20:54:01 +09:00
Fei Yang 5c2dd83964 Merge branch 'syoyo:master' into master 2022-08-14 19:50:14 +08:00
feiy 1a8814d687 Sparse accessor serialization: typo fix. 2022-08-14 19:49:07 +08:00
Syoyo Fujita 666ab8661c Merge pull request #366 from fynv/master
Adding serialization code for sparse accessors.
2022-08-13 18:34:24 +09:00
feiy 0b31543098 Adding serialization code for sparse accessors. 2022-08-13 10:08:17 +08:00
Syoyo Fujita 81f7dbe53a Partial fix of issue 365 2022-08-02 01:05:34 +09:00
Syoyo Fujita 544969b732 Check the failure of RapidJson Accept(). Fixes #332
TODO: Better error reporting when Accept() failed.
2022-07-13 19:03:33 +09:00
Syoyo Fujita 3d4150419e Merge pull request #362 from hschwane/master
fix images not beeing embeded into stream
2022-06-29 20:16:35 +09:00
Hendrik Schwanekamp 41e1102e57 fix images not beeing embeded into stream 2022-06-29 12:22:40 +02:00
Syoyo Fujita b901dd62d8 Merge pull request #357 from eariassoto/fix-basic-example
Fix basic example
2022-05-15 20:06:17 +09:00
Syoyo Fujita bc03ceaac1 Merge pull request #358 from brlcad/patch-2
treat powerpc as big endian too
2022-05-15 20:02:28 +09:00
Christopher Sean Morrison 2c9b25642b treat powerpc as big endian too
added powerpc to the list of big endian types
2022-05-14 19:00:19 -04:00
Emmanuel Arias Soto a894904f11 Fix basic example
Context: When parsing a mesh with primitives that have indices pointing to different buffer views, the VAO will use the last GL_ELEMENT_ARRAY_BUFFER that was bound to it. In this scenario, the mesh will not be rendered properly.

When binding a mesh, return VAO and EBOs so that primitives can bind to the proper element array buffer.
2022-05-14 19:54:03 +02:00
Syoyo Fujita 912856823d Add Open3D to "projects using TinyGLTF". 2022-05-07 01:35:14 +09:00
Syoyo Fujita 1a7c7d2001 Merge pull request #353 from mgerhardy/master
Fixed find_last_of call in GetBaseFilename
2022-03-14 14:50:32 +09:00
Martin Gerhardy fae6543b7a Fixed find_last_of call in GetBaseFilename
this leads to a stack overflow on linux - it looks like this magically works on msvc though...
2022-03-13 18:42:39 +01:00
Syoyo Fujita 6ed7c39d71 Add note on componentType double type. 2022-03-03 16:40:54 +09:00
Syoyo Fujita 5a90ab76ee Merge pull request #350 from tsmaster/master
Examples/glview - apply translation, rotation, scale in that order
2022-03-03 03:16:29 +09:00
Dave LeCompte 0ffdc4334a Examples/glview - apply translation, rotation, scale in that order
Tested on the Kenney.nl CarKit models: https://www.kenney.nl/assets/car-kit
2022-03-02 07:01:34 -08:00
Syoyo Fujita 53338352f2 Merge pull request #349 from tsmaster/master
Fix examples/glview rotations
2022-03-02 02:55:15 +09:00
Dave LeCompte d642c80a86 Fix examples/glview rotations
GLtf defines rotations as quaternions, glRotated expects angle/axis, with angle in degrees.
2022-03-01 08:11:22 -08:00
Syoyo Fujita a1952053ee Merge pull request #347 from syoyo/jmousseau-sparse-accessor-optionality
Jmousseau sparse accessor optionality
2022-02-26 21:27:35 +09:00
Syoyo Fujita cbd3885049 Check required attribute exists for SparseAccessor. 2022-02-26 21:19:15 +09:00
Jack Mousseau 9471517c1e Fix byte offset optionality for sparse accessor indices and values 2022-02-24 14:25:37 -08:00
Syoyo Fujita e59028d68f Merge pull request #345 from syoyo/github-actions-ci-fix
GitHub actions ci fix
2022-02-25 02:07:46 +09:00
Syoyo Fujita cfab524125 VS2019 seems gone. Use VS2022. 2022-02-25 01:39:02 +09:00
Syoyo Fujita 9229971bcb Print cmake help 2022-02-25 01:25:15 +09:00
Syoyo Fujita 051149311c Specify x64 for MSVC build. 2022-02-25 01:11:51 +09:00
Syoyo Fujita 0c7789b1e5 Merge pull request #344 from epajarre/fix-wrapS
Added missing comparison for wrapS
2022-02-24 21:52:43 +09:00
Eero Pajarre 51b12d2546 Added missing comparison for wrapS 2022-02-24 14:38:20 +02:00
Syoyo Fujita 4749b0989d Merge pull request #342 from brlcad/patch-1
add missing switch case for binary
2022-02-24 03:34:58 +09:00
Christopher Sean Morrison 0bfcb4f49e add missing switch case for binary
with warnings cranked up and warnings-as-errors enabled, the compiler throws an error due to this switch missing a case for binary.  this makes the ignore explicit in order for compilation to proceed.
2022-02-23 10:02:49 -05:00
Syoyo Fujita 17e6e310ce Merge pull request #341 from mushrom/loopfix
Fixing loop index
2022-02-14 17:10:31 +09:00
My Name 07ceb4c313 Fixing loop index 2022-02-13 16:31:27 -05:00
Syoyo Fujita e7f1ff5c59 Merge pull request #339 from yslking/yslking-update-json-hpp-3-10-4
update json.hpp to v3.10.4 to compile with c++20 compilers
2021-11-28 22:25:34 +09:00
yslking fd904063c9 update json.hpp to v3.10.4 2021-11-28 15:08:05 +08:00
Syoyo Fujita 38398cc2da Fix typo from PR #320 2021-11-21 18:59:10 +09:00
Syoyo Fujita ed1a294bc4 Merge branch 'master' of github.com:syoyo/tinygltf 2021-11-21 18:58:39 +09:00
Syoyo Fujita b86eb6c079 Merge pull request #331 from abwood/so-updates
Remove stackoverflow references from tinygltf.
2021-10-19 21:45:19 +09:00
Alexander Wood e4bc6c7bd4 - Remove clang warning suppression. I assume this stackoverflow reference can just be removed as it isn't a code snippet but a repost of clang documentation of ignoring warning levels.
- Remove stackoverflow reference that recommends the use of dlib. There's no source that was pulled from this s.o. post, only a recommendation on a library, I wouldn't think a link to s.o. is necessary here. Per the Boost License, I've included a copy of the license along with the snippet
2021-10-14 08:54:59 -04:00
Alexander Wood 13803659f8 Build fix. 2021-10-08 20:13:07 -04:00
Alexander Wood a3d5d5d1c9 Build fix. 2021-10-08 20:09:08 -04:00
Alexander Wood 9e3d1f6db5 Build fix. 2021-10-08 16:57:56 -04:00
Alexander Wood 190382aecd GetBaseFilename contained a logic error in that a filename that does not contain a path separator would result in a crash.
Removed the roundUp lambda, as this generalization is not necessary; the caller always attempts 4 byte alignment.
2021-10-08 12:19:13 -04:00
Syoyo Fujita c6501530e3 Merge branch 'master' of github.com:syoyo/tinygltf 2021-09-24 17:11:07 +09:00
Syoyo Fujita ed48224f4b Describe current status(its stable) 2021-09-24 17:10:29 +09:00
Syoyo Fujita 19a41d20ec Merge pull request #330 from cgdae/master
Fix for OpenBSD - wordexp.h not available.
2021-08-25 20:25:03 +09:00
Julian Smith 0598a20cce Fix for OpenBSD - wordexp.h not available. 2021-08-25 12:06:08 +01:00
Syoyo Fujita 514167b475 Merge pull request #329 from syoyo/cmake-add-subdirectory
Cmake add subdirectory
2021-07-03 22:09:26 +09:00
Syoyo Fujita 0f76561ebf Add readme to use tinygtf through cmake + add_subdirectory. 2021-07-03 22:06:29 +09:00
Syoyo Fujita f3dc4acaa4 Merge branch 'master' into cmake-add-subdirectory 2021-07-03 22:01:46 +09:00
Syoyo Fujita 1588e75e26 Merge branch 'master' of github.com:syoyo/tinygltf 2021-06-09 21:23:57 +09:00
Syoyo Fujita d1453b5e5e GLEW_LIBRARY -> GLEW_LIBRARIES 2021-06-09 21:23:37 +09:00
Syoyo Fujita 7e83ef9fb4 Merge pull request #327 from CppProgrammer23/master
update enum Type
2021-05-20 20:44:16 +09:00
Idriss Chaouch 425195bf9c update enum Type
the first element in an enum is 0, so it's not necessarily to affect values from 0 to 7.
2021-05-20 12:11:00 +01:00
Syoyo Fujita ce3a30e612 Merge pull request #326 from xzrunner/master
Fix comment on minFilter
2021-05-14 15:06:07 +09:00
zz 8a35b8f6fe Fix comment on minFilter 2021-05-14 13:49:33 +08:00
Syoyo Fujita f66f3bfeb3 Merge pull request #325 from iceydee/scene-extras
Store scene extras and extensions on the scene
2021-05-11 19:01:25 +09:00
Mio Nilsson e29ba7c49a 🐛 Store scene extras and exteions on the scene
This was being stored in the wrong place
2021-05-11 11:50:35 +02:00
Syoyo Fujita bc753d4ac5 Merge pull request #322 from syoyo/fix-negative-skeleton-id
Do not serialize skeleton id -1
2021-04-29 16:20:42 +09:00
Syoyo Fujita 688ba8a60e Add regression test for issue 321 2021-04-29 16:04:52 +09:00
Syoyo Fujita d07b976d59 Do not write negative skeleton id(skeleton is not assigned).
Also ensure `inverseBindMatrices` should not be -2 or other negative values.
2021-04-28 19:15:16 +09:00
Syoyo Fujita 08a7dd8dad Merge pull request #317 from Snowapril/master
Delete unused variable initialization code
2021-03-30 03:15:26 +09:00
snowapril 87da1e775f Delete unused variable initialization code
Line 4536 in tinygltf.h file, there is unused variable initialization code like below.
```c++
    const auto pBuffer = pAttribute->buffer();
```

gcc compiler complain about that unused variable. 

I found there is no side-effect in  `pAttribute->buffer()` call and also pBuffer variable is never used. Therefore I delete that line entirely.
2021-03-30 00:16:04 +09:00
Syoyo Fujita 151495558e Merge pull request #314 from Snowapril/master
Add (void)err for handling unused variable warning
2021-03-20 19:59:44 +09:00
snowapril 84e15260ba add (void)err for handling unused variable warning
I saw in the `ParseExtensionsProperty`(3667) function,
unused variable err argument is wrapped with (void) keword.

I think err argument in the `ParseDracoExtension`(4472) is exactly
same situation with the above one.

For consistency, I think it need to be added (void)err in the
`ParseDracoExtension` function.
2021-03-20 19:25:58 +09:00
Syoyo Fujita 03cdef430d Merge pull request #312 from AlvaroBarua/no_include_rapidjson
Added TINYGLTF_NO_INCLUDE_RAPIDJSON
2021-03-19 14:32:35 +09:00
AlvaroBarua fb4bd82e2c Updated Readme.md 2021-03-18 18:40:09 +00:00
Alvaro Barua 3ddf8301f6 Added TINYGLTF_NO_INCLUDE_RAPIDJSON for consistency and because my project already used rapidjson/ 2021-03-18 00:21:23 +00:00
Syoyo Fujita 298c37a954 Merge pull request #310 from syoyo/write-assert-version
`asset.version` is a required field
2021-03-03 00:35:55 +09:00
Syoyo Fujita b702de755f asset.version is a required field so write "2.0" when asset.version is empty. Fixes #308 2021-03-02 19:08:29 +09:00
Syoyo Fujita 58ceed1d89 Add CMake file and Makefile for examples/build-gltf 2021-02-26 18:34:00 +09:00
Dov Grobgeld d1b6b3a5aa Add example for creating a triangle gltf file from scratch 2021-02-26 09:30:05 +02:00
Syoyo Fujita c56d069726 Merge pull request #306 from mahiuchun/const
Drop an unnecessary 'const'.
2021-02-21 16:07:51 +09:00
Hill Ma d1e32865f1 Drop an unnecessary 'const'. 2021-02-20 22:30:44 -08:00
Syoyo Fujita 869a9d273c Merge pull request #305 from Selmar/patch-2
check correct `extensionsUsed` for serialization
2021-02-02 14:17:34 +09:00
Selmar 1208f057d6 check correct extensionsUsed for serialization 2021-02-01 19:24:41 +01:00
Syoyo Fujita f684dde9f1 Merge pull request #303 from syoyo/int-minmax-serialize
Issue #301. Serialize accessor min/vax value as int
2021-01-22 03:40:52 +09:00
Syoyo Fujita 7905a5b4dc Issue #301. Serialize accessor min/vax value as int if its component type is an integer. 2021-01-21 20:33:11 +09:00
Syoyo Fujita f161782001 Merge pull request #299 from DethRaid/patch-1
Add my project to the README
2020-12-23 15:46:32 +09:00
David Dubois 654bcf733c Add my project to the README
My personal project uses tinygltf so i want to add it to the "Projects using TinyGLTF" section of the README
2020-12-22 22:32:59 -08:00
syoyo 001c870051 Make cmake script add_subdirectory friendly. 2020-12-18 01:10:21 +09:00
Syoyo Fujita 2c521b3432 Remove sampler.wrapR parameter(unused tinygltf extension). Fixes #287
Suppress clang `-Wdocumentation-unknown-command` warning.
2020-12-04 00:50:46 +09:00
Syoyo Fujita a159945db9 Add document for TinyGLTF::SetPreserveimageChannels. 2020-10-31 19:40:33 +09:00
Syoyo Fujita 010ee9c67b Add SetPreserveImageChannels feature(preserve image channels in stored image file. Only effective when using builtin ImageLoad function(STB image load)). 2020-10-31 19:35:55 +09:00
Syoyo Fujita a23971c603 Merge pull request #295 from syoyo/empty-material
Empty material
2020-10-23 04:05:19 +09:00
Syoyo Fujita 1923067982 Fix build when using RapidJSON backend. 2020-10-22 22:38:56 +09:00
Syoyo Fujita 68adc4ba5e Serialize empty JSON object when material has all default parameters. Fixes #294 . 2020-10-22 22:27:12 +09:00
Syoyo Fujita 42a8cd50ff Merge branch 'master' of github.com:syoyo/tinygltf 2020-10-22 21:51:01 +09:00
Syoyo Fujita 0543640a83 Merge pull request #290 from Coast-Coader/master
Minor change to the example of usage with opengl (basic example)
2020-09-29 14:28:47 +09:00
Eschemann 9c59a0b64c Deleted unnessecary stuff2 2020-09-28 16:06:31 +02:00
Eschemann 452541a231 Deleted unnessecary stuff 2020-09-28 16:04:14 +02:00
Eschemann 78fe8d9b89 Fixed segfault in example basic on inter graphics hd and corrected path to model 2020-09-28 15:50:45 +02:00
Syoyo Fujita 51e5508fa0 Add note on sajson branch. 2020-08-09 21:18:28 +09:00
Syoyo Fujita 91da299729 Fix inequality. Should allow 0 for bufferView. 2020-07-15 13:52:39 +09:00
Syoyo Fujita 50ae8a31a8 Merge branch 'master' of github.com:syoyo/tinygltf 2020-07-14 22:05:28 +09:00
Syoyo Fujita 0af0435ef1 Renamed directory name. 2020-07-14 22:04:26 +09:00
Syoyo Fujita 7c342533e9 Add scene date for issue 280 2020-07-14 22:02:51 +09:00
Syoyo Fujita 7842c1276f Merge pull request #281 from rbsheth/sparse_morph_fix
Fix sparse morph targets
2020-07-14 15:35:37 +09:00
Rahul Sheth 125e4a2033 Fix sparse morph targets 2020-07-13 13:56:50 -04:00
Syoyo Fujita c9d6c5b9b4 Merge pull request #278 from rbsheth/string_fix
Use std::string for GetKey function
2020-07-11 03:41:11 +09:00
Rahul Sheth 96a8b2c69b Run clang-format 2020-07-10 14:27:46 -04:00
Rahul Sheth 01d54380ac Use std::string instead of const char* for GetKey function 2020-07-10 14:27:37 -04:00
Syoyo Fujita 6cd8fdb2c8 Merge pull request #274 from daemyung/dxview
Add dxview
2020-07-04 16:48:08 +09:00
daemyung jang fe01af2f01 Add README.md for dxview 2020-07-04 09:24:00 +09:00
daemyung jang efdd2b04dc Add dxview 2020-07-04 01:29:41 +09:00
Syoyo Fujita 2e642b3322 Merge pull request #273 from daemyung/dxview
Initialize member variables
2020-07-03 15:38:46 +09:00
daemyung jang 1739d025a9 Initialize member variables 2020-07-03 13:27:39 +09:00
Syoyo 39418e5728 Disable blank issue. 2020-06-26 02:01:16 +09:00
Syoyo Fujita 5622d2762d Update issue templates 2020-06-19 16:31:37 +09:00
Syoyo Fujita 3d939fd3ee Add comment on tinygltf::ExpandFilePath() 2020-06-06 18:13:15 +09:00
Syoyo Fujita fbbeb4d6a9 Use nullptr instead of NULL. 2020-06-06 17:11:50 +09:00
Syoyo Fujita cef1787ef8 Add regression test for PR-266. 2020-06-06 17:10:49 +09:00
cwbhhjl 2f5aa9f13b fix an error occurred while expanding utf8 path 2020-06-04 10:40:38 +08:00
Syoyo Fujita 28bafe4b11 Add GitHub Actions badge. 2020-05-30 17:06:45 +09:00
Syoyo Fujita 34894a6325 Build validator for MSVC build. 2020-05-30 02:28:58 +09:00
Syoyo Fujita 2e7006797b Separrate build of examples. 2020-05-30 02:27:25 +09:00
Syoyo Fujita d9c03d041a Build examples for VS2019 build job. 2020-05-30 02:21:07 +09:00
Syoyo Fujita 50a3061ddf Fix path to rapidjson headers 2020-05-30 02:19:47 +09:00
Syoyo Fujita 014dce27f4 Add VS2019 build job. 2020-05-30 02:16:41 +09:00
Syoyo Fujita c046769054 Add mingw build job 2020-05-30 02:12:48 +09:00
Syoyo Fujita c43266fdc9 Add argument to loader_example run 2020-05-30 02:07:00 +09:00
Syoyo Fujita aca196e8d3 add aarch64 cross compile and macos build job. 2020-05-30 02:04:06 +09:00
Syoyo Fujita b48c027c9a Fix yaml syntax. 2020-05-30 02:00:03 +09:00
Syoyo Fujita db5c3bea45 Add gcc-4.8 build job. 2020-05-30 01:59:02 +09:00
Syoyo Fujita ddfa1f2f0b Fix workflow 2020-05-30 01:56:35 +09:00
Syoyo Fujita 7b69c778fe Add rapidjson build job 2020-05-29 22:21:24 +09:00
Syoyo Fujita 73e73bf3c1 Create github actions workflow 2020-05-29 20:57:39 +09:00
Syoyo Fujita 35d664e417 Merge pull request #265 from ivovandongen/ivd_rapidjson_size_t
cast size_t to uint_64_t for rapidjson serialization
2020-05-29 18:19:07 +09:00
Ivo van Dongen 272a9dfa5f cast size_t to uint_64_t for rapidjson serialization 2020-05-29 11:24:11 +03:00
Syoyo f3bf6ee78e Add TDME2 2020-05-22 01:25:03 +09:00
Syoyo Fujita aba57bb907 Support llvm-mingw(clang + libcxx) to open UTF-8 path in ifstream. 2020-05-18 20:50:45 +09:00
Syoyo Fujita 6fad7adb9c Fix existing "extensions" were overwritten in serialization when the scene contains lights(serialized as "KHR_light_punctual")
Append "KHR_light_punctual" to `extensionsUsed` if not exist in serialization.
Apply clang-format.
Fixes #261
2020-05-15 21:32:06 +09:00
Syoyo Fujita 3dad303bea Only serialize light.range when range > 0. Fixes #260 2020-05-13 21:22:23 +09:00
Syoyo Fujita ff0a2e9fb4 Return type must be int for GetNumberAsInt(). Fixes #258 2020-05-11 19:07:00 +09:00
Syoyo fe77cc5cdd Serialize extension and extras for Camera. Fixes #257 2020-05-09 02:41:07 +09:00
Syoyo Fujita 18f0e20a11 Fix float and int comparison. 2020-04-29 19:16:35 +09:00
Syoyo Fujita 978adee547 Include cmath for std::fabs 2020-04-29 17:33:48 +09:00
Syoyo Fujita 73c4cce303 Return false for zero-sized asset. Fixes #255 2020-04-28 01:06:34 +09:00
Syoyo Fujita 925b83627a Merge pull request #254 from LHLaurini/master
Fix write functions so they work with MinGW
2020-04-14 01:40:00 +09:00
Luiz Henrique Laurini 92c23725ae Fix write functions so they work with MinGW 2020-04-12 16:00:33 -03:00
Syoyo Fujita af750a5104 Merge pull request #252 from freddiehonohan/master
Fixed small error if node has no mesh in examples/basic.
2020-04-10 02:04:12 +09:00
root ff48fa0ff4 Fixed small error if node has no mesh. 2020-04-09 10:42:41 -04:00
Syoyo Fujita ec45334d3d Merge branch 'master' of github.com:syoyo/tinygltf 2020-04-06 22:12:39 +09:00
Syoyo Fujita 5f603c56dc Do not segfault when the scene does not contain texture images. Fixes #251 2020-04-06 22:11:16 +09:00
Syoyo Fujita 063b8586f1 Merge pull request #250 from FsiGuy00015623/prevent-cloning-buffer-images
Prevent cloning of images in buffers
2020-03-10 14:53:13 +09:00
FsiGuy00015623 db855c6794 Prevent cloning of images in buffers
Now, in UpdateImageObject, if an image has no URI but had a valid bufferView, it will no longer change the image object or copy the buffer object to an outside file at baseDir. 
(When saving files from streams, this function would previously save textures in buffers as "#.png" in the program's working directory instead of the model file's directory, and create a broken link in the updated image object if the two locations were different.)
2020-03-09 16:57:21 -05:00
Syoyo Fujita e391f6b03e Merge pull request #249 from CesiumGS/accessor-index-fix
Ensures only valid bufferViews are mentioned in accessor
2020-03-05 23:59:23 +09:00
Sanjeet Suhag 5ecede71f0 Ensures only valid bufferViews are mentioned in accessor 2020-03-04 17:40:10 -05:00
Syoyo Fujita 40982716f9 Merge branch 'uri-decode' 2020-03-03 18:49:27 +09:00
Syoyo Fujita 4bdc96fb9b Update copyright year.
Add note on the result from fuzzer test.
2020-02-24 01:36:24 +09:00
Syoyo Fujita 96ecea080a Merge pull request #243 from mfpgs/reading_copyright
Reading copyright field in ParseAsset()
2020-02-20 23:42:14 +09:00
Miguel Sousa 22bfc843ee Reading copyright field in ParseAsset() 2020-02-20 14:16:58 +01:00
Syoyo Fujita eaa25a307a Merge pull request #242 from Selmar/some_empty_array_fixes
Some empty array fixes
2020-01-29 01:27:44 +09:00
Selmar Kok ab600b8e72 Merge remote-tracking branch 'origin/master' into some_empty_array_fixes 2020-01-28 13:46:22 +01:00
Selmar Kok eb9d29c06e dont serialize a couple of empty arrays 2020-01-28 13:45:38 +01:00
Syoyo Fujita 57356933c5 Merge pull request #240 from kacprzak/master
Set target for bufferView used by MorphTargets
2020-01-22 22:32:41 +09:00
Marcin Kacprzak c3d6716c56 Set target for bufferView used by MorphTargets 2020-01-22 13:13:35 +01:00
Syoyo Fujita ac5e09f8c3 Merge pull request #239 from Selmar/channel_target_extensions
Channel target extensions
2020-01-22 03:52:20 +09:00
Selmar Kok e2c3fe1c0b Merge remote-tracking branch 'origin/master' into channel_target_extensions 2020-01-21 18:46:58 +01:00
Selmar Kok 973d9b3394 add channel.target extensions 2020-01-21 18:45:24 +01:00
Syoyo Fujita 28ad4ab7b8 Add clang fuzzer tester. 2020-01-18 20:31:54 +09:00
Syoyo Fujita 0227ae5d9b Merge pull request #238 from sammyKhan/patch-1
Initialize defaultScene to -1
2020-01-17 21:58:00 +09:00
sammyKhan a0a62bde1c Initialize defaultScene to -1
To prevent undefined behavior if the model is serialized without defaultScene being set explicitly.
2020-01-17 13:41:16 +01:00
Syoyo Fujita 23d1ff2880 Possible fix for error: invalid path 'models/CubeImageUriSpaces/ 2x2 image has multiple spaces.png ' on Windows(NTFS? dislikes extra white space after the file extension ) 2020-01-17 16:15:03 +09:00
Syoyo Fujita bcf2ce586e Merge pull request #237 from FrankGalligan/fix_image_uri_with_spaces
Fix loading images with spaces on Linux
2020-01-14 18:00:48 +09:00
Frank Galligan aa3c5a1cad Fix loading images with spaces on Linux
This change quotes the string before it is passed into wordexp.

This addresses issue https://github.com/syoyo/tinygltf/issues/236
2020-01-13 15:06:56 -08:00
Syoyo Fujita db2fbeec9d Add dlib license. 2020-01-08 02:39:46 +09:00
Syoyo Fujita c4166e4c60 Initial support of decoding percent-encoding URI. 2020-01-08 02:38:01 +09:00
Syoyo Fujita 1cf179d377 Merge pull request #235 from ziocleto/master
BufferView ctor now uses correct members order.
2020-01-08 00:52:09 +09:00
Syoyo Fujita ddc14f8ba6 Merge pull request #233 from 8i/fix-animation-sampler-serialization
Reserve space for animation samplers in serialization
2020-01-08 00:47:41 +09:00
Syoyo Fujita 72f4a55edd Suppress clang warnings. Fixes #234 2020-01-08 00:40:41 +09:00
Dado 379bb612f1 BufferView ctor now uses correct members order.
tiny_gltf.h line 815 
(Moved target(0) to second to last)
2020-01-07 14:41:12 +00:00
Jacek 1da4e5d633 Reserve space for animation samplers in serialization 2020-01-06 15:15:21 -06:00
Syoyo Fujita 4e47bc7799 Fill BufferView variables with initial/invalid values just in case. 2020-01-02 22:07:25 +09:00
Syoyo Fujita 9cc3e91968 Merge pull request #232 from kacprzak/master
Do not set target on bufferView pointing to animation data
2020-01-02 21:53:53 +09:00
Marcin Kacprzak d09788d10f Do not set target on bufferView pointing to animation data 2020-01-02 13:00:48 +01:00
Syoyo Fujita a11f6e1939 Allow empty buffer when serializing glTF buffer data. 2019-12-19 14:20:01 +09:00
Syoyo Fujita 8ced108571 Merge pull request #230 from itainter/fix-primitive-extension
Fix the issue that the extension of primitive written as extension of mesh.
2019-12-18 13:33:46 +09:00
zhaozhiquan 3eb65e269a Fix the issue that the extension of primitive written as extension of mesh. 2019-12-18 11:28:57 +08:00
Syoyo Fujita 1322c7bf09 Merge branch 'master' of github.com:syoyo/tinygltf 2019-11-24 20:50:50 +09:00
Syoyo Fujita 49651fe3d9 Update READE. 2019-11-24 20:50:35 +09:00
Syoyo Fujita db93a87c4a Merge pull request #226 from epajarre/glb-bin-blob
Glb bin blob
2019-11-19 01:30:10 +09:00
Eero Pajarre 7b0d81bf12 Added support for BIN chunk when saving in glb format
If saving in glb (binary) format the first buffer in
model is saved as gbl chunk number 1 in binary format.
This operation is not performed if the first buffer
as an url specified.
2019-11-18 14:15:48 +02:00
Eero Pajarre 2e8a115d7e Only serialize Accessor.normalized if it is true 2019-11-18 13:09:25 +02:00
Eero Pajarre ae9364902a Added Accessor initializers
Added Accessor intializers
Now byteOffset and normalized are initialized to their default
values. componentType and Type are initialized to bad values
on purpose, they must be set when loading or creating the model.
2019-11-18 12:59:05 +02:00
Syoyo Fujita 06d2fbdae6 not is alternative keyword and not recommended to use. Fixes #225 2019-11-17 02:11:59 +09:00
Syoyo Fujita d5ff5cbfb1 Merge branch 'master' of github.com:syoyo/tinygltf 2019-11-16 17:00:42 +09:00
Syoyo Fujita 1d20520680 Correct computation of padding size. Fixes #224. 2019-11-16 17:00:17 +09:00
Syoyo Fujita 4ab0386d09 Fix MinGW code path reused linux code path. 2019-11-10 15:31:17 +09:00
Syoyo Fujita a471770f38 Merge pull request #223 from syoyo/mingw-fix
Mingw fix
2019-11-10 02:03:18 +09:00
Syoyo Fujita 125d8e50a9 fopen_s -> fopen in linux(posix) code path. 2019-11-09 20:52:56 +09:00
Syoyo Fujita 45cac78709 Fix utf8 filepath on MinGW based on PR 222. 2019-11-09 20:42:55 +09:00
Syoyo Fujita a9d86c1af4 Add URL of Vulkan-Samples. 2019-11-08 14:45:16 +09:00
Syoyo Fujita 2f26eddac4 Merge pull request #220 from Selmar/doublesided_default_serialization
Doublesided default serialization
2019-11-01 13:39:36 +09:00
Selmar Kok a0939550ca Merge branch 'master' of github.com:syoyo/tinygltf into doublesided_default_serialization 2019-10-31 15:10:03 +01:00
Selmar Kok 58ab95be2f only serialize doublesided if it is not the default value 2019-10-31 15:08:03 +01:00
Syoyo Fujita bf0e4f8e45 Merge pull request #219 from syoyo/travis-gcc-4.8
Travis gcc 4.8
2019-10-31 19:34:33 +09:00
Syoyo Fujita 30f333c607 Fix travis script. 2019-10-31 02:17:22 +09:00
Syoyo Fujita 419162716e Introduce TINYGLTF_BUILD_EXAMPLES option to CMakeLists.txt. Fixes #218 2019-10-31 01:55:57 +09:00
Syoyo Fujita 9533c352a1 Add gcc-4.8 build on Travis. 2019-10-31 01:02:43 +09:00
Syoyo Fujita 9ff3d93084 Merge pull request #217 from syoyo/store-json-string-for-extras-and-extensions
Add feature to store original JSON string for extras and extensions
2019-10-30 19:08:08 +09:00
Syoyo Fujita aea514a975 Merge pull request #216 from harokyang/feature/utf8_path
Feature/utf8 path
2019-10-30 17:40:22 +09:00
Harokyang 05a4456948 fix build error on C++11/C++14 2019-10-30 16:30:00 +08:00
Syoyo Fujita 6e08b17ce3 Add feature to store original JSON string for extras and extensions(for user-specific JSON parsing). # Fixes 215
Fix some glTF object(e.g. Skin) does not have extras and/or extensions property.
2019-10-30 17:25:38 +09:00
Harokyang fb256609f2 support writing with utf-8 filepath 2019-10-30 16:14:10 +08:00
Harokyang 5cecef2b92 Treat all filepath string as utf-8 encoded
On Windows, convert utf-8 to wchar string before interact with filepath
2019-10-30 15:17:09 +08:00
Syoyo Fujita 1100f0f1eb Allow parsing integer number value as double(For example, glTF-Sample-Models/2.0/Cameras/glTF has zfar number property with integer value, which trigerred a parsing failure). 2019-10-30 15:18:55 +09:00
Syoyo Fujita 2b66c81f67 Merge pull request #212 from Selmar/move_operator
Move semantics
2019-10-30 15:11:26 +09:00
Selmar Kok f29375f59b revert some local modifications, oops.... >_> 2019-10-29 16:25:37 +01:00
Selmar Kok 79e3df26a8 replace TINYGLTF_USE_NO_EXCEPT with GNU compiler version check 2019-10-29 16:22:07 +01:00
Selmar Kok e3cf5edb94 Merge remote-tracking branch 'origin/Selmar-move_operator' into move_operator 2019-10-29 16:09:40 +01:00
Selmar Kok b74fadef8e TINYGLTF_USE_NOEXCEPT 2019-10-29 16:09:32 +01:00
Syoyo Fujita a11709a9ff Merge pull request #213 from dmuir/master
Validate model_length against length in LoadBinaryFromMemory.
2019-10-29 02:20:31 +09:00
Doug Muir cf668683f9 Fix check for invalid glTF to consider invalid length/model_length combinations. 2019-10-28 09:51:13 -07:00
Syoyo Fujita 817bbcfb58 Show clang version in Travis build. 2019-10-23 00:41:40 +09:00
Selmar Kok 23467959ca pbrMetallicRoughnes default noexcept move operator 2019-10-21 19:23:15 +02:00
Selmar Kok 6f08785e9f Merge remote-tracking branch 'origin/master' into move_operator 2019-10-21 17:58:57 +02:00
Selmar Kok ff2b1f92dd use default noexcept move constructor / operator 2019-10-21 17:58:09 +02:00
Syoyo Fujita e886247329 Fix parsing a glTF file with 2GB+ or lareger size. 2019-10-20 17:47:50 +09:00
Syoyo Fujita 83bb1a48d7 Merge pull request #211 from Selmar/add_missing_serialization
small serialization additions
2019-10-19 15:18:19 +09:00
Selmar Kok c3353e1acd set default values for baseColorFactor so that it has correct values when parsing a material without a pbrMetallicRoughness struct 2019-10-18 18:22:35 +02:00
Selmar Kok 81b672bcc2 add some missing serialization // add mesh==() weights comparison // use const iterator for extension serialization 2019-10-18 16:08:44 +02:00
Syoyo Fujita cece6ee6d2 Merge pull request #209 from patriciogonzalezvivo/master
Adding glslViewer
2019-10-08 19:21:51 +09:00
Patricio Gonzalez Vivo 31f875ddbc adding glslViewer 2019-10-08 03:07:58 -07:00
Syoyo Fujita 8dccf9bf4e Merge pull request #208 from toshiks/patch-1
Added project to Readme.md (QuickLook GLTF plugin)
2019-09-15 14:50:06 +09:00
Anton Klochkov 508dcfa2e6 Added project to Readme.md (QuickLook GLTF plugin) 2019-09-15 01:25:47 +03:00
Syoyo Fujita 7e009041e3 Do not serialize pbrMetallicRoughness when they have all default values. Fixes #204 2019-09-13 15:32:22 +09:00
Syoyo Fujita 14977937c2 Add a link to Lighthouse 2. 2019-09-09 20:07:54 +09:00
Syoyo Fujita 8bb18fbd9c Merge pull request #202 from Ybalrid/fix_copy_assignment_operator
Fix broken copy-assignment operators
2019-09-06 13:58:54 +09:00
Arthur Brainville (Ybalrid) 9eeaf20133 Fix copy-assignment operator
When manual move constructor are declared, C++ compilers deletes the
copy constructor and copy-assign operator.

Most of these structures recently got a move ctor added, and copy ctor
re-enabled ( = default ). But copy-assignment are missing, thus in some
context, breaking instantiations of templates like std::vector<>.
2019-09-05 13:02:05 +02:00
Syoyo Fujita a34aa8ea77 Suppress variable-is-shadowed warnings.
Apply clang-format.
Add note on RapidJSON and C++14 compilation flags.
2019-09-05 14:40:32 +09:00
Syoyo Fujita 59b2966f81 Merge branch 'master' of https://github.com/jrkoonce/tinygltf into jrkoonce-master 2019-09-05 14:22:51 +09:00
jrkoonce 7481011fd9 Removing RapidJSON toggle 2019-09-04 13:46:59 -05:00
jrkoonce 0d2b6efa6f Removing warnings 2019-09-04 13:46:45 -05:00
jrkoonce ce7fa7419b Support simultaneous gltf load/saves
Added support for RapidJSON's CrtAllocator which is stateless and allows multiple documents to be in use at once, removing that restriction on default documents.  Enable with TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR
2019-09-04 13:31:44 -05:00
jrkoonce 906f98fa74 Revert "Support simultaneous gltf load/saves"
This reverts commit d2a2703ec5.
2019-09-04 13:30:02 -05:00
jrkoonce d2a2703ec5 Support simultaneous gltf load/saves
Added support for RapidJSON's CrtAllocator which is stateless and allows multiple documents to be in use at once, removing that restriction on default documents.  Enable with TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR
2019-09-04 12:19:27 -05:00
jrkoonce 95f05757d6 Revert "Support simultaneous gltf load/saves (TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR)"
This reverts commit ab63db6318.
2019-09-04 12:15:51 -05:00
jrkoonce ab63db6318 Support simultaneous gltf load/saves (TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR)
This allows multiple gltf's to be loaded/saved in parallel.  It removes the restriction of a single JsonDocument active at once which is default behavior.  Enable with TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR
2019-09-04 12:01:39 -05:00
jrkoonce 6ff95392b0 Fix Compiler Warnings 2019-09-04 10:50:55 -05:00
Syoyo Fujita c29bd3d9ce Use const reference for Buffer to fix compilation.
Removed UTF BOM?
2019-09-04 14:26:58 +09:00
jrkoonce 63419a11e1 Revert accidental committed change
Put "JsonX" helpers back in anonymous namespace to keep them inside local translation unit.
2019-09-03 17:06:41 -05:00
jrkoonce 06c30c4d04 Fixed Bugs/Unit Tests Pass
Fixed bugs found by unit tests and got unit tests running with RapidJSON as well as nlohmann.
2019-09-03 15:56:48 -05:00
jrkoonce 67e6160a9a Fixed move bugs 2019-09-03 10:42:39 -05:00
jrkoonce a3b8b355ae Merge branch 'pr/1' 2019-09-03 10:30:19 -05:00
jrkoonce 5145394239 Made C++14 optional, default off. 2019-09-03 09:48:30 -05:00
Syoyo Fujita 67aa2ca75e Merge pull request #200 from ux3d/feature/allow-scenes-without-nodes
allow scenes without nodes
2019-09-02 22:12:15 +09:00
Benjamin Schmithüsen ce25385eab remove extra parenthesis 2019-09-02 13:43:24 +02:00
Benjamin Schmithüsen 6143c6662b don't fail if a scene has no nodes property (which is not required) 2019-09-02 13:41:59 +02:00
Syoyo Fujita 81d75df48a Rename typeSizeInBytes to numComponents. 2019-08-30 19:19:52 +09:00
DingboDingboDingbo 83ccb9f28d GetTypeSizeInBytes not returning Type Size In Bytes
Changed name to be less misleading.
2019-08-29 18:49:15 -04:00
jrkoonce 9b6f52e98a Fix bug in ParseNumberArrayProperty()
Only doubles were being accepted instead of any number (including ordinals)
2019-08-29 13:56:58 -05:00
jrkoonce 5cecc41db9 More cleanup
1. Reserve array memory when converting JSON to Value for heap efficiency.
2. Grouped more JSON abstraction functions together and put in anonymous namespace instead of making each static.
2019-08-29 11:45:04 -05:00
jrkoonce 208c3058bf Remove test code accidentally commited 2019-08-29 11:28:07 -05:00
jrkoonce cba5d6caae RapidJson 1.1 support + More move semantics
*Support for RapidJson 1.1, use TINYGLTF_USE_RAPIDJSON to toggle between RapidJson and nlohmann

*Lot more move semantics enabled.  All parsing and serialization now move all json objects with far fewer copies
2019-08-29 11:26:22 -05:00
jrkoonce d1e1472992 Update tiny_gltf.h
Add/Enable move semantics to most all structs/classes
2019-08-27 11:51:02 -05:00
Syoyo Fujita ff51570c26 Apply clang format.
Remove `const static std::string` global variable.
2019-08-24 16:29:14 +09:00
Syoyo Fujita a472a3fa0f Add Set/Get SerializeDefaultValues method(W.I.P.) 2019-08-21 14:23:00 +09:00
Syoyo Fujita 1f160d5b8f Merge pull request #195 from ux3d/fix/parse-int-as-double
(also) parse int as double
2019-08-20 19:33:20 +09:00
Syoyo Fujita 5150a46072 Merge branch 'master' of github.com:syoyo/tinygltf 2019-08-20 17:11:29 +09:00
Syoyo Fujita cea69e37a5 Suppress clang warnings. 2019-08-20 17:10:30 +09:00
Syoyo Fujita 8b56c016ab Merge pull request #193 from Selmar/emissiveFactor_defaults
Emissive factor defaults
2019-08-20 13:13:12 +09:00
Benjamin Schmithüsen c7e205be87 when parsing a number from an int, also set the 'real value' to the value 2019-08-19 16:16:43 +02:00
Selmar Kok 6dba6c6aac [emissiveFactor] correct default values 2019-08-19 11:23:31 +02:00
Selmar Kok 6df800d2b6 [emissiveFactor] fix inconsistency with baseColorFactor where default values were set only for baseColorFactor and not emissiveFactor 2019-08-19 11:05:28 +02:00
Syoyo Fujita 2f044e77f1 Merge pull request #191 from Selmar/animation_extension_properties
Animation extension properties
2019-08-17 01:09:34 +09:00
Selmar Kok af5a5ef026 Merge branch 'master' of github.com:syoyo/tinygltf into animation_extension_properties 2019-08-16 17:54:14 +02:00
Syoyo Fujita 6591ba4461 Merge pull request #190 from ux3d/feature/parse-node-weights
parse/serialize node weights
2019-08-16 22:21:48 +09:00
Benjamin Schmithüsen 74c3c10121 serialize node weights 2019-08-16 14:24:26 +02:00
Benjamin Schmithüsen ad63bf748b parse node weights 2019-08-16 14:19:27 +02:00
Selmar Kok 5d43cf8e64 Merge branch 'master' of github.com:syoyo/tinygltf 2019-08-16 14:08:31 +02:00
Selmar Kok 4e2988eebd add extension property for Animation and AnimationChannel 2019-08-16 14:08:08 +02:00
Syoyo Fujita ee179b2cb6 Set default value of minFilter and magFilter in Sampler to -1(unset), since glTF 2.0 spec does not declare default values for it.
Fixes #186
2019-08-16 13:11:30 +09:00
Syoyo Fujita 4ebd6368fb Fix inequality of texture index check when serializing texture of material.
Texture info was written even if it have invalid index(-1). Fixes #189
2019-08-15 12:25:50 +09:00
Syoyo Fujita 67d3d2504d Merge pull request #188 from ux3d/fix/alphaMode
Fixed saving of alphaMode if not OPAQUE
2019-08-14 21:40:07 +09:00
Patrick Härtl d9a468bbb4 Fixed saving of alphaMode if not OPAQUE
Removed duplicated code for alphaCutoff
2019-08-14 14:14:07 +02:00
Syoyo Fujita c7bae71f7f Merge pull request #185 from DerouineauNicolas/endif
remove extra #endif in examples/basic app
2019-08-14 03:09:53 +09:00
nicolasDEROUINEAU f93642c196 remove extra #endif in examples/basic app 2019-08-13 15:08:01 +02:00
Syoyo Fujita f68d5e1f2a Merge pull request #182 from ux3d/textureinfo
[TextureInfo] fix default value checks for serialization
2019-07-26 01:29:23 +09:00
Benjamin Schmithüsen 1c84fc22a5 fix default value checks for serialization 2019-07-25 16:07:27 +02:00
Syoyo Fujita 150f243b1b Change the behavior of NUMBER value in Value class. NUMBER now reprents the value is either int or real(floating point). 2019-07-25 19:22:44 +09:00
Syoyo Fujita 0ee273fdfa Update README. Add note on tinygltf::Value for extensions. 2019-07-24 19:55:04 +09:00
Syoyo Fujita 046400b17f Now material is parsed as a struct with explicit parameter definitions.
Implement Material struct serialization.
2019-07-24 19:26:48 +09:00
Syoyo Fujita 89fd93f815 Introduce TextureInfo class(W.I.P.) 2019-07-23 22:37:06 +09:00
Syoyo Fujita e940337796 Merge pull request #180 from ux3d/master
Explicitly use the correct constructor for empty object
2019-07-23 18:55:34 +09:00
Syoyo Fujita 1b5f476d95 Merge pull request #178 from rapidimages/feature/write-to-streams
Serialize to stream
2019-07-17 18:53:35 +09:00
Johan Bowald 52936a00e0 clang format 2019-07-17 09:06:45 +02:00
Benjamin Schmithüsen f3ef880029 call json constructor explicitly 2019-07-16 17:07:45 +02:00
Johan Bowald 1af7c1d784 can write to streams 2019-07-16 15:56:18 +02:00
Benjamin Schmithüsen c0b79afecc Merge pull request #2 from syoyo/master
update from original repository
2019-07-15 15:13:50 +02:00
Syoyo Fujita c49461b7c2 Merge pull request #176 from ux3d/feature/update-lights
Feature: update lights
2019-07-10 21:20:12 +09:00
Benjamin Schmithüsen 051f4be2f1 serialize lights 2019-07-09 17:59:20 +02:00
Benjamin Schmithüsen 4557b6aa22 fix spot light parsingg 2019-07-09 16:55:55 +02:00
Benjamin Schmithüsen b2d7d88dbc parse additional light properties and fix defaults 2019-07-09 16:32:42 +02:00
Benjamin Schmithüsen b7ca7c9381 update lights to follow the KHR_lights_punctual extension 2019-07-08 18:04:24 +02:00
Benjamin Schmithüsen 0ffedcbe79 Merge pull request #1 from syoyo/master
update fork
2019-07-08 17:40:20 +02:00
Syoyo Fujita 80faac5238 Merge pull request #174 from Ybalrid/pr_material_param_tex_info
Add Parameter::TextureStrength(). Precise default values.
2019-07-05 14:11:15 +09:00
Arthur Brianville (Ybalrid) 2a9d9deb67 Applied clang-format 2019-07-05 00:30:47 +02:00
Arthur Brainville 8a98d98cd9 Add Paramter::TextureStrength(). Precise default values.
The default values on these methods as been set to what is described [here](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0?ts=4#normaltextureinfo) and [here](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0?ts=4#occlusiontextureinfo).

This is to keep consistent with the API behavior from #144
2019-07-05 00:30:20 +02:00
Syoyo Fujita 689edcbef6 Merge pull request #173 from christophe-f8/master
Adding texture scale reading + asset copyright and texture names to the export
2019-07-04 15:39:22 +09:00
Christophe 820ede87db Adding texture scale reading (for normal maps) + asset copyright and texture names to the export 2019-07-04 15:21:21 +09:00
Syoyo Fujita d6b0d0a61f Explicitly define copy constructor and copy assignment operator for Model an Node. 2019-06-29 17:31:13 +09:00
Syoyo Fujita 5f180aaf74 Merge pull request #171 from Ybalrid/fix_double_parse_material_name
Material names are stored once in material.name, then duplicated in "additionalValues"
2019-06-24 14:06:55 +09:00
Arthur Brainville (Ybalrid) dab0daaedf Material names are stored once in material.name, then duplicated in "additionalValues"
This patch prevent this duplication
2019-06-23 21:50:10 +02:00
Syoyo Fujita 0ccc8dc262 Merge pull request #170 from Ybalrid/msvc_warn_fix
Fix C4267 warning (size_t -> int) convertion
2019-06-15 15:58:03 +09:00
Arthur Brainville (Ybalrid) 811e1d3899 Fix C4267 warning (size_t -> int) convertion 2019-06-15 07:32:38 +02:00
Syoyo Fujita f65e06c5ca Merge pull request #169 from Ybalrid/remove_mesh_targets
Remove Mesh::targets, as targets only exists inside `Primitive`
2019-05-26 16:23:46 +09:00
Arthur Brianville (Ybalrid) f29ae1a653 Remove Mesh::targets, as targets only exists inside Primitive 2019-05-25 22:30:55 +02:00
Syoyo Fujita 3bf16e4be5 Merge branch 'master' of github.com:syoyo/tinygltf 2019-05-16 16:55:09 +09:00
Syoyo Fujita fbc4295770 Remove CATMULLROMSPLINE, which was removed in the final glTF 2.0 spec. 2019-05-16 16:54:28 +09:00
Syoyo Fujita edf8d5cae1 Merge pull request #164 from DiligentGraphics/master
Updated readme: added link to Diligent Engine
2019-05-09 12:47:24 +09:00
DiligentGraphics b7f2473225 Updated readme: added link to Diligent Engine 2019-05-08 18:33:26 -07:00
Syoyo Fujita ed7bf66255 Merge pull request #162 from ux3d/master
add REQUIRE_VERSION to gltf validation and use it as default instead of REQUIRE_ALL
2019-05-03 15:08:36 +09:00
Syoyo Fujita caa36dd050 Merge pull request #163 from jwmcglynn/fix-test-gltfs-standalone
Add "asset" section to BoundsChecking test models
2019-05-03 15:06:38 +09:00
Jeff McGlynn 389d5016ad Add "asset" section to BoundsChecking test models
These test assets were trimmed down and erroneously didn't have an
"asset" section or version number, which is required by the glTF spec.

This fixes test failures with pull request #162.
2019-05-02 23:05:13 -07:00
Benjamin Schmithüsen d02ad0dede add REQUIRE_VERSION to gltf validation and use it as default instead of REQUIRE_ALL 2019-05-02 14:44:20 +02:00
Syoyo Fujita 8f67121deb Merge pull request #161 from rainliang000/patch-1
if image.uri empty, should use image.bufferView
2019-04-29 17:48:47 +09:00
rainliang000 62be8d04cf if image.uri empty, should use bufferview
if uri empty, shoud use mimeType and bufferview
2019-04-29 09:54:27 +08:00
Syoyo Fujita d11a4c4d71 Merge pull request #160 from jwmcglynn/parse-integer
Parse integers directly instead of casting doubles
2019-04-27 14:57:54 +09:00
Jeff McGlynn 19b806e052 Parse integers directly instead of casting doubles
When parsing numeric values as doubles, its possible for users to
specify values that cannot be converted to integers, such as Inf, NaN,
and extremes such as 1e100.  If this value is received, and then cast to
an int, it is undefined behavior, which trips ubsan when running
tinygltf under a fuzzer.

Instead of parsing integral values as doubles, use nlohmann/json's
built-in support to parse integer and unsigned values directly, with
.is_number_integer() and .is_number_unsigned().

Add ParseIntegerProperty, ParseUnsignedProperty, and
ParseIntegerArrayProperty helpers that allow parsing directly to
int/uint values and update code to use them when appropriate.
2019-04-26 17:20:50 -07:00
Syoyo Fujita e0ab69cb31 Merge pull request #158 from jwmcglynn/bounds-checking
Add checks for boundary conditions for malformed glTF files
2019-04-26 12:56:21 +09:00
Jeff McGlynn 8915252407 Add checks for boundary conditions for malformed glTF files
When loading untrusted glTF files, ideally an error should be returned
if the file is malformed instead of an exception/crash.  Add additional
validation for crashes found when running tinygltf under a fuzzer, and
add test cases to confirm:

1. Validate that the primitive indices value is within the
   model->accessors bounds before dereferencing.
2. Validate that the accessors bufferView index if valid.
3. Validate that the buffer's index is valid when parsing images.
4. For glb files, validate that the overall length is within the
   provided input buffer.
2019-04-25 16:51:09 -07:00
Jeff McGlynn 9446f65667 Set up tests to run in travis-ci and ignore test outputs in .gitignore 2019-04-25 16:26:26 -07:00
Syoyo Fujita fb9f709166 Merge pull request #157 from Selmar/patch-1
correct Value::Equals mistake
2019-04-17 03:19:00 +09:00
Selmar a63cc6373d correct Value::Equals mistake
a missing exclamation mark... ^^
2019-04-16 16:57:43 +02:00
Syoyo Fujita b3c1471317 Merge pull request #155 from ffreling/accessor-normalized
Serialize accessor 'normalized' attribute.
2019-03-22 01:32:34 +09:00
Fabien Freling 9056aee823 Serialize accessor 'normalized' attribute. 2019-03-21 17:06:22 +01:00
Syoyo Fujita 29c431b2f2 Add build option with draco in Makefile. 2019-03-08 14:01:06 +09:00
Syoyo Fujita d06b2c2022 Merge pull request #154 from Ybalrid/patch-3
Fix the display of the version history
2019-03-08 13:32:31 +09:00
Arthur Brainville 339c9d578a Fix the display of the version history
Markdown is like HTML: simple line-breaks don't work.

Besides, making a list with dots here looks nicer :)
2019-03-07 19:40:57 +01:00
Syoyo Fujita 7c315fa8a8 Merge pull request #153 from Ybalrid/patch-2
fix a few typos in README.md
2019-03-07 21:30:20 +09:00
Arthur Brainville 0f04ed018a fix a few typos in README.md 2019-03-07 13:23:59 +01:00
Syoyo Fujita ca56f726d6 Merge branch '16bit-lodepng' 2019-03-07 21:04:25 +09:00
Syoyo Fujita e8a46c4e1d Update README.
Check bit depth when saving image as PNG.
2019-03-07 20:50:58 +09:00
Syoyo Fujita 9cd14a461b Update README. 2019-03-07 01:05:02 +09:00
Syoyo Fujita 1ef603ea2a Merge pull request #150 from Ybalrid/sparse_accessor
Sparse accessor
2019-03-07 00:49:29 +09:00
Arthur Brainville (Ybalrid) 14d259f361 glview can now load static geometry modified by sparse accessor 2019-03-06 14:48:44 +00:00
Arthur Brainville (Ybalrid) 9223d3133a Ran clang-format on tiny_gltf.h 2019-03-06 14:00:56 +00:00
Arthur Brainville (Ybalrid) 9b321a8515 clang-format + added sparse accessor in loader_example 2019-03-06 12:39:39 +00:00
Arthur Brainville (Ybalrid) 7e9f734d73 Parse sparse accessors 2019-03-06 12:27:23 +00:00
Arthur Brainville (Ybalrid) 9d86405d3d Fix accessor ctor 2019-03-06 11:33:30 +00:00
Arthur Brainville (Ybalrid) 1ccb4ff580 added sparse structure to accessors 2019-03-06 11:30:00 +01:00
Syoyo Fujita 8fd91aea04 Update TinyEXR. 2019-03-04 02:15:03 +09:00
Syoyo Fujita 8f76d790b8 Merge pull request #148 from Ybalrid/16bit-lodepng-good-byteswap
When writing out a 16bit image with lodepng, simplify the byteswap to big-endian
2019-03-04 01:15:20 +09:00
Arthur Brainville (Ybalrid) 853f6df7b5 Simplify byteswap code to convert to big endian 16bit 2019-03-03 16:26:20 +01:00
Syoyo Fujita 758a1240c9 Reorder 16 bit pixel data to big endian when saving it as 16 png, since lodepng::encode expects image data is in big endian manner.
Add OpenEXR saver for 16bit image as a bonus.
2019-03-03 21:21:18 +09:00
Syoyo Fujita 7bdfed3bec Add lodepng to save 16bit PNG.
Suppress clang/gcc warnings.
2019-03-03 17:04:49 +09:00
Syoyo Fujita bf9c2f4abd Merge pull request #146 from WARP-LAB/master
Fix for when json and stb is aready used in project
2019-03-03 15:31:09 +09:00
kroko fc0116b323 rename TINYGLTF_BYPASS_INCLUDE_x to TINYGLTF_NO_INCLUDE_x 2019-03-03 08:28:49 +02:00
Syoyo Fujita 962552c5c8 Merge pull request #145 from Ybalrid/upgrade_stb_libs
Upgrade the STB libraries, and fix #132
2019-03-03 13:39:10 +09:00
kroko 606e5dde31 be more precise in readme about include bypassing flags 2019-03-03 01:56:34 +02:00
kroko 6a0d4c57b1 Fix for when json and stb is aready used in project v2 2019-03-03 01:28:45 +02:00
kroko f4b6d11abc Fix for when json and stb is aready used in project 2019-03-03 01:11:31 +02:00
Arthur Brainville (Ybalrid) 5a4c898912 Fixed wrong metadata in case 16bit image wasn't actually loaded
The fallback to 8 bit would have been broken.
2019-03-02 22:03:34 +01:00
Arthur Brainville (Ybalrid) f2addc0e44 16bit images are 16bit images: added Image::bits and Image::pixel_type 2019-03-02 22:00:48 +01:00
Arthur Brainville (Ybalrid) 70d16a7b92 Upgrade the STB libraries, and fix #132 2019-03-02 16:10:54 +01:00
Syoyo Fujita 326d7ea310 Merge pull request #144 from SaschaWillems/master
Add direct access to texture coordinate set on texture parameter
2019-02-24 14:42:51 +09:00
Sascha Willems eb011068c0 Added function to easily access texture coordinate set index on a texture parameter 2019-02-23 21:15:45 +01:00
Syoyo Fujita 87be0ce34b Define WIN32_LEAN_AND_MEAN to save the number of including files. 2019-02-19 21:36:32 +09:00
Syoyo Fujita 7d9a0bda3a Define NOMINMAX to avoid defining MIN/MAX macros on Windows. Without defining NOMINMAX, MIN/MAX macro would affect other header/c++ files. Fixes #143 2019-02-19 16:03:23 +09:00
Syoyo Fujita 7ece5c8275 Merge pull request #142 from ebirenbaum/animation-sampler-interpolation
Change AnimationSampler::interpolation to a non-required field.
2019-02-15 14:04:06 +09:00
Evan Birenbaum 6bdffedcbe Change AnimationSampler::interpolation to a non-required field. The spec states to default to LINEAR when not present. 2019-02-14 13:30:57 -08:00
Syoyo Fujita d2fb7dc2af Merge pull request #140 from timmmeh/master
Adding default values for min and mag filter.
2019-02-10 00:01:11 +09:00
Syoyo Fujita c0d0251e2c Update json.hpp to fix compilation with clang with C++17(-std=c++1z) support. 2019-02-04 16:19:13 +09:00
timmmeh 62a72c4845 fix compile 2019-01-31 11:46:19 -08:00
timmmeh 73584ba7b7 Adding default values for min and mag filter. 2019-01-30 18:38:46 -08:00
Syoyo Fujita ead876fce9 Merge pull request #138 from dolphineye/dolphineye/add_mode_line_strip
Add line strip primitive mode define
2019-01-30 23:19:30 +09:00
Thomas Tissot 6c4a006496 Add line strip primitive mode define
This small commit adds the `TINYGLTF_MODE_LINE_STRIP` primitive mode
define whose value is set to `3` as per the GLTF 2.0 specification.
2019-01-30 13:10:51 +01:00
Syoyo Fujita 281af41b6c Merge pull request #137 from Ybalrid/pr_fix_glview_no_scene_no_nodes
Fix glView in case there is no default scene
2019-01-28 13:00:26 +09:00
Arthur Brainville (Ybalrid) 215e1fae61 handle not having default scene 2019-01-27 20:52:04 +00:00
Arthur Brainville (Ybalrid) cba75b9927 fix glview in case gltf asset doesn't have a default scene 2019-01-27 20:52:04 +00:00
Syoyo Fujita 4de57db325 Add TINYGLTF_ENABLE_DRACO flag to README. 2019-01-27 00:43:02 +09:00
Syoyo Fujita a32fa80102 Add support for building glview with draco.
Fix out-of-bounds access when calling DrawMesh().
Fix potential out-of-bounds access when filling window title string.
2019-01-27 00:38:34 +09:00
Syoyo Fujita 5f34dab548 Merge pull request #136 from abwood/draco
Fixed decoding bugs in draco
2019-01-26 23:22:55 +09:00
Alexander Wood 0d77a291f7 Updates to draco decoding:
- When injecting draco decoded meshes into accessor data, update count to match the optimized and decoded draco mesh
 - accessor.componentType is now used for extraction of decoded draco meshes.

Fixes #135
2019-01-26 08:58:45 -05:00
Syoyo Fujita b926195ef8 Merge pull request #134 from abwood/draco
Initial support for draco mesh compression
2019-01-25 16:45:33 +09:00
Alex Wood c8ba17fcab Looks like I'm colliding with work by syoyo. Only difference so far appears to be our macro name. 2019-01-24 15:45:16 -05:00
Alex Wood df39e04e7b Merge branch 'draco' of https://github.com/abwood/tinygltf into draco 2019-01-24 15:40:28 -05:00
Alex Wood 7319db7a50 Initial support for draco mesh compression. In this PR, we establish that draco is a dependency built external to tinygltf, which breaks from the current tradition of header only dependencies. For that reason, this feature is hidden behind a #define TINYGLTF_ENABLE_DRACO and requires developers to explicitly opt-in for draco support.
In this change, tinygltf any primitive using draco compression will:
If indices are specified
1) Decode the index buffer using draco, creating a new buffer and bufferview, adding to Model::bufferViews and Model::buffer collections
2) Update the primitive's accessor id to reference this new decoded bufferview.
For each attribute semantic specified by the draco extension
1) Decode the vertex buffer using draco, creating a new buffer and bufferview, adding to Model::bufferViews and Model::buffer collections
2) Update the primitive's accessor id to reference this new decoded bufferview.
2019-01-24 15:38:16 -05:00
Syoyo Fujita 7ae7110800 Begin supporting draco. 2019-01-19 03:03:22 +09:00
Syoyo Fujita b864ea7349 Support macOS + OpenGL 3.3+ GPU 2019-01-14 22:11:11 +09:00
Syoyo Fujita d6b0b0b990 Convert UTF16 file to UTF8.
Add premake project to build on Linux.
2019-01-14 21:30:53 +09:00
Syoyo Fujita af3ebb2e76 Show more expressive messages when parsing image. 2019-01-06 18:55:57 +09:00
Syoyo Fujita 105694b468 Merge pull request #129 from SaschaWillems/master
Added new compiler option for loading all gltf related files from android app asset package
2018-12-29 12:33:34 +09:00
Sascha Willems 5f9cb24245 Added new feature for loading all gltf related files (including textures, binaries, etc.) from assets packaged with an Android app 2018-12-28 20:53:41 +01:00
Syoyo Fujita 9fcd3f998e Merge pull request #127 from nyue/master
Renamed glTFConfig to TinyGLTFConfig
2018-12-28 14:31:33 +09:00
Tan Meng Yue d96b45df06 Renamed glTFConfig to TinyGLTFConfig
This renaming is done so that the config file matches
the project name which is TinyGLTF. This is done to prevent
future name collision should the Khronos glTF project decides
to provide their own CMake configuration file.
2018-12-27 10:24:13 +11:00
Syoyo Fujita dd7c9efbea Merge pull request #125 from nyue/master
Fix bug in handling OS X build via CMake
2018-12-25 15:06:37 +09:00
Tan Meng Yue 80a85af661 Fix bug in handling OS X build via CMake
The OS macros needs to be upper case for the
if statement to work as expected
2018-12-25 17:03:58 +11:00
Syoyo Fujita 7cf2c44ad7 Merge pull request #124 from nyue/master
Fix GLFW3 handling on CentOS
2018-12-25 11:27:33 +09:00
Nicholas Yue f1b5bb12fd Add support for static GLFW3 library linking 2018-12-25 09:48:26 +11:00
Nicholas Yue 174334eaf4 Fix GLFW3 handling on CentOS 2018-12-25 09:15:13 +11:00
Syoyo Fujita 1212a6ee51 Update README. 2018-12-24 01:50:17 +09:00
Syoyo Fujita 8674c60781 Add document on TINYGLTF_NO_EXTERNAL_IMAGE. Fixes #123 2018-12-18 21:59:23 +09:00
Syoyo Fujita 9d89f02cf0 Merge pull request #122 from lebek/master
Fix incorrect index into bufferViews array
2018-12-09 12:23:39 +09:00
Peter Le Bek 463408c4a0 Fix incorrect index into bufferViews array 2018-12-08 16:04:42 -08:00
Syoyo Fujita a9d862aeee Merge pull request #119 from nyue/master
Add CMake package for developer
2018-12-07 18:48:14 +09:00
Tan Meng Yue 2123da775b Add CMake package for developer
Added the glTFConfig.cmake file so that once
installed, it is easy for developers to find
all the path location for include purposes.
2018-12-07 20:45:13 +11:00
Syoyo Fujita 20806b27d7 Merge pull request #118 from nyue/master
Added more CMake support
2018-12-07 16:07:16 +09:00
Tan Meng Yue 94fcfdeb9d Added installation of headers and target binaries 2018-12-07 18:01:08 +11:00
Syoyo Fujita d44b6e7bcc Merge pull request #117 from viperscape/master
Fill in missing bufferView targets
2018-12-06 11:20:18 +09:00
viperscape 9df05806ad find missing bufferView target types and fill them in 2018-12-05 14:11:01 -05:00
Chris Gill 93db9e20c0 Merge pull request #1 from syoyo/master
update to latest
2018-12-05 13:03:44 -05:00
Syoyo Fujita 2c5597f591 Merge pull request #115 from Selmar/serialization_fixes
some serialization fixes
2018-12-06 02:05:26 +09:00
Tan Meng Yue 2dcf79566f Add CMake configuration for glview
So that we can build more of the examples consistently
with CMake
2018-12-05 23:56:23 +11:00
Tan Meng Yue f20888ae8b Added top level CMake configuration file 2018-12-05 23:55:53 +11:00
Selmar Kok 5892d3e3ea Set a default for sampler.wrapR, because it was serializing an uninitialized value 2018-12-04 19:55:56 +01:00
Selmar Kok 27aab61d62 Fix prettyprint to really not print pretty 2018-11-30 18:01:31 +01:00
Syoyo Fujita d80f0f9a6c Merge pull request #111 from viperscape/master
This is a basic example I added after figuring out how to use the tinygltf library
2018-11-16 14:01:13 +09:00
Syoyo Fujita 5110820ebb Merge pull request #110 from AlvaroBarua/warnings_cleanup
Removed unreachable code and fixed ambiguity warning.
2018-11-16 14:00:33 +09:00
viperscape c3e34c2ff7 add screenshot 2018-11-15 17:03:38 -05:00
viperscape 0ddfaead8f add basic example 2018-11-15 17:02:20 -05:00
Unknown ae2cf8e26f Removed unreachable code and fixed ambiguity warning. 2018-11-15 18:36:59 +00:00
Syoyo Fujita 8b7cdde30c Merge pull request #109 from viperscape/master
Windows build with provided VS solution
2018-11-15 00:28:06 +09:00
viperscape 764bcb5a8a add win32 includes 2018-11-14 10:19:39 -05:00
viperscape 50ada7ff11 rework to include VS 2017 project, fully configured and tested 2018-11-14 10:15:58 -05:00
Syoyo Fujita 16fae080f9 Merge branch 'master' of github.com:syoyo/tinygltf 2018-11-10 20:08:02 +09:00
Syoyo Fujita 90c0008b0e Merge branch 'loomai-master' 2018-11-10 20:07:47 +09:00
Syoyo Fujita b572650d26 Merge branch 'master' of https://github.com/loomai/tinygltf into loomai-master 2018-11-10 20:07:15 +09:00
Syoyo Fujita 6af9e886cd Merge pull request #107 from Selmar/serialization_fixes
Add missing serialization of `sampler.wrapR`
2018-11-10 02:32:56 +09:00
Selmar Kok 60f97325b1 Merge remote-tracking branch 'origin/master' into serialization_fixes 2018-11-09 10:34:55 +01:00
Selmar Kok a3595488e3 Fix missing serialization: sampler.wrapR 2018-11-09 10:34:39 +01:00
Syoyo Fujita cf60322e73 Merge pull request #105 from rapidimages/bugfix/write_image_to_disk
Fixed a reference error which cause an error when writing images to disk
2018-11-07 00:56:34 +09:00
Johan Bowald 77decfaff8 fixed a reference error which cause an error when writing images to disk 2018-11-06 14:28:20 +01:00
Syoyo Fujita e26117e026 Merge branch 'master' of github.com:syoyo/tinygltf 2018-11-05 13:33:27 +09:00
Syoyo Fujita 33514af61a Fix logic error. Fixes #104 2018-11-05 13:32:43 +09:00
Syoyo Fujita ba3c3c99ef Merge pull request #102 from 1div0/master
Building glview failed
2018-10-28 15:30:21 +09:00
Syoyo Fujita 8d96b4a14e Merge pull request #103 from Selmar/serialization_fixes
[serialization] handle failing buffer file writes
2018-10-26 02:12:24 +09:00
Selmar Kok 1cef6dcf33 Merge remote-tracking branch 'origin/master' into serialization_fixes 2018-10-25 16:48:14 +02:00
Selmar Kok e46774940c fail serialization if a buffer file fails to be written (e.g. due to access rights) 2018-10-25 16:45:49 +02:00
Peter Kovář dddaee695d Merge branch 'master' of https://github.com/1div0/tinygltf 2018-10-17 15:30:33 +02:00
Peter Kovář a645cfc840 Added include directory ../common/ for trackball.h 2018-10-17 15:29:56 +02:00
Peter Kovář 040310e0d3 Added include direectory ../common/ for trackball.h 2018-10-17 15:24:59 +02:00
Syoyo Fujita d9eddbfeb9 Merge pull request #101 from 1div0/master
make lint
2018-10-16 19:11:17 +09:00
Peter Kovář 10365a53ff Fixed make lint 2018-10-16 12:03:45 +02:00
Peter Kovář d0e293fd7d Fixed typos 2018-10-16 12:00:24 +02:00
Syoyo Fujita 3b25d9130a Merge pull request #100 from Selmar/serialization_fixes
yet another serialization fix
2018-10-11 01:25:12 +09:00
Selmar Kok db7f4e4d04 fix an issue when serializing an empty extension object would serialize as type null (and thus deserialize as type null, causing it to be ignored) 2018-10-10 18:10:58 +02:00
Syoyo Fujita 30bbe0fe3c Merge pull request #99 from Selmar/serialization_fixes
Pretty print & some (de)serialization fixes
2018-10-09 02:12:38 +09:00
Selmar Kok ee3d06646d // pretty print as optional parameter, default true
// serialize name instead of type for camera.name
// create empy Value::Object if extension value parsing failed
2018-10-08 16:20:43 +02:00
Syoyo Fujita 924d86e362 Serialize extension with empty object. Fixes #97
Use pretty printing JSON when serializing for the readability.
2018-10-08 21:18:33 +09:00
Syoyo Fujita 68353f1b34 Merge branch 'master' of github.com:syoyo/tinygltf 2018-10-07 20:35:14 +09:00
Syoyo Fujita 05a8d0bc52 Fix premake script. 2018-10-07 20:34:45 +09:00
Syoyo Fujita 39a263c2a8 Merge branch 'master' of github.com:syoyo/tinygltf 2018-10-06 03:20:31 +09:00
Syoyo Fujita 61673a62ef Update README. 2018-10-06 03:20:11 +09:00
Syoyo Fujita fdf105645b Merge pull request #96 from Selmar/serialization_fixes
Serialization & comparison fixes
2018-10-06 01:36:27 +09:00
Selmar Kok 440cb1e66b tabs to spaces 2018-10-05 16:30:50 +02:00
Selmar Kok c884e5827e better implementation for bin file name checking 2018-10-05 16:25:54 +02:00
Selmar Kok 7cb31e4e23 - support writing multiple bin files
- use existing buffer.uri as filename if not empty and not a data uri
2018-10-05 16:02:29 +02:00
Selmar Kok 2bda71c8fb - always check Parameter::number_value to catch user errors, e.g. setting number_value without setting has_number_value, which will cause it to serialize as a bool but read back in as a float anyway 2018-10-05 14:36:05 +02:00
Selmar Kok 13b6402388 Merge branch 'master' of github.com:syoyo/tinygltf into serialization_fixes 2018-10-05 14:30:16 +02:00
Selmar Kok 8eb3904de2 - Parse image extras property
- Optionally serialize texture.source (it is not required in the current spec)
2018-10-05 14:29:35 +02:00
Syoyo Fujita b5a72a1ba2 Remove duplicated files. 2018-10-04 15:48:17 +09:00
Syoyo Fujita 0820d83a9d Update to v2.0.1 2018-10-04 15:45:13 +09:00
Syoyo Fujita 641b3ccf8c Suppress clang warnings.
Apply clang-format.
2018-10-04 15:43:33 +09:00
Syoyo Fujita 7518334044 Merge pull request #95 from Selmar/equality_operator_and_some_additions
Equality operator and some additions
2018-10-04 13:56:35 +09:00
Syoyo Fujita efc919c022 Merge branch 'master' into devel 2018-10-04 13:55:21 +09:00
Selmar Kok fa0a998a8b Merge branch 'master' of github.com:syoyo/tinygltf into equality_operator_and_some_additions
# Conflicts:
#	tiny_gltf.h
2018-10-03 15:46:23 +02:00
Selmar Kok 31cb7f92d8 // equality operator for tinygltf::Model and types contained by it
// double comparison (although perhaps not necessary, as json reads/writes bytes directly? unsure..)
// initialize some variables for operator==() reliabiltiy
// change some floats to doubles
// intellisense define
// serialize accessor.name
// dont serialize some names if they're empty
// return false if writing gltf file fails
2018-10-03 15:39:05 +02:00
Syoyo Fujita e59dd6a5c0 Update TODOs. 2018-09-25 03:03:49 +09:00
Syoyo Fujita e66d8c992f Add as-is flag to Image. Tentative solution for issue #82 2018-09-02 16:58:43 +09:00
Syoyo Fujita 3e53feb046 Parse extensions property of Image. 2018-09-02 15:36:17 +09:00
Syoyo Fujita 9ec7109089 Bump clang version from 3.7 to 3.9 since clang-3.7 apt source is untrusted. 2018-08-30 21:27:11 +09:00
David Harmon da9eac2fbe Enable support for writing binary glTF. 2018-08-30 08:06:05 -04:00
Syoyo Fujita 5cf22e3abc Merge branch 'master' of github.com:syoyo/tinygltf 2018-08-28 21:34:06 +09:00
Syoyo Fujita a8f0b1c383 Suppress unknown pragma warning on clang 3.7 2018-08-28 21:33:40 +09:00
Syoyo Fujita 098dfee982 Merge pull request #92 from walf443/respect_stb_image_write_error
handling stbi_write_xxx_to_func return code
2018-08-28 21:33:07 +09:00
Keiji Yoshimi c0cfc1ed95 handling stbi_write_xxx_to_func return code 2018-08-28 21:13:03 +09:00
Syoyo Fujita be718436c1 Merge pull request #90 from victorbush/force_32bit_tex
Force default image loader to use 32-bit images
2018-08-23 12:51:43 +09:00
Victor Bushong 18ef338ff5 Force default image loader to use 32-bit images for Vulkan compatibility. 2018-08-22 22:03:30 -05:00
Syoyo Fujita 1d0bd6c64f Merge pull request #89 from Selmar/missing_bin_to_error_message
missing bin files are reported as warning instead of error
2018-08-23 02:16:10 +09:00
Selmar Kok e3b3fa9eb6 add required parameter to LoadExternalFile 2018-08-22 19:04:21 +02:00
Selmar Kok cda38e03ed change from warning to error for missing bin files 2018-08-22 18:26:10 +02:00
Syoyo Fujita fcdfc71ba6 Merge pull request #88 from Selmar/forward_declare_dataUri_utils
forward declare DataURI helpers
2018-08-22 21:36:16 +09:00
Selmar Kok 0d0e97e8cd forward declare DataURI helper functions to allow usage outside of implementation file (in case of custom image handling) 2018-08-22 14:01:57 +02:00
Syoyo Fujita dfc3545d79 Fix unit test.
Update README.
2018-08-22 20:35:04 +09:00
Syoyo Fujita 1898f10836 Merge branch 'devel' 2018-08-22 20:30:52 +09:00
Syoyo Fujita 96d2f314cd Merge pull request #86 from mosra/fail-when-bin-missing-from-glb
Properly fail also when external *.bin are missing from *.glb.
2018-08-17 19:52:09 +09:00
Vladimír Vondruš fd84ceb791 Properly fail also when external *.bin are missing from *.glb.
Consistency with behavior for external *.bin files referenced from
*.gltf.
2018-08-16 21:07:56 +02:00
Syoyo Fujita 6d38ca3894 Merge branch 'devel' of github.com:syoyo/tinygltf into devel 2018-08-16 15:57:28 +09:00
Syoyo Fujita a6802d10fb Fix typo(n2.z -> n1.z) 2018-08-16 15:56:13 +09:00
Syoyo Fujita 28dc902368 Add link to px_render. 2018-08-09 01:58:40 +09:00
Syoyo Fujita 7c8d4ed748 Added 'warning' message parameter to glTF loader API.
Asset loading failure messages(e.g. image file is missing) are now stored in `warning` message, not `error` message.
2018-07-27 16:49:10 +09:00
Syoyo Fujita a71be9cc98 Merge pull request #80 from mosra/texture-name
Import texture names as well
2018-07-25 13:51:41 +09:00
Syoyo Fujita 8c29e35b42 Merge pull request #81 from mosra/emscripten-file-paths
Don't try to expand file paths on Emscripten.
2018-07-25 13:51:00 +09:00
Vladimír Vondruš 9f04583280 Don't try to expand file paths on Emscripten.
Since the same is done on all mobile platforms already, I think it
should not do any harm. Without this I was getting compilation/linker
errors.
2018-07-24 23:32:17 +02:00
Vladimír Vondruš 239be2c09f Import texture names as well.
Every other structure has it already.
2018-07-24 23:23:56 +02:00
Syoyo Fujita 39abfb5f91 Consider Data URI buffers in binary. Fixes #79. 2018-07-11 02:46:52 +09:00
Syoyo Fujita 81bbf86e2a Merge pull request #78 from UberLambda/devel
Added filesystem callback support (#77)
2018-07-08 15:17:13 +09:00
Paolo Jovon b2a587af96 Fixed C++11 compliance of previous commit 2018-07-07 21:50:01 +02:00
Paolo Jovon e6601bfb4b Added filesystem callback support
Now a library like PhysFS can be used to load files by defining custom
callbacks and disabling the builtin ones by #define TINYGLTF_NO_FS
2018-07-07 20:43:33 +02:00
Syoyo Fujita 90e2c9cc74 Merge pull request #76 from mynz/devel
parse extras on the root object
2018-06-28 20:25:23 +02:00
mynz c0d4d1c50c parse extras on the root object 2018-06-28 23:06:00 +09:00
Syoyo Fujita 0f282f7e26 Merge pull request #75 from holzon/fix/allextras
Adding missing extras field serializaton
2018-06-04 19:07:49 +09:00
Jens Olsson b3af2f1cf6 adding missing extras field serializaton 2018-06-04 11:56:00 +02:00
Syoyo Fujita 4769b1ca37 Apply clang-format. 2018-06-04 18:40:16 +09:00
Syoyo Fujita 0067a9e43a Support gltf-buffer mime.
Make `min` and `max` parameters in `Accessor` optional.
2018-06-04 18:26:05 +09:00
Syoyo Fujita 57f8e7ca3b Correctly handle filename containing spaces for external resources. Fixes #74. 2018-06-04 17:52:08 +09:00
Syoyo Fujita a48f12d2fc Merge pull request #73 from holzon/fix/extras
Added missing extras serialization for nodes
2018-05-24 23:59:56 +09:00
Jens Olsson a9718668b4 fixing typo 2018-05-24 15:48:49 +02:00
Jens Olsson b96f6966ab added missing extras serialization for nodes 2018-05-24 15:29:54 +02:00
Syoyo Fujita 7c56f8eb9e Merge pull request #69 from benbuzbee/serialization-fixes
Serialization fixes for single-number values and integers
2018-04-26 14:06:18 +09:00
Ben Buzbee f6af224135 Remove use of optional 2018-04-25 15:13:05 -07:00
Ben Buzbee 3b735bb878 Serialization fixes 2018-04-24 11:39:30 -07:00
Syoyo Fujita 2d17a31d3b typedef struct -> struct for enabling forward declarations of struct. 2018-04-17 15:45:42 +09:00
Syoyo Fujita 48f6db0994 Suppress clang warnings. 2018-04-15 18:40:55 +09:00
Syoyo Fujita c89fc5f06b Describe supported VS 2015 update revision. 2018-04-12 11:52:14 +09:00
Syoyo Fujita 1e629c8efe Fix printing accessor.min and accessor.max in loader_example.
Initial support for printing extensions(no pretty printing at the moment).
Merge branch 'generic_extension_support' of https://github.com/Selmar/tinygltf into Selmar-generic_extension_support
2018-04-05 15:37:57 +09:00
Selmar Kok 341fc31aee Merge remote-tracking branch 'origin/devel' into generic_extension_support
# Conflicts:
#	tiny_gltf.h
2018-04-04 18:34:30 +02:00
Syoyo Fujita 7b0bbc6570 Merge branch 'devel' into Selmar-generic_extension_support 2018-04-05 01:27:03 +09:00
Selmar Kok 9eae110946 serialize texture extensions 2018-04-04 18:10:37 +02:00
Selmar Kok fa7022f364 Changed ExtensionMap to use Value instead of ParameterMap 2018-04-04 18:10:20 +02:00
Syoyo Fujita 6c67da478f Merge pull request #62 from bowald/feature/serializer-handle-image-output
small bugfix, serializer skipped texture samplers refering to first index.
2018-04-02 15:24:04 +09:00
johan bowald b97d34cfee bugfix, serializer skipped texture samplers refering to first index. 2018-04-02 07:29:29 +02:00
Syoyo Fujita 142aed7499 Merge pull request #61 from bowald/fix/readme-update
Updated readme
2018-04-02 12:42:49 +09:00
johan bowald ca80a591e0 updated readme: fixed example, fixed dead links to stb_image/stb_image_write 2018-04-01 22:57:07 +02:00
Syoyo Fujita dc4bb86bf1 Suppress clang warnings. 2018-04-02 02:04:24 +09:00
johan bowald ef151a4fed update examples with new defines 2018-04-01 14:08:45 +02:00
johan bowald 0894de77f9 added stb_image_write.h 2018-04-01 13:31:09 +02:00
johan bowald 642a343684 output both embedded and image files, small fix to serializer. 2018-04-01 12:37:18 +02:00
Syoyo Fujita 719d7e4a74 Suppress clang warnings.
Apply clang-format.
2018-03-30 19:26:35 +09:00
Syoyo Fujita 13fd7152ee Merge pull request #59 from bowald/feature/serializer-embed-buffer
Added embed buffers as an option in serializer
2018-03-30 19:17:18 +09:00
johan bowald 30c5347afe added embed buffers as an option in serializer 2018-03-30 11:52:56 +02:00
Syoyo Fujita 841c858bfd Merge pull request #58 from bowald/Bowald-serializer-fixes
Serializer skips null values
2018-03-28 22:09:08 +09:00
Johan Bowald faa2722f45 Serializer skips null values 2018-03-28 14:54:22 +02:00
Syoyo Fujita ae751c4882 Merge pull request #57 from Squareys/patch-1
Add Magnum's TinyGltfImporter plugin to projects
2018-03-28 19:23:39 +09:00
Jonathan Hale 6a04c87807 Add Magnum's TinyGltfImporter plugin to projects 2018-03-28 12:19:42 +02:00
Selmar Kok 5210f1539e Merge remote-tracking branch 'origin/devel' into generic_extension_support 2018-03-26 16:22:18 +02:00
Selmar Kok 35c798ed28 Merge remote-tracking branch 'origin/Selmar-generic_extension_support' into generic_extension_support 2018-03-26 16:20:44 +02:00
Syoyo Fujita 5e379693cb Merge pull request #55 from Ybalrid/pr_add_ogre_gltf_to_readme
Add Ogre_glTF to the list of projects using the lib
2018-03-22 02:09:49 +09:00
Arthur Brainville (Ybalrid) a403cd8736 Add Ogre_glTF to the list of projects using the lib
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-21 18:02:36 +01:00
Syoyo Fujita 246654a15a Code clean-up. Reviewed by @Squareeyes. 2018-03-21 20:32:22 +09:00
Syoyo Fujita ba28ddcc9e Modify error message. 2018-03-21 20:05:11 +09:00
Syoyo Fujita 8e2c24fb92 Refactor ParseImage function.
Returns error when both `bufferView` and `uri` are defined in Image.
2018-03-21 19:54:38 +09:00
Syoyo Fujita ba809ff52f Merge branch 'devel' of github.com:syoyo/tinygltf into devel 2018-03-21 18:52:53 +09:00
Syoyo Fujita d1f8bae89c Print extensions. 2018-03-21 18:48:03 +09:00
Syoyo Fujita 70d8b7a42b Merge pull request #53 from Ybalrid/gltfutil
Gltf utility
2018-03-20 11:01:22 +09:00
Syoyo Fujita 3f1c5a90d3 Merge pull request #54 from Ybalrid/fix_msvc_build_usage
Fix MSVC build: removing static keyowrd befor tinygltf::LoadImageData
2018-03-20 10:36:26 +09:00
Arthur Brainville 2960379eba Can select image file format with -f argument in gltf util
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-19 20:24:00 +01:00
Arthur Brainville 4ba01f5968 Add a "not specified" option to the enum class for image formats
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-19 20:06:59 +01:00
Arthur Brainville cd366ddd1d Fix MSVC build: removing static keyowrd befor tinygltf::LoadImageData
This is peculiar:
It looks like MSVC doesn't want to build when multiple compilation units
(e.g. multiple .cc files) uses tiny_gltf and this funciton is static.

The only one file that will build without error is the one that defined
the `TINYGLTF_IMPLEMENTATION` macro.

Removing `static` here solves the issue...

Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-19 19:54:05 +01:00
Arthur Brainville 68174a3fb3 Fix MSVC build: removing static keyowrd befor tinygltf::LoadImageData
This is peculiar:
It looks like MSVC doesn't want to build when multiple compilation units
(e.g. multiple .cc files) uses tiny_gltf and this funciton is static.

The only one file that will build without error is the one that defined
the `TINYGLTF_IMPLEMENTATION` macro.

Removing `static` here solves the issue...

Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-19 19:40:04 +01:00
Arthur Brainville (Ybalrid) 34c8b60325 Can specify output directory for dumped texture with -o
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-19 17:21:18 +01:00
Arthur Brainville (Ybalrid) 8d8840f809 Added basic texture dumper
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-19 17:11:53 +01:00
Selmar Kok 85b3cbc44d Merge branch 'devel' into generic_extension_support 2018-03-19 16:15:22 +01:00
Arthur Brainville ea2b1c5e5d Start working on a gltf utility program
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-19 15:49:14 +01:00
Syoyo Fujita d5b0244e2c Serialize lights under as KHR_lights_cmn extension. 2018-03-17 16:12:42 -05:00
Syoyo Fujita f1cdd1c4cb Merge pull request #52 from Selmar/opt_out_external_image_loading
Allow opting out of external image loading
2018-03-16 17:26:49 -05:00
Selmar Kok 2a15f387bc Merge branch 'devel' into generic_extension_support
# Conflicts:
#	tiny_gltf.h
2018-03-16 12:32:52 +01:00
Selmar Kok 5b8eb9b429 Merge branch 'devel' into opt_out_external_image_loading 2018-03-16 12:15:13 +01:00
Selmar 67af3c98aa Allow opting out of external image loading
We do not require image loading for external files, we have separate texture directories at the moment.

I've also added saving the image->uri when loading a binary gltf.
2018-03-16 11:48:19 +01:00
Syoyo Fujita 580d7c8b9f Parse defaultScene value correcrly. Fixes #47. 2018-03-15 22:09:01 -05:00
Syoyo Fujita e69069d53c Loading a GLB file without BIN data fails. Fixes #49. 2018-03-15 22:01:18 -05:00
Syoyo Fujita d42767e63f Store relative URI in Buffer serializer. Fixes #48.
Apply clang-format.
Add simple saver sample.
2018-03-15 21:52:00 -05:00
Selmar 7d8cbba8e4 removed code from another issue 2018-03-15 17:32:27 +01:00
Selmar 09d2ff12d8 generic extension support
Two issues remaining:
- The lights data exists twice on export; once outside of the gltf specification and once in the extensions.
- A lot of objects are still missing the extensions property.
2018-03-15 17:30:42 +01:00
Syoyo Fujita 20244e1e4e Fix storing uri to Buffer.uri. Fixes #50.
Fix decoding DataURI with 'data:application/gltf-buffer;base64' mime.
2018-03-15 11:01:05 -05:00
Syoyo Fujita 4f0b893d73 Merge pull request #45 from Squareys/custom-image-loaders
Allow custom image loaders
2018-03-14 10:07:49 +09:00
Squareys 2d3594de22 Allow opting out of STB_IMAGE dependency
Signed-off-by: Squareys <squareys@googlemail.com>
2018-03-13 23:08:03 +01:00
Squareys ff644d82c9 Allow specifying custom image loader callback
Signed-off-by: Squareys <squareys@googlemail.com>
2018-03-13 23:08:03 +01:00
Squareys f99f760b07 Clean up obsolete debug output
Signed-off-by: Squareys <squareys@googlemail.com>
2018-03-13 22:29:31 +01:00
Squareys 4337463c79 Remove trailing whitespaces
Signed-off-by: Squareys <squareys@googlemail.com>
2018-03-13 22:20:48 +01:00
Squareys 188965b11e Fix minor typo
Signed-off-by: Squareys <squareys@googlemail.com>
2018-03-13 22:20:01 +01:00
Syoyo Fujita 179edbf054 Fix empty serialization. Fixes #44. 2018-03-06 12:04:51 +09:00
Syoyo Fujita 1e94d05012 Merge pull request #43 from Ybalrid/devel
raytrace: remove code that ouput the 1st loaded texture as PPM
2018-03-03 02:15:44 +09:00
Arthur Brainville 92000ddeed raytrace: remove code that ouput the 1st loaded texture as PPM
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-02 16:58:30 +01:00
Syoyo Fujita abf4bd1800 Merge pull request #42 from Ybalrid/pr_raytrace_texture_loading
raytrace: add simple code that load texture data
2018-03-03 00:55:58 +09:00
Syoyo Fujita c14616d21c Merge pull request #41 from Ybalrid/pr_upgrade_imgui_imguizmo_raytrace
Upgraded dear imgui and ImGuizmo to the latest version
2018-03-03 00:43:18 +09:00
Arthur Brainville e832baf229 Restored previous behavior when moving node in scene
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-02 16:21:28 +01:00
Arthur Brainville df9003ea08 Update scene when moving gizmo
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-02 16:10:20 +01:00
Arthur Brainville ab156c7d18 Upgraded dear imgui and ImGuizmo to the latest version
The Gizmo feels a little bit nicer to use in the latest version

Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-02 15:49:01 +01:00
Arthur Brainville dd45c56927 raytrace: add simple code that load texture data
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-02 13:57:37 +01:00
Syoyo Fujita 0b01361d15 Fix return location. 2018-02-28 19:59:32 +09:00
Syoyo Fujita 493cad4e64 Merge pull request #40 from Ybalrid/pr_raytrace_example
Pr raytrace example
2018-02-28 00:04:07 +09:00
Arthur Brainville c227c5bddb Fixed triangle fan indices
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-27 12:47:06 +01:00
Arthur Brainville (Ybalrid) de8e3a6e6b Enforece some const correctness. Add comments.
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-25 01:23:04 +01:00
Arthur Brainville (Ybalrid) a5a03a2d44 Reorder UVs in vacevaying order
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-25 01:14:57 +01:00
Arthur Brainville (Ybalrid) 6cf0228fa7 Handle all types of triangle-based vertex buffer.
Some small codepath changes too.

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-25 00:52:50 +01:00
Arthur Brainville (Ybalrid) 1cd3b0f756 Fix pesudo -> pseudo typo
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-25 00:42:35 +01:00
Arthur Brainville (Ybalrid) 0e0a884378 Check the type of vectors before checking the type of their component
This order makes more sense.

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-24 22:09:17 +01:00
Arthur Brainville (Ybalrid) 8eb0fbb3d4 Fix the loading of normals by putting them into facevarying order
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-24 21:52:53 +01:00
Arthur Brainville (Ybalrid) 0da2b35085 Fixes problem when mesh in glTF file doesn't have a name
a "unnamed_X" name will be genrated.

This fixes the loading of Trinagle.gltf from khronos

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-23 15:15:33 +01:00
Arthur Brainville (Ybalrid) 55bff342c2 Merge branch 'pr_raytrace_example' of github.com:Ybalrid/tinygltf into pr_raytrace_example 2018-02-23 14:26:55 +01:00
Arthur Brainville (Ybalrid) 37ba0ae481 Log the types of data used by the currently loaded GLTF file
This will help test and improve compatibilitiy.

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-23 14:23:30 +01:00
Arthur Brainville (Ybalrid) 27ae4ba9c1 load texture coordinates
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:24 +01:00
Arthur Brainville 07e6c5c109 Small code cleanup
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:23 +01:00
Arthur Brainville 0b4f54162b Switch to unsigned int for the int arrays. Fix compatibility issue
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:23 +01:00
Arthur Brainville db1e8b3e8b added loading of doubles for position
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:23 +01:00
Arthur Brainville 2b211221c8 Add double type vector. Remove by default byte_stride value
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:22 +01:00
Arthur Brainville (Ybalrid) 72f535e198 Move defined types (array adapter templates) to the header
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:22 +01:00
Arthur Brainville (Ybalrid) 02fce26c6c Use default material as the 1st material on the array
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:22 +01:00
Arthur Brainville (Ybalrid) 7218e40bfd Fix pivot. Hack material to prevent crash
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:22 +01:00
Arthur Brainville (Ybalrid) 2b10d88e42 Load inside the scene graph the gltf mesh (like the obj)
pivot is still invalid

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:21 +01:00
Arthur Brainville aad6f06208 Fix linux build in C++11 strict
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:21 +01:00
Arthur Brainville b62e95f414 Load the normal vectors of the primitive
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:21 +01:00
Arthur Brainville ffc79a719b Also access the position attribute of the primitive
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:20 +01:00
Arthur Brainville (Ybalrid) ce75870894 Now load index buffer
Added some template infrastructure to read arrays where type is defined by a value.

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:20 +01:00
Arthur Brainville (Ybalrid) 49721f0fd4 Add the entry point for loading gltf files.
Also switch on the primitive mode of each mesh. Will only attempt to
load lists of triangles for now...

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:20 +01:00
Arthur Brainville (Ybalrid) 62da4688af Only attempt to load the obj file if the obj_filename is defined in json
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:20 +01:00
Arthur Brainville (Ybalrid) 365e56b779 Small adjustment to the NanoSG readme
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:19 +01:00
Arthur Brainville (Ybalrid) 1baa211450 Add files to .gitignore
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:19 +01:00
Arthur Brainville 01bf27443e Fix where stb image is actually implemented
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:18 +01:00
Arthur Brainville (Ybalrid) 7e91e9bb9f Setup CI for raytrace example
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:18 +01:00
Arthur Brainville (Ybalrid) 67f5fbd79e Add a gltf_filename feild to the renderconfig struct
This is to get the filename that will be given to the gltf-loader

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:18 +01:00
Arthur Brainville (Ybalrid) a6cbf3d35b Applyind clang-format on main.cc. Included gltf-loader
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:17 +01:00
Arthur Brainville (Ybalrid) 3903446bfc Move the implementation of stbi to it's own .cc file
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:17 +01:00
Arthur Brainville (Ybalrid) 8066a54415 Build the tinygltf loader code
Also remove the implementation of STB-Image from obj-loader.cc

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:17 +01:00
Arthur Brainville (Ybalrid) 3d63a08ce2 Make this code buildable as is
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:16 +01:00
Arthur Brainville (Ybalrid) d868aff1d1 Add the current code of nanort + nanosg
This implementation will be based on commit
b31dc0bd92eb7ac896079849a2205fac4abbd087 from the nanort project

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:16 +01:00
Arthur Brainville (Ybalrid) 6233b2e6bb Remove old nanort/nanosg code. Keep the gltf-loader class on hand
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-22 21:50:15 +01:00
Syoyo Fujita b09d660c38 Update premake script for glview example. Fixes #39. 2018-02-23 01:14:13 +09:00
Arthur Brainville (Ybalrid) 0dca478817 load texture coordinates
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-21 10:02:04 +01:00
Arthur Brainville b7bf01c679 Switch to unsigned int for the int arrays. Fix compatibility issue
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 21:47:22 +01:00
Arthur Brainville dc07a50ab7 added loading of doubles for position
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 21:43:07 +01:00
Arthur Brainville 6edd3a7f60 Add double type vector. Remove by default byte_stride value
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 21:40:55 +01:00
Arthur Brainville (Ybalrid) fac0ad9243 Move defined types (array adapter templates) to the header
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 15:55:23 +01:00
Arthur Brainville (Ybalrid) 58baa51463 Use default material as the 1st material on the array
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:57 +01:00
Arthur Brainville (Ybalrid) d095ef53c4 Fix pivot. Hack material to prevent crash
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:57 +01:00
Arthur Brainville (Ybalrid) 9993a71410 Load inside the scene graph the gltf mesh (like the obj)
pivot is still invalid

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:57 +01:00
Arthur Brainville e64e6d2d2a Fix linux build in C++11 strict
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:56 +01:00
Arthur Brainville db5b272a1b Load the normal vectors of the primitive
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:56 +01:00
Arthur Brainville 5682cb4542 Also access the position attribute of the primitive
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:56 +01:00
Arthur Brainville (Ybalrid) 7c54677acd Now load index buffer
Added some template infrastructure to read arrays where type is defined by a value.

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:56 +01:00
Arthur Brainville (Ybalrid) b8040e2a19 Add the entry point for loading gltf files.
Also switch on the primitive mode of each mesh. Will only attempt to
load lists of triangles for now...

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:56 +01:00
Arthur Brainville (Ybalrid) e42ba4e404 Only attempt to load the obj file if the obj_filename is defined in json
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:56 +01:00
Arthur Brainville (Ybalrid) cc4fd4be8e Small adjustment to the NanoSG readme
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:37 +01:00
Arthur Brainville (Ybalrid) f4fbee1cdf Add files to .gitignore
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:42:11 +01:00
Arthur Brainville 088aa0210f Fix where stb image is actually implemented
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:40:50 +01:00
Arthur Brainville (Ybalrid) 1340e62848 Setup CI for raytrace example
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-20 14:40:33 +01:00
Syoyo Fujita d800c88d09 Merge branch 'devel' of github.com:syoyo/tinygltf into devel 2018-02-19 19:28:17 +09:00
Syoyo Fujita ca8cfee824 Add link to Vulkan-glTF-PBR. 2018-02-19 18:05:47 +09:00
Arthur Brainville (Ybalrid) c9ec1ea7b6 Add a gltf_filename feild to the renderconfig struct
This is to get the filename that will be given to the gltf-loader

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-18 21:01:59 +01:00
Arthur Brainville (Ybalrid) adfe936dd3 Applyind clang-format on main.cc. Included gltf-loader
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-18 20:24:57 +01:00
Arthur Brainville (Ybalrid) e1e868a704 Move the implementation of stbi to it's own .cc file
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-18 20:09:24 +01:00
Arthur Brainville (Ybalrid) 75af411fda Build the tinygltf loader code
Also remove the implementation of STB-Image from obj-loader.cc

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-18 19:55:02 +01:00
Arthur Brainville (Ybalrid) 90ff6f7ce9 Make this code buildable as is
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-18 19:21:38 +01:00
Arthur Brainville (Ybalrid) c81be8f87d Add the current code of nanort + nanosg
This implementation will be based on commit
b31dc0bd92eb7ac896079849a2205fac4abbd087 from the nanort project

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-18 19:16:16 +01:00
Arthur Brainville (Ybalrid) fb7ebb955e Remove old nanort/nanosg code. Keep the gltf-loader class on hand
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-18 19:13:57 +01:00
Syoyo Fujita c7ae1a3e76 Merge pull request #38 from o-micron/patch-2
Fix LoadImageData return value when error occurs
2018-02-10 16:53:00 +09:00
Omar C. F d492efc38a Fix return value when error occurs 2018-02-10 09:50:35 +02:00
Syoyo Fujita 568f05fec9 Merge pull request #37 from o-micron/patch-1
Add missing bmp and gif mimetypes
2018-02-10 16:11:35 +09:00
Omar C. F f8a8d9caa0 Add missing bmp and gif mimetypes 2018-02-10 09:09:41 +02:00
Syoyo Fujita 0d9a495fd1 Merge pull request #36 from Ybalrid/devel_add_gitignore
Add gitignore file
2018-02-02 00:57:32 +09:00
Arthur Brainville (Ybalrid) a62e955a52 Add gitignore file
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-02-01 15:38:34 +01:00
Syoyo Fujita 89cd83e22f Merge branch 'devel' of github.com:syoyo/tinygltf into devel 2018-01-21 12:20:00 +09:00
Syoyo Fujita 476a8b21b0 Set GL_DOUBLE value from OpenGL spec. Fixes #35. 2018-01-21 12:19:01 +09:00
Syoyo Fujita 05e0bf1cdc Suppress clang warnigns.
Refactor code to use C++11 features.
2018-01-16 18:55:13 +09:00
Syoyo Fujita f2aba36638 Add more note on Visual Studio version. 2018-01-11 14:06:10 +09:00
Syoyo Fujita 688236a3a8 Merge pull request #34 from Ybalrid/patch-1
Add language tags on code snippets in README
2018-01-10 20:52:24 +09:00
Arthur Brainville d93364e63f Add language tag on code snippets in README 2018-01-10 12:04:51 +01:00
Syoyo Fujita e3a7aef197 Describe note on Visual Studio version. 2018-01-10 18:32:51 +09:00
Syoyo Fujita 85ed1ac824 Merge pull request #33 from Ybalrid/CI_fix
Attempt to fix continuous integration (fix #31)
2018-01-10 18:30:45 +09:00
Arthur Brainville (Ybalrid) 760c1a5065 Change VS version to one that is better compatible with C++11
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-01-10 09:09:21 +01:00
Syoyo Fujita f0606e83d3 Merge pull request #32 from Ybalrid/narrowingConversionWarning
Silence a MSVC warning about narrowing conversion
2018-01-10 12:20:28 +09:00
Arthur Brainville 8ce4e54394 Silence a MSVC warning about narrowing conversion
We actually want to convert a size_t value into an int value in this
return statement.

Fix the annoying MSVC warning by actually casting the bytestride to an
int

Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-01-10 01:27:12 +01:00
Syoyo Fujita 45c29dc54d Update README of gltf-validator. 2018-01-09 14:28:16 +09:00
Syoyo Fujita 1b482fe0be Merge pull request #30 from Ybalrid/simplerMaterial
Simpler material data retreival
2018-01-09 12:19:03 +09:00
Arthur Brainville 9585391311 rename Color to ColorFactor
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-01-08 18:37:44 +01:00
Arthur Brainville 41fe772058 Const qualify const methods
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-01-08 18:32:48 +01:00
Arthur Brainville 5845319b1a Add little utility methods to access the content of a Parameter object
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-01-08 18:25:52 +01:00
Syoyo Fujita 1ebd29d84e Remove unnecessary text. 2018-01-05 20:21:27 +09:00
Syoyo Fujita f5318cc759 Describe more about C++ exception. 2018-01-05 20:17:37 +09:00
Syoyo Fujita 17cfbcc976 Fix argument to catch claus was wrong.
Add support to compile TinyGLTF with no C++ exception(TINYGLTF_NOEXCEPTION). Fixes #18.
Add initial unit tests.
2018-01-05 20:14:46 +09:00
Syoyo Fujita 584f8c0ddf Add method for computing byteStride to Accessor struct.
This would fix issue #29.
2018-01-03 17:47:08 +09:00
Syoyo Fujita 3ab8ee1f87 Add name of Adrien and many contributrors. 2017-12-31 18:36:02 +09:00
Syoyo Fujita daa726ec7c Merge pull request #28 from Ybalrid/devel
Create LICENSE file according to the terms of the MIT License agreement
2017-12-31 15:02:01 +09:00
Arthur Brainville 5194b47a16 Create LICENSE
This library is an awesome project, and I can imagine a lot of 3D application written in C++ would happily use it to load glTF assets ;-)

However, the license wasn't properly stated on the project. To actually put work under the term of the MIT license agreement, a copyright notice **needs** to be distributed alongside the source code.

It is also standard practice to add a warranty disclaimer. This prevent people to hold you liable if (at least they think) something doesn't work because of this library.

I took the liberty to put the file in place, with your full name as stated on your GitHub profile as the copyright holder. This is the text that states that you, the author, grants the to other people to use this as a free/open-source software, with all the thing that comes with it (access to source code, right to modify, redistribute, redistribute modified version, and use for any purpose they like) 

Sorry for the annoyance ^^"
2017-12-31 04:07:06 +00:00
Syoyo Fujita b66d68f3fb Report error message. 2017-12-19 18:45:22 +09:00
Syoyo Fujita 85591954ab Update README. 2017-12-19 18:29:34 +09:00
Syoyo Fujita dac2a89b63 Fix wrong return value(Fixes #26) 2017-12-19 17:58:32 +09:00
Syoyo Fujita 660256062b Update premake5.exe binary(5.0.0 alpha12). 2017-12-10 00:44:29 +09:00
Syoyo Fujita 87a76e1679 Merge branch 'patch-1' of https://github.com/cemdervis/tinygltf into cemdervis-patch-1 2017-12-10 00:39:52 +09:00
Syoyo Fujita 6bdd54f709 Rename premake config script. 2017-12-08 19:45:33 +09:00
Cemalettin Dervis f889d2b0dc Fixed typo ("RPEAT") 2017-12-07 21:58:15 +01:00
Cemalettin Dervis 246d866961 Fixed typo ("RPEAT") 2017-12-07 20:29:51 +01:00
Syoyo Fujita 06096520b8 Update README. 2017-12-03 17:26:25 +09:00
Syoyo Fujita aec35f10c0 Update README. 2017-12-03 17:19:55 +09:00
Syoyo Fujita 802b4df991 Merge branch 'validator' into jsoncpp 2017-12-03 17:17:03 +09:00
Syoyo Fujita 738a13ebf4 Use C++11 in Travis build and appveyor build. 2017-12-02 21:22:58 +09:00
Syoyo Fujita 7ce4a42fc3 Fix compilation. 2017-12-02 21:21:06 +09:00
Syoyo Fujita 0501a46612 Use C++11 flag. 2017-12-02 21:18:59 +09:00
Syoyo Fujita 836753132b Merge branch 'devel' into jsoncpp 2017-12-02 21:14:13 +09:00
Syoyo Fujita a415cf477c Add workaround for parsing glTF schemas 2017-11-25 19:55:28 +09:00
Syoyo Fujita e59de221ff Add json-schema-validator code. 2017-11-25 18:32:56 +09:00
Syoyo Fujita cd1ddf341d Describe supported platforms in README.
Better isnan/isinf availabity test(I guess).
2017-11-15 13:55:14 +09:00
Syoyo Fujita b23f6fe492 Fix compile on iOS. Fixes #24. 2017-11-15 01:03:09 +09:00
Syoyo Fujita 1657cf6a1d Merge pull request #23 from e-schrade/devel
Parse KHR_Lights_cmn extension
2017-11-08 01:56:08 +09:00
Emanuel Schrade 186322bed6 Parse KHR_Lights_cmn extension 2017-11-06 11:14:49 +01:00
Syoyo Fujita ef2f49ff19 User lowercase for Windows.h. Fixes #22. 2017-11-05 17:18:46 +09:00
Syoyo Fujita 2e21be7e19 Use json.hpp instead of picojson(W.I.P.) 2017-11-05 17:13:24 +09:00
Syoyo Fujita 57c1018f89 Improve error message. 2017-10-19 18:48:26 +09:00
Syoyo Fujita dfe8c70d9a Merge pull request #21 from thestr4ng3r/devel
Disable wordexp for Android
2017-09-23 00:07:20 +09:00
Florian Märkl d525e19582 Disable wordexp for Android 2017-09-22 15:25:48 +02:00
Syoyo Fujita 1aba9cf663 Merge pull request #20 from jianghaosen/devel
fix(row1728): accessor->normalize is a local variables and forget ini…
2017-08-29 22:29:57 +09:00
jianghaosen 4748ad61c0 fix(row1728): accessor->normalize is a local variables and forget initial it. Beside, the value of p
accessor->normalize is a local variables and forget initial it, it may be true or false. Beside, the
value of parse glTF do not assign to normalize.
2017-08-29 20:08:37 +08:00
Syoyo Fujita 1065728429 Remove installing cpp-coverage tool 2017-08-26 17:05:05 +09:00
Syoyo Fujita dadcfa5306 Merge pull request #19 from jianghaosen/devel
fix(row926): a bug that filename is empty when parse glb
2017-08-26 17:03:58 +09:00
jianghaosen b721fb76c6 fix(row926): a bug that filename is empty when parse glb
when parse glb, filename maybe a empty value, it will be wrong
2017-08-25 21:01:17 +08:00
Syoyo Fujita 59130d1a19 Check if JSON element is valid JSON object or not. Now all fuzz input passes. Fixes #16. 2017-08-01 20:23:11 +09:00
Syoyo Fujita cdf849061c Wrap picojson::parse with exception clause to catch JSON parsing error. 2017-08-01 20:12:08 +09:00
Syoyo Fujita 2b0307f397 Hardened parsing and solved some issue found by fuzzer(issue 16). 2017-08-01 18:15:52 +09:00
Syoyo Fujita 9c0c665eb4 Fix config setting. 2017-07-23 19:21:04 +09:00
Syoyo Fujita cd5c5f0ea0 Add codes for raytrace example(W.I.P.) 2017-07-23 19:11:39 +09:00
Syoyo Fujita c0beef73a1 Update travis badge URL. 2017-07-14 01:15:34 +09:00
Syoyo Fujita 259c9b2802 Update README. 2017-07-13 18:23:29 +09:00
Syoyo Fujita 7b6edab3a9 Initial support of parsing/serializing Camera. 2017-07-13 18:20:14 +09:00
Syoyo Fujita 06402256c7 Remove binary extension since glTF 2.0 supports binary format in native manner. 2017-07-13 01:28:55 +09:00
Syoyo Fujita d9d012a5df Accessor.min and Accessor.max are now optional parameter.
Set BufferView.byteStride default value to 0(= tightly packed). Fixes #13.
2017-07-12 18:29:29 +09:00
Syoyo Fujita 965071b309 Merge pull request #12 from Teybeo/devel
Update Readme.md
2017-07-12 15:28:18 +09:00
Teybeo 9ec8137dd0 Update Readme.md 2017-07-09 20:45:28 +02:00
Syoyo Fujita 168d0595ef Remove Accessor.byteStride. 2017-07-03 00:56:16 +09:00
Syoyo Fujita 822788921e Delete Accessor.byteStride field which was removed in glTF 2.0 spec. 2017-06-26 17:54:34 +09:00
Syoyo Fujita a12620f378 Fix bufferView.byteStride is read into byteLength property. Fixes #9 2017-06-24 20:57:05 +09:00
Syoyo Fujita 06a2be8d9d Merge branch 'devel' of github.com:syoyo/tinygltf into devel 2017-06-23 00:26:14 +09:00
Syoyo Fujita 4df5f94eb7 Fix appveyor script. 2017-06-23 00:24:24 +09:00
Syoyo Fujita 72d5af4d9e Merge pull request #8 from soma-arc/fix-naming
Fix file/define/class name referenced in glview
2017-06-23 00:23:54 +09:00
soma_arc 74a94f5068 Fix file/define/class name referenced in glview 2017-06-22 13:34:53 +09:00
Syoyo Fujita 5307850555 Update README. 2017-06-21 19:27:18 +09:00
Syoyo Fujita 2840a0eb48 Rename filename/define/class name. 2017-06-21 02:52:11 +09:00
Syoyo Fujita 73cd7b9c1d Fix build on Visual Studio. 2017-06-20 03:02:57 +09:00
Syoyo Fujita 9a1ea7e300 Merge branch 'feature/serialize-gltf' of https://github.com/sketchfab/tinygltf into sketchfab-feature/serialize-gltf 2017-06-20 02:17:28 +09:00
Aurélien Chatelain cc8ba99179 Adds serialization functions 2017-06-19 14:32:27 +00:00
Aurélien Chatelain 756ee6ba4d Adds extensionsRequired object 2017-06-19 14:32:27 +00:00
Aurélien Chatelain 8d5e0a75e8 Fixes typos and useless data 2017-06-19 14:32:27 +00:00
Aurélien Chatelain 2682c6fb4b Fixes morph targets parsing 2017-06-19 14:32:24 +00:00
Syoyo Fujita 168da25539 Update build script. 2017-06-05 01:58:26 +09:00
Syoyo Fujita 5b40745f7a Remove unused examples.
Refactor source code.
2017-06-04 17:42:41 +09:00
Syoyo Fujita 4ebd5a9f82 Merge pull request #2 from sketchfab/devel
Devel
2017-05-31 00:17:45 +09:00
Syoyo Fujita 2fb2f92997 Merge pull request #3 from syoyo/revert-1-feature/update-tinygltf-20
Revert "Feature/update tinygltf 20"
2017-05-31 00:17:29 +09:00
Syoyo Fujita 08c9d25629 Revert "Feature/update tinygltf 20" 2017-05-31 00:16:45 +09:00
Syoyo Fujita 80249464ae Merge pull request #1 from sketchfab/feature/update-tinygltf-20
Feature/update tinygltf 20
2017-05-31 00:16:15 +09:00
Aurélien Chatelain 6d3bfd7e1b Fix image parsing (2.0) 2017-05-30 15:04:35 +00:00
Aurélien Chatelain 0aab1575d5 Update buffer parsing (2.0) 2017-05-30 15:03:57 +00:00
Syoyo Fujita 40c4a0a60a Update binary glTF header check(Reading binary glTF is still in progress) 2017-05-30 01:21:36 +09:00
Syoyo Fujita d7ec19c3dc Fix Animation dumper. 2017-05-30 00:52:00 +09:00
Syoyo Fujita 90e1ed21bc byteOffset in Accessor and BufferViews are optional; 2017-05-30 00:47:37 +09:00
Syoyo Fujita d17ff66b3d BufferView.byteOffset is optional(default = 0). 2017-05-29 02:53:12 +09:00
Syoyo Fujita d941f6d1eb Update test runner. 2017-05-29 02:20:05 +09:00
Syoyo Fujita e01fc67380 Merge branch 'devel' of github.com:syoyo/tinygltf into devel 2017-05-28 01:21:32 +09:00
Syoyo Fujita e4ef6c070c Upadate README. 2017-05-28 01:20:59 +09:00
Syoyo Fujita b7f71e6786 Upadate README. 2017-05-28 01:20:05 +09:00
Syoyo Fujita 2d8edf5c8b Merge branch 'sketchfab-feature/update-tinygltf-20' into devel 2017-05-27 23:57:04 +09:00
Syoyo Fujita 1866e11237 Add Cube test model. 2017-05-27 23:55:32 +09:00
Syoyo Fujita f612015ac2 Keep up with loader_example.cc
Update picojson.h
2017-05-27 23:51:23 +09:00
Syoyo Fujita 2057b1ae6e Merge branch 'feature/update-tinygltf-20' of https://github.com/sketchfab/tinygltf into sketchfab-feature/update-tinygltf-20 2017-05-26 02:16:49 +09:00
Syoyo Fujita c8d3c76bb1 Sync with tinygltfloader 2017-05-25 01:42:38 +09:00
Aurélien Chatelain 38a6a7565c Supports glTF morph (glTF 2.0, not tested) 2017-05-24 13:48:10 +00:00
Aurélien Chatelain 8cb98950ff Supports glTF skinning (glTF 2.0) 2017-05-24 13:48:10 +00:00
Aurélien Chatelain 5cb4346a32 Adds workaround for unsupported images 2017-05-24 13:48:10 +00:00
Aurélien Chatelain d48bbdcd90 Updates asset object (glTF 2.0) 2017-05-24 13:48:10 +00:00
Aurélien Chatelain ab7b218385 Updates materials (glTF 2.0)
glTF 2.0 has now PBR materials.
Core material is Metallic/Roughness material
Specular/glossiness is still in an extension

Material properties can be number arrays (colors/factors) or JSON objects (textures)
2017-05-24 13:48:10 +00:00
Aurélien Chatelain a25e495fd9 Updates camera object (glTF 2.0) 2017-05-24 13:48:10 +00:00
Aurélien Chatelain ee4693e3a1 Supports glTF 2.0 schema
- Renaming 'Scene' to 'Model' to avoid confusion
- glTF top objects are now arrays, and objects are referenced by index instead of id
- added a few comments (required)
- default values
2017-05-24 13:48:10 +00:00
Aurélien Chatelain f4f4ae4d89 Removes Technique/Shader/Program support (glTF 2.0) 2017-05-24 13:47:58 +00:00
Syoyo Fujita 36289fb59f Merge pull request #15 from missmah/master
Possible fix for child values not being properly deserialized
2017-05-08 15:16:44 +09:00
Layla 1dbfe0ee13 Possible fix for child values not being properly deserialized.
* Add the child_value parsed by ParseObjectProperty to the return value

The omission of adding child_value to the return object appears to have been an oversight, as it is the only case where the parsed value is not added, and because child_value is otherwise unreferenced.

This change also does give us the value that we are expecting in our use case after loading our glTF.

Was this an oversight or an intentional omission?
2017-05-07 16:56:55 -04:00
Syoyo Fujita 6158f3489e Update README. 2016-11-25 01:26:21 +09:00
Syoyo Fujita 036166d121 Do not emit empty Curves primitive. 2016-11-25 01:22:02 +09:00
Syoyo Fujita bb3884e04e Update README. 2016-11-24 18:28:49 +09:00
Syoyo Fujita 87dc2753da Merge branch 'master' of github.com:syoyo/tinygltfloader 2016-11-24 18:21:18 +09:00
Syoyo Fujita 6df009e737 Update README. 2016-11-24 17:56:56 +09:00
Syoyo Fujita b083093db4 Show geomeric normal for mesh object. 2016-11-24 17:55:20 +09:00
Syoyo Fujita 025c880879 Fix nodes emission. 2016-11-24 17:42:18 +09:00
Syoyo Fujita 6239faff48 Fix draw length for GL_LINES. 2016-11-24 17:41:44 +09:00
Syoyo Fujita af4109e6e3 Update glTF sample model repo path. 2016-11-24 16:20:57 +09:00
Syoyo Fujita 4be2f888f7 Fix memory leak of stb_image data. 2016-11-24 16:20:34 +09:00
Syoyo Fujita 15eb9bdf67 Initial support of node hierarchy. 2016-11-24 03:10:02 +09:00
Syoyo Fujita dfb87ab0b9 Fix nodes generation. 2016-11-24 03:09:43 +09:00
Syoyo Fujita b15a26e357 Fix mouse button state management. 2016-11-23 21:41:53 +09:00
Syoyo Fujita cb0f560fbd Compute geometric normal. 2016-11-23 21:40:57 +09:00
Syoyo Fujita dfab1f7c5d Emit "name" for each "mesh" object. 2016-11-23 18:27:19 +09:00
Syoyo Fujita 8598af65b0 Rename function. 2016-11-23 18:26:49 +09:00
Syoyo Fujita 67fa87c18d Comented debug printf. 2016-11-23 18:22:04 +09:00
Syoyo Fujita b21b24e072 Initial support of node hierarchy. 2016-11-23 17:59:17 +09:00
Syoyo Fujita 9e2f479270 Improve UI for one-button mouse. 2016-11-23 17:45:35 +09:00
Syoyo Fujita 7aa09d1c1d Fix gltf semantic. 2016-11-23 02:13:55 +09:00
Syoyo Fujita 814b3fce56 Fix gltf gen(WIP). 2016-11-23 01:42:51 +09:00
Syoyo Fujita 8ffc4e400d Refactor scene graph(WIP). 2016-11-22 20:14:42 +09:00
Syoyo Fujita 29d4dc5247 Start to add node hierarchy support(W.I.P.) 2016-11-22 17:54:47 +09:00
Syoyo Fujita 3890ae276a Refactor class. 2016-11-21 19:29:04 +09:00
Syoyo Fujita 5442071f99 Update README. 2016-10-25 01:48:44 +09:00
Syoyo Fujita de004dfe0d Newline 2016-10-25 01:45:10 +09:00
Syoyo Fujita f847e74d4d Add screenshot of cyhair. 2016-10-25 01:44:19 +09:00
Syoyo Fujita 3b17371648 Add cyhair2gltf converter. 2016-10-25 01:30:40 +09:00
Syoyo Fujita 72f3f77840 Update doc. 2016-10-18 21:16:34 +09:00
Syoyo Fujita ebce2521b2 Initial GL rendering support of curves primitive(render as GL_LINES). 2016-10-18 20:39:33 +09:00
Syoyo Fujita 8038965d33 Fix typo(extra -> extras)
Add some curves support to glview.
2016-10-17 20:00:19 +09:00
Syoyo Fujita a5e63705a3 Remove GL_TRINANGLES restriction for mode in primitive parameter. 2016-10-17 18:05:42 +09:00
Syoyo Fujita 7680abf54d Remove inttypes dependency in TinyGLTFLoader header definition. 2016-10-17 18:02:45 +09:00
Syoyo Fujita f3447a236b Fix build on some compilers. 2016-10-17 13:18:08 +09:00
Syoyo Fujita f696c6f188 Initial support of "extras" property.
Change license from BSD to MIT.
2016-10-17 03:48:55 +09:00
Syoyo Fujita 1db9a358a7 Initial support of converting Alembic curve to .gltf. 2016-10-15 20:12:23 +09:00
Syoyo Fujita c39d93879a Merge branch 'master' of github.com:syoyo/tinygltfloader 2016-10-14 19:00:58 +09:00
Syoyo Fujita e08ef2fbd5 Initial working abc2gltf converter. 2016-10-14 18:50:33 +09:00
Syoyo Fujita 0614eb8fa6 Improve error messsage a bit. 2016-10-14 18:50:14 +09:00
Syoyo Fujita f91a3b7f0e Initial abc -> gltf converter. 2016-10-13 16:48:53 +09:00
Syoyo Fujita 8d6fc9ece6 W.I.P. alembic to gltf converter. 2016-10-11 01:41:08 +09:00
Syoyo Fujita 0976b09d4f Merge pull request #12 from r-lyeh/master
Fix .glb loading (Windows)
2016-08-30 14:45:43 +09:00
r-lyeh 66c1063995 Fix .glb loading (Windows)
Fixes loading of https://github.com/KhronosGroup/glTF/blob/master/sampleModels/Duck/glTF-Binary/Duck.glb
2016-08-29 16:56:18 +02:00
Syoyo Fujita d112d0969d Merge pull request #11 from lukesanantonio/texture-wrap-fix
Use correct value for TEXTURE_WRAP_MIRRORED_REPEAT
2016-08-20 15:20:09 +09:00
Luke San Antonio Bialecki 904612cd23 Use correct value for TEXTURE_WRAP_MIRRORED_REPEAT 2016-08-19 17:28:03 -04:00
Syoyo Fujita fcaacde94c Pretty print output JSON. 2016-07-20 20:00:34 +09:00
Syoyo Fujita 5d8c5c832b Merge pull request #10 from lukesanantonio/feature-conditional-section-checking
Support conditional checking of glTF sections
2016-06-24 12:44:47 +09:00
Syoyo Fujita 90f6ccb55b Merge pull request #9 from lukesanantonio/feature-texture-formats
Add macros for more texture formats
2016-06-24 12:44:35 +09:00
Syoyo Fujita b209c29d39 Merge pull request #8 from lukesanantonio/fix-empty-file-segfault
Prevent a segfault when loading an empty file
2016-06-24 12:44:11 +09:00
Luke San Antonio 9e36b61ed5 Support conditional checking of glTF sections 2016-06-23 15:16:21 -04:00
Luke San Antonio b310b4a32e Prevent a segfault when loading an empty file
If the size of the file is zero, we just signal an error and return false.
2016-06-23 15:15:07 -04:00
Luke San Antonio 6d616f5f06 Add macros for more texture formats 2016-06-23 14:33:54 -04:00
Syoyo Fujita cf6e07b1ec Suppress clang compiler warnings. 2016-06-21 21:18:12 +09:00
Syoyo Fujita c261563b0b Parse sampler 2016-06-19 21:56:06 +09:00
Syoyo Fujita 10c55cc3b5 Update TODO 2016-06-19 18:19:09 +09:00
Syoyo Fujita 8c5ab0344f Initial support of animation. 2016-06-19 18:16:10 +09:00
Syoyo Fujita 330f6da818 Small fix on README. 2016-06-17 00:36:45 +09:00
Syoyo Fujita 5bab26d37e Merge pull request #7 from lukesanantonio/master
Print shaders, programs, and techniques in loader_example.cc
2016-06-16 13:41:37 +09:00
Luke San Antonio 5415f413b8 Print shaders, programs, and techniques in loader_example.cc
This changes the way parameters for materials and techniques are
printed. Now only one of either the number array or string value will be
printed. Before, both would be printed with the same name being used.
2016-06-15 14:11:55 -04:00
Syoyo Fujita 3cdfb3bd07 Support loading binary shader source data for binary glTF. 2016-06-15 20:58:42 +09:00
Syoyo Fujita 4904852e4e Merge branch 'master' of github.com:syoyo/tinygltfloader 2016-06-15 20:44:19 +09:00
Syoyo Fujita 36c718386c Update README.
Fix exec name in test_runner.py
2016-06-15 15:48:18 +09:00
Syoyo Fujita 92cb3d9c4d Merge pull request #5 from lukesanantonio/feature_technique
Support shaders, programs, and techniques
2016-06-15 15:35:07 +09:00
Syoyo Fujita 7b91552bb1 Merge pull request #6 from lukesanantonio/master
Only use valid (triangle) primitive sets
2016-06-15 15:33:13 +09:00
Luke San Antonio caa24b0513 Support plain text data URIs 2016-06-15 02:23:09 -04:00
Luke San Antonio 10a3e1da81 Only use valid (triangle) primitive sets
ParsePrimitive returns false immediately on error but the return value
wasn't being checked in ParseMesh so invalid / uninitialized primitives
were being added to the mesh.
2016-06-15 02:15:23 -04:00
Luke San Antonio da8b5d148c Add newline to error messages in LoadExternalFile 2016-06-14 22:52:06 -04:00
Luke San Antonio cdf4cb79ed Add support for shaders, programs, and techniques 2016-06-14 22:51:53 -04:00
Luke San Antonio 19894c7806 Add function to parse string dictionaries
A string dictionary in the glTF spec is called a "dictionary object of
strings." For example: mesh.primitives.attributes, technique.attributes,
and technique.uniforms.
2016-06-14 22:47:50 -04:00
Syoyo Fujita a5c15e9e76 Merge branch 'master' of github.com:syoyo/tinygltfloader 2016-06-11 16:33:46 +09:00
Syoyo Fujita 89ac0b45cb Update README. 2016-06-11 16:33:32 +09:00
Syoyo Fujita 8317ffbe8a Improve windows build.
Don't report error when `in_normal` is not used in the shader.
2016-06-11 16:10:39 +09:00
Syoyo Fujita 9a478238c7 Format source. 2016-06-06 01:26:57 +09:00
Syoyo Fujita 0a3b09f33e Initial glTF writer example(W.I.P). 2016-06-06 01:26:18 +09:00
Syoyo Fujita 064d177448 Print warning when bufferView.target == 0. 2016-06-06 01:20:52 +09:00
Syoyo Fujita d286bd9ac0 Print bufferView.target. 2016-06-06 01:20:32 +09:00
Syoyo Fujita b37b7de27c Retinal display fix for glview. 2016-06-05 22:35:37 +09:00
Syoyo Fujita e04b1b56d8 Add error check for scenes property. 2016-06-05 22:31:20 +09:00
Syoyo Fujita fbc6118c6a Missing indices print. 2016-06-05 22:17:19 +09:00
Syoyo Fujita 8c6774c6db Suppress VS2015 warning. 2016-05-01 20:36:29 +09:00
Syoyo Fujita 6fd9162ed0 Make some compiler happy. 2016-05-01 20:27:30 +09:00
Syoyo Fujita beded611b7 Initial support of loading binary glTF(.glb). 2016-05-01 20:03:43 +09:00
Syoyo Fujita ec39a523c2 Merge branch 'master' of github.com:syoyo/tinygltfloader
Conflicts:
	tiny_gltf_loader.h
2016-05-01 18:33:31 +09:00
Syoyo Fujita 643ce10979 Suppress clang warnings for external code. 2016-05-01 17:19:37 +09:00
Syoyo Fujita 5eebbdc87c Suppress VC2015 warnings. 2016-04-20 14:13:08 +09:00
Syoyo Fujita 523c9bfbc2 Apply cpplint.
Use Google C++ style.
2016-04-20 14:06:56 +09:00
Syoyo Fujita 46ae360e15 Update test.cc 2016-03-18 00:55:21 +09:00
Syoyo Fujita e1bef8cacb Apply cpplint and format source code. 2016-03-17 21:31:13 +09:00
Syoyo Fujita 41426b6134 Merge branch 'master' of github.com:syoyo/tinygltfloader 2016-03-11 00:42:31 +09:00
Syoyo Fujita 719315f5f4 Disable ASAN for clang 3.7. 2016-03-11 00:41:49 +09:00
Syoyo Fujita 5bc17bdf5f Merge pull request #2 from dgough/master
Fixed loading child nodes
2016-03-08 17:11:12 +09:00
Darryl Gough bc9f2b2544 Fixed loading child nodes
Fixed a bug that was preventing child nodes from being loaded.
2016-03-08 00:19:40 -05:00
Syoyo Fujita 7c87797176 Refactor source code.
Add compiler matrix in Travis build.
2016-03-08 01:31:49 +09:00
Syoyo Fujita c4bc323c0e Update README. 2016-02-07 17:46:55 +09:00
Syoyo Fujita e9a0cd9210 Update screen shot. 2016-02-07 17:45:17 +09:00
Syoyo Fujita bde7021b94 texture support. 2016-02-07 17:38:17 +09:00
Syoyo Fujita b495603c67 Update README. 2016-02-06 17:28:42 +09:00
Syoyo Fujita 61fb52b57d Support loading glTF from memory(string). 2016-02-06 17:26:44 +09:00
Syoyo Fujita d8959696c0 Merge branch 'master' of github.com:syoyo/tinygltfloader 2016-01-02 23:42:55 +09:00
Syoyo Fujita 620eed154b Add image/jpeg and image/png MIME support.
Add simple unit test runner.
2016-01-02 23:37:12 +09:00
Syoyo Fujita 582226ac48 Add travis badge. 2015-12-21 11:56:54 +09:00
Syoyo Fujita 44430496d2 Add travis script. 2015-12-21 11:54:36 +09:00
Syoyo Fujita ed4d7ad34b Add box.gltf. 2015-12-21 11:50:21 +09:00
Syoyo Fujita ba26657a01 Use GLFW_INCLUDE_GLU 2015-12-21 11:48:32 +09:00
Syoyo Fujita f6a31fa22e Update appveyor yaml. 2015-12-21 01:23:00 +09:00
Syoyo Fujita ad9ef023ea Add AppVeyor badge. 2015-12-21 01:22:12 +09:00
Syoyo Fujita 47de00b91f Fix markdown. 2015-12-21 01:21:03 +09:00
Syoyo Fujita c717f1859f Add appveyor file. 2015-12-21 01:20:35 +09:00
1420 changed files with 57637 additions and 77536 deletions
-45
View File
@@ -1,45 +0,0 @@
## Description
What does this PR do? Provide a brief summary of the changes.
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Refactoring (no functional changes)
- [ ] Documentation update
- [ ] Other (please describe):
## Checklist
### Required for All PRs
- [ ] Reproducible glTF test file(s) are included (e.g., `models/regression/`, `tests/issue-***.gltf`, etc.)
- [ ] Unit tests are written and pass locally (`cd tests && make run`)
### Required for Feature PRs
- [ ] Specification document is included (e.g., `docs/spec/<feature-name>.md`)
- The spec should cover: purpose, API design, usage examples, and edge cases
### Security Policy
This project manages CVE assignments exclusively through GitHub Security Advisories.
PRs that include or reference independently obtained CVE IDs or external vulnerability disclosures will be closed.
## Test Instructions
How can reviewers verify your changes?
```
# Example:
cd build && cmake .. && make test
```
## Related Issues
Link related issues:
## Additional Notes
Any other context, screenshots, or information relevant to the review.
+125 -24
View File
@@ -4,65 +4,166 @@ on: [push, pull_request]
jobs:
# gcc4.8 is too old and ubuntu-18.04 image is not supported in GitHub Actions anymore,
# so disable this build.
## compile with older gcc4.8
#build-gcc48:
# runs-on: ubuntu-18.04
# name: Build with gcc 4.8
# steps:
# - name: Checkout
# uses: actions/checkout@v1
# - name: Build
# run: |
# sudo apt-get update
# sudo apt-get install -y build-essential
# sudo apt-get install -y gcc-4.8 g++-4.8
# g++-4.8 -std=c++11 -o loader_example loader_example.cc
# - name: NoexceptBuild
# run: |
# g++-4.8 -DTINYGLTF_NOEXCEPTION -std=c++11 -o loader_example loader_example.cc
# - name: RapidjsonBuild
# run: |
# git clone https://github.com/Tencent/rapidjson
# g++-4.8 -DTINYGLTF_USE_RAPIDJSON -I./rapidjson/include/rapidjson -std=c++11 -o loader_example loader_example.cc
# compile with mingw gcc cross
build-mingw-cross:
runs-on: ubuntu-latest
name: Build v3 C tests with MinGW gcc cross
name: Build with MinGW gcc cross
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v2
- name: Build
run: |
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y mingw-w64
cd tests
x86_64-w64-mingw32-gcc -I../ -std=c11 -DTINYGLTF3_ENABLE_FS -o tester_v3_c.exe tester_v3_c.c ../tiny_gltf_v3.c
x86_64-w64-mingw32-g++ -std=c++11 -o loader_example loader_example.cc
# Windows(x64) + MSVC build (VS version agnostic: msvc-dev-cmd locates
# whatever Visual Studio the runner image ships, e.g. VS2022 or VS2026)
# Windows(x64) + Visual Studio 2022 build
# Assume windows-latest have VS2022 installed
build-windows-msvc:
runs-on: windows-latest
name: Build v3 C tests on Windows(x64, MSVC)
name: Build for Windows(x64, MSVC)
# Use system installed cmake
# https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up MSVC environment
uses: ilammy/msvc-dev-cmd@v1
uses: actions/checkout@v1
- name: Configure
run: cmake -B build -G Ninja -DTINYGLTF3_BUILD_TESTS=ON
run: |
mkdir build
cd build
cmake --help
cmake -G "Visual Studio 17 2022" -A x64 -DTINYGLTF_BUILD_LOADER_EXAMPLE=On -DTINYGLTF_BUILD_GL_EXAMPLES=Off -DTINYGLTF_BUILD_VALIDATOR_EXAMPLE=On ..
cd ..
- name: Build
run: cmake --build build
- name: Run tests
run: ctest --test-dir build --output-on-failure
run: cmake --build build --config Release
build-linux:
runs-on: ubuntu-latest
name: Build v3 C tests with gcc
name: Buld with gcc
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v2
- name: build
run: |
cd tests
cc -I../ -std=c11 -g -O0 -DTINYGLTF3_ENABLE_FS -o tester_v3_c tester_v3_c.c ../tiny_gltf_v3.c
g++ -std=c++11 -o loader_example loader_example.cc
- name: test
run: |
./tests/tester_v3_c models/Cube/Cube.gltf
./loader_example models/Cube/Cube.gltf
- name: tests
run: |
cd tests
make all
./tester_v3_c
./tester_v3_c_v1port
./tester_v3_json_c
./tester_v3_freestanding
g++ -I../ -std=c++11 -g -O0 -o tester tester.cc
./tester
cd ..
- name: noexcept_tests
run: |
cd tests
g++ -DTINYGLTF_NOEXCEPTION -I../ -std=c++11 -g -O0 -o tester_noexcept tester.cc
./tester_noexcept
cd ..
build-rapidjson-linux:
runs-on: ubuntu-latest
name: Buld with gcc + rapidjson
steps:
- uses: actions/checkout@v2
- name: build
run: |
git clone https://github.com/Tencent/rapidjson
g++ -v
g++ -DTINYGLTF_USE_RAPIDJSON -I./rapidjson/include/rapidjson -std=c++11 -o loader_example loader_example.cc
- name: loader_example_test
run: |
./loader_example models/Cube/Cube.gltf
- name: tests
run: |
cd tests
g++ -DTINYGLTF_USE_RAPIDJSON -I../rapidjson/include/rapidjson -I../ -std=c++11 -g -O0 -o tester tester.cc
./tester
cd ..
- name: noexcept_tests
run: |
cd tests
g++ -DTINYGLTF_USE_RAPIDJSON -I../rapidjson/include/rapidjson -DTINYGLTF_NOEXCEPTION -I../ -std=c++11 -g -O0 -o tester_noexcept tester.cc
./tester_noexcept
cd ..
# Cross-compile for aarch64 linux target
build-cross-aarch64:
runs-on: ubuntu-latest
name: Build on cross aarch64
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: |
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
git clone https://github.com/Tencent/rapidjson
aarch64-linux-gnu-g++ -DTINYGLTF_USE_RAPIDJSON -I./rapidjson/include/rapidjson -std=c++11 -g -O0 -o loader_example loader_example.cc
# macOS clang
build-macos:
runs-on: macos-latest
name: Build on macOS
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Build
run: |
clang++ -std=c++11 -g -O0 -o loader_example loader_example.cc
./loader_example models/Cube/Cube.gltf
git clone https://github.com/Tencent/rapidjson
clang++ -DTINYGLTF_USE_RAPIDJSON -I./rapidjson/include/rapidjson -std=c++11 -g -O0 -o loader_example loader_example.cc
-389
View File
@@ -1,389 +0,0 @@
name: Comprehensive CI
on:
push:
branches:
- master
- release
- devel
pull_request:
branches:
- master
- release
- devel
workflow_dispatch:
permissions:
contents: read
jobs:
# Linux x64 - GCC
linux-gcc-x64:
runs-on: ubuntu-latest
name: Linux x64 (GCC)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Configure
run: cmake -B build -DTINYGLTF3_BUILD_TESTS=ON
- name: Build
run: cmake --build build
- name: Run tester_v3_c on a sample model
run: ./build/tester_v3_c models/Cube/Cube.gltf
- name: Run tests
run: ctest --test-dir build --output-on-failure
# Linux x64 - Clang 21
linux-clang-x64:
runs-on: ubuntu-24.04
name: Linux x64 (Clang 21)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Clang 21
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
- name: Configure
run: |
cmake -B build -DCMAKE_C_COMPILER=clang-21 -DTINYGLTF3_BUILD_TESTS=ON
- name: Build
run: cmake --build build
- name: Run tester_v3_c on a sample model
run: ./build/tester_v3_c models/Cube/Cube.gltf
- name: Run tests
run: ctest --test-dir build --output-on-failure
# Linux ARM64 - GCC (native)
linux-arm64:
runs-on: ubuntu-24.04-arm
name: Linux ARM64 (GCC)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Configure
run: cmake -B build -DTINYGLTF3_BUILD_TESTS=ON
- name: Build
run: cmake --build build
- name: Run tester_v3_c on a sample model
run: ./build/tester_v3_c models/Cube/Cube.gltf
- name: Run tests
run: ctest --test-dir build --output-on-failure
# macOS ARM64 Apple Silicon
macos-arm64:
runs-on: macos-14
name: macOS ARM64 Apple Silicon (Clang)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Configure
run: cmake -B build -DTINYGLTF3_BUILD_TESTS=ON
- name: Build
run: cmake --build build
- name: Run tester_v3_c on a sample model
run: ./build/tester_v3_c models/Cube/Cube.gltf
- name: Run tests
run: ctest --test-dir build --output-on-failure
# Windows x64 - MSVC (VS version agnostic; msvc-dev-cmd locates the
# Visual Studio shipped with the runner image, e.g. VS2022 or VS2026)
windows-msvc-x64:
runs-on: windows-latest
name: Windows x64 (MSVC)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up MSVC environment
uses: ilammy/msvc-dev-cmd@v1
- name: Configure
run: cmake -B build -G Ninja -DTINYGLTF3_BUILD_TESTS=ON
- name: Build
run: cmake --build build
- name: Run tester_v3_c on a sample model
run: |
.\build\tester_v3_c.exe models\Cube\Cube.gltf
- name: Run tests
run: ctest --test-dir build --output-on-failure
# Windows MinGW - MSYS2
windows-mingw-msys2:
runs-on: windows-latest
name: Windows x64 (MinGW MSYS2)
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
install: base-devel
pacboy: >-
cc:p cmake:p ninja:p
update: true
release: false
- name: Build with CMake
run: |
cmake -G"Ninja" -S . -B build -DTINYGLTF3_BUILD_TESTS=ON
cmake --build build
- name: Run tester_v3_c on a sample model
run: |
./build/tester_v3_c models/Cube/Cube.gltf
- name: Run tests
run: ctest --test-dir build --output-on-failure
# Linux -> Windows MinGW Cross-compile
linux-mingw-cross:
runs-on: ubuntu-latest
name: Linux→Windows (MinGW Cross) - Build Only
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install MinGW
run: |
sudo apt-get update
sudo apt-get install -y build-essential mingw-w64
- name: Build
run: |
cd tests
x86_64-w64-mingw32-gcc -I../ -std=c11 -g -O0 -DTINYGLTF3_ENABLE_FS -o tester_v3_c.exe tester_v3_c.c ../tiny_gltf_v3.c
# v3 C tests through Meson on the primary desktop platforms.
v3-c-meson:
runs-on: ${{ matrix.os }}
name: v3 C Meson (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Meson
run: python -m pip install meson ninja
- name: Configure
run: meson setup build-meson -Dtests=true
- name: Build
run: meson compile -C build-meson
- name: Run v3 C tests
run: meson test -C build-meson --print-errorlogs
# v3 C runtime: internal security regression tests + ported v1 unit tests.
v3-c-tests:
runs-on: ubuntu-latest
name: v3 C tests (Linux x64, GCC)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Build tester_v3_c
run: |
cd tests
cc -I../ -std=c11 -g -O0 -Wall -Wextra -Wpedantic -Werror -DTINYGLTF3_ENABLE_FS \
-o tester_v3_c tester_v3_c.c ../tiny_gltf_v3.c
- name: Build tester_v3_c_v1port
run: |
cd tests
cc -I../ -std=c11 -g -O0 -Wall -Wextra -Wpedantic -Werror -DTINYGLTF3_ENABLE_FS \
-o tester_v3_c_v1port tester_v3_c_v1port.c ../tiny_gltf_v3.c
- name: Run tester_v3_c (security regressions)
run: |
cd tests
./tester_v3_c
- name: Run tester_v3_c_v1port (ported unit tests)
run: |
cd tests
./tester_v3_c_v1port
# v3 C runtime under stock Ubuntu clang.
v3-c-tests-clang:
runs-on: ubuntu-latest
name: v3 C tests (Linux x64, Clang)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install clang
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Build tester_v3_c
run: |
cd tests
clang -I../ -std=c11 -g -O0 -Werror -Weverything \
-Wno-padded -Wno-unsafe-buffer-usage -Wno-switch-default \
-Wno-format-nonliteral -Wno-float-equal -Wno-cast-align \
-Wno-declaration-after-statement -Wno-unknown-warning-option \
-Wno-pre-c11-compat \
-DTINYGLTF3_ENABLE_FS \
-o tester_v3_c tester_v3_c.c ../tiny_gltf_v3.c
- name: Build tester_v3_c_v1port
run: |
cd tests
clang -I../ -std=c11 -g -O0 -Werror -Weverything \
-Wno-padded -Wno-unsafe-buffer-usage -Wno-switch-default \
-Wno-format-nonliteral -Wno-float-equal -Wno-cast-align \
-Wno-declaration-after-statement -Wno-unknown-warning-option \
-Wno-pre-c11-compat \
-DTINYGLTF3_ENABLE_FS \
-o tester_v3_c_v1port tester_v3_c_v1port.c ../tiny_gltf_v3.c
- name: Run tester_v3_c
run: |
cd tests
./tester_v3_c
- name: Run tester_v3_c_v1port
run: |
cd tests
./tester_v3_c_v1port
# v3 C runtime under bleeding-edge clang 21 (matches local dev environment).
v3-c-tests-clang21:
runs-on: ubuntu-24.04
name: v3 C tests (Linux x64, Clang 21)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install clang 21
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
- name: Build tester_v3_c
run: |
cd tests
clang-21 -I../ -std=c11 -g -O0 -Werror -Weverything \
-Wno-padded -Wno-unsafe-buffer-usage -Wno-switch-default \
-Wno-format-nonliteral -Wno-float-equal -Wno-cast-align \
-Wno-declaration-after-statement -Wno-unknown-warning-option \
-Wno-pre-c11-compat \
-DTINYGLTF3_ENABLE_FS \
-o tester_v3_c tester_v3_c.c ../tiny_gltf_v3.c
- name: Build tester_v3_c_v1port
run: |
cd tests
clang-21 -I../ -std=c11 -g -O0 -Werror -Weverything \
-Wno-padded -Wno-unsafe-buffer-usage -Wno-switch-default \
-Wno-format-nonliteral -Wno-float-equal -Wno-cast-align \
-Wno-declaration-after-statement -Wno-unknown-warning-option \
-Wno-pre-c11-compat \
-DTINYGLTF3_ENABLE_FS \
-o tester_v3_c_v1port tester_v3_c_v1port.c ../tiny_gltf_v3.c
- name: Run tester_v3_c
run: |
cd tests
./tester_v3_c
- name: Run tester_v3_c_v1port
run: |
cd tests
./tester_v3_c_v1port
# v3 C runtime built with MSVC at warning-level 4 (/W4 /WX).
v3-c-tests-msvc:
runs-on: windows-latest
name: v3 C tests (Windows x64, MSVC /W4)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up MSVC environment
uses: ilammy/msvc-dev-cmd@v1
- name: Build and run tester_v3_c
shell: cmd
run: |
cd tests
cl /nologo /W4 /WX /std:c11 /Zi /Od /D_CRT_SECURE_NO_WARNINGS /DTINYGLTF3_ENABLE_FS /I.. tester_v3_c.c ..\tiny_gltf_v3.c /Fe:tester_v3_c.exe
tester_v3_c.exe
- name: Build and run tester_v3_c_v1port
shell: cmd
run: |
cd tests
cl /nologo /W4 /WX /std:c11 /Zi /Od /D_CRT_SECURE_NO_WARNINGS /DTINYGLTF3_ENABLE_FS /I.. tester_v3_c_v1port.c ..\tiny_gltf_v3.c /Fe:tester_v3_c_v1port.exe
tester_v3_c_v1port.exe
# v3 C runtime under ASan + UBSan for memory-safety + UB checks.
v3-c-tests-sanitizers:
runs-on: ubuntu-latest
name: v3 C tests (Clang ASan + UBSan)
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Build tester_v3_c with ASan + UBSan
run: |
cd tests
clang -I../ -std=c11 -g -O1 -DTINYGLTF3_ENABLE_FS \
-fsanitize=address,undefined -fno-omit-frame-pointer \
-o tester_v3_c tester_v3_c.c ../tiny_gltf_v3.c
- name: Build tester_v3_c_v1port with ASan + UBSan
run: |
cd tests
clang -I../ -std=c11 -g -O1 -DTINYGLTF3_ENABLE_FS \
-fsanitize=address,undefined -fno-omit-frame-pointer \
-o tester_v3_c_v1port tester_v3_c_v1port.c ../tiny_gltf_v3.c
- name: Run tester_v3_c
env:
ASAN_OPTIONS: detect_leaks=1:halt_on_error=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
run: |
cd tests
./tester_v3_c
- name: Run tester_v3_c_v1port
env:
ASAN_OPTIONS: detect_leaks=1:halt_on_error=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
run: |
cd tests
./tester_v3_c_v1port
+72
View File
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '21 20 * * 5'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
-53
View File
@@ -1,53 +0,0 @@
name: MSYS2 MinGW-w64 Windows 64bit Build
on:
push:
branches:
- release
- devel
paths:
- 'tiny_gltf.*'
- 'tinygltf_json_c.h'
- 'CMakeLists.txt'
- 'meson.build'
- 'meson_options.txt'
- 'tests/tester_v3*.c'
- '.github/workflows/mingw-w64-msys2.yml'
pull_request:
workflow_dispatch:
jobs:
mingw-w64-msys2-build:
name: MSYS2 MinGW-w64 Windows Build
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v5
- name: Install core & build dependencies
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
install: base-devel
pacboy: >-
cc:p cmake:p ninja:p
update: true
release: false
- name: Configure
run: |
cmake \
-G"Ninja" \
-S . \
-B build \
-DTINYGLTF3_BUILD_TESTS=ON
- name: Build
run: |
cmake --build build
- name: Run tests
run: |
ctest --test-dir build --output-on-failure
+7 -20
View File
@@ -1,5 +1,4 @@
# CMake
/build/
CMakeCache.txt
CMakeFiles
CMakeScripts
@@ -22,13 +21,9 @@ premake5.tar.gz
*.vcxproj*
.vs
# default cmake build dir
build/
#binary directories
bin/
obj/
out/
#runtime gui config
imgui.ini
@@ -70,22 +65,14 @@ imgui.ini
*.app
loader_example
# Compiled test binaries (built by tests/Makefile, CMakeLists.txt, meson.build)
tests/tester_v3
tests/tester_v3_c
tests/tester_v3_c_cpp
tests/tester_v3_c_v1port
tests/tester_v3_c_v1port_cpp
tests/tester_v3_freestanding
tests/tester_v3_json_c
tests/v3/fuzzer/fuzz_gltf_v3
tests/v3/fuzzer/fuzz_gltf_v3_c
# Generated by web/Makefile (make / make sample)
web/tinygltf_v3.js
web/tinygltf_v3.wasm
web/Cube.glb
tests/tester
tests/tester_noexcept
tests/issue-97.gltf
tests/issue-261.gltf
# unignore
!Makefile
!examples/build-gltf/Makefile
!examples/raytrace/cornellbox_suzanne.obj
!tests/Makefile
!tools/windows/premake5.exe
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
if [[ "$TRAVIS_OS_NAME" == "osx" ]]
then
brew upgrade
curl -o premake5.tar.gz https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-macosx.tar.gz
else
wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-linux.tar.gz -O premake5.tar.gz
fi
tar xzf premake5.tar.gz
+63
View File
@@ -0,0 +1,63 @@
language: cpp
sudo: false
matrix:
include:
- addons: &1
apt:
sources:
- george-edison55-precise-backports
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-3.9
packages:
- g++-4.9
- clang-3.9
compiler: clang
env: COMPILER_VERSION=3.9 BUILD_TYPE=Debug
- addons: *1
compiler: clang
env: COMPILER_VERSION=3.9 BUILD_TYPE=Release
- addons: &2
apt:
sources:
- george-edison55-precise-backports
- ubuntu-toolchain-r-test
packages:
- g++-4.9
compiler: gcc
env: COMPILER_VERSION=4.9 BUILD_TYPE=Debug EXTRA_CXXFLAGS="-fsanitize=address"
- addons: *2
compiler: gcc
env: COMPILER_VERSION=4.9 BUILD_TYPE=Release EXTRA_CXXFLAGS="-fsanitize=address"
- addons: *1
compiler: clang
env: COMPILER_VERSION=3.9 BUILD_TYPE=Debug CFLAGS="-O0" CXXFLAGS="-O0"
- addons: &3
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
compiler: gcc
env: COMPILER_VERSION=4.8 BUILD_TYPE=Debug
- addons: *3
compiler: gcc
env: COMPILER_VERSION=4.8 BUILD_TYPE=Release
before_install:
- ./.travis-before-install.sh
script:
- export CC="${CC}-${COMPILER_VERSION}"
- export CXX="${CXX}-${COMPILER_VERSION}"
- ${CC} -v
- ${CXX} ${EXTRA_CXXFLAGS} -std=c++11 -Wall -g -o loader_example loader_example.cc
- ./loader_example ./models/Cube/Cube.gltf
- cd tests
- clang++ -v
- make
- ./tester
- ./tester_noexcept
- cd ../examples/raytrace
- ../../premake5 gmake
- make
-55
View File
@@ -1,55 +0,0 @@
# AGENTS.md — tinygltf v3 (C)
TinyGLTF v3 C (`tiny_gltf_v3.h` + `tiny_gltf_v3.c` + `tinygltf_json_c.h`) is the
mainline. Legacy v1/v2/v3-C++ code lives under `attic/` and is not built or
tested.
## Commands
- Unit tests (C): `make -C tests all && make -C tests run`
- CMake: `cmake -B build -DTINYGLTF3_BUILD_TESTS=ON && cmake --build build && ctest --test-dir build --output-on-failure`
- Meson: `meson setup build && meson compile -C build && meson test -C build`
- WASM/web demo (requires Emscripten SDK, default `~/work/emsdk`):
`make -C web && make -C web sample` — then open `http://localhost:8000` via `make -C web serve`
- Fuzzers: `make -C tests/v3/fuzzer` (clang + libFuzzer)
## Pre-push audit checklist
Run **before every push**. Fix or unstage anything found; the audit must pass
clean.
1. **Working tree sanity**
- `git status --short` — no staged build artifacts, no surprise files.
- Never `git add -A` / `git add .`: stage only intended paths. The repo
root frequently contains untracked scratch files (`Fox.glb`,
`benchmark/synthetic_*`, `log*`, `.cache/`, `tests/v3/fuzzer/artifacts|corpus`,
stray `*.gltf`/`*.bin` files). Verify `git status` before staging.
2. **Secret scan**
- `gitleaks detect --source . --no-banner -r /tmp/gitleaks.json`
- `~/local/bin/trufflehog git file://$PWD --no-update --only-verified`
- Both must report 0 real secrets. Known allowed finding: `B3G_LEFT_ARROW`
generic-api-key hits in `attic/examples/common/OpenGLWindow/` are false
positives (keyboard key constants).
3. **No build artifacts or unwanted large binaries**
- `git ls-files -z | xargs -0 du -b | sort -rn | head -30` — review the top.
- Rule of thumb: nothing over ~1 MB unless it is a tracked, intentional
asset (e.g. `attic/tools/windows/premake5.exe`, `models/Cube/*.png`).
- Watch for: compiled executables, `*.wasm`/`*.exr`/`*.log`/`*.o`/`*.obj`,
generated `output.*`/`cloth*`/`sim*.bin`/`out_*.exr` files, and large
`.gltf`/`.glb` files. Small test/regression fixture `.gltf` files
(e.g. under `tests/`, `models/regression/`, `tests/v3/security/`) are OK.
- `web/tinygltf_v3.js`, `web/tinygltf_v3.wasm`, `web/Cube.glb` are
generated by `make -C web` and must stay gitignored (never commit them).
4. **History is lean**
- If an unwanted file was added in an unpushed commit, rewrite it
(`git rebase -i origin/<branch>`, `git rm` + `--amend`) so the blob never
reaches the remote, then `git gc --prune=now` locally.
- Push only intended branches (`git push origin <branch>` — never `--all`
or `--force` unless explicitly asked).
5. **Final smoke check**
- `make -C tests run` passes (all 4 testers).
- If touched: `cmake`/`meson` builds and `make -C web` still succeed.
+63 -43
View File
@@ -1,56 +1,76 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.6)
project(tinygltf_v3 C)
PROJECT (tinygltf)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED On)
set(CMAKE_C_EXTENSIONS Off)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
SET(CMAKE_CXX_STANDARD 11)
option(TINYGLTF3_BUILD_TESTS "Build and run tinygltf v3 C unit tests" ON)
option(TINYGLTF3_INSTALL "Install tinygltf v3 files during install step" ON)
option(TINYGLTF_BUILD_LOADER_EXAMPLE "Build loader_example(load glTF and dump infos)" ON)
option(TINYGLTF_BUILD_GL_EXAMPLES "Build GL exampels(requires glfw, OpenGL, etc)" OFF)
option(TINYGLTF_BUILD_VALIDATOR_EXAMPLE "Build validator exampe" OFF)
option(TINYGLTF_BUILD_BUILDER_EXAMPLE "Build glTF builder example" OFF)
option(TINYGLTF_HEADER_ONLY "On: header-only mode. Off: create tinygltf library(No TINYGLTF_IMPLEMENTATION required in your project)" OFF)
option(TINYGLTF_INSTALL "Install tinygltf files during install step. Usually set to OFF if you include tinygltf through add_subdirectory()" ON)
set(TINYGLTF3_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
if (TINYGLTF3_BUILD_TESTS)
enable_testing()
function(add_tinygltf_v3_c_test target)
add_executable(${target} ${ARGN})
target_include_directories(${target} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tests
if (TINYGLTF_BUILD_LOADER_EXAMPLE)
ADD_EXECUTABLE ( loader_example
loader_example.cc
)
set_target_properties(${target} PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON
C_EXTENSIONS OFF
)
add_test(NAME ${target} COMMAND ${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
endfunction()
endif (TINYGLTF_BUILD_LOADER_EXAMPLE)
add_tinygltf_v3_c_test(tester_v3_c tests/tester_v3_c.c tiny_gltf_v3.c)
target_compile_definitions(tester_v3_c PRIVATE TINYGLTF3_ENABLE_FS)
if (TINYGLTF_BUILD_GL_EXAMPLES)
ADD_SUBDIRECTORY ( examples/gltfutil )
ADD_SUBDIRECTORY ( examples/glview )
endif (TINYGLTF_BUILD_GL_EXAMPLES)
add_tinygltf_v3_c_test(tester_v3_c_v1port tests/tester_v3_c_v1port.c tiny_gltf_v3.c)
target_compile_definitions(tester_v3_c_v1port PRIVATE TINYGLTF3_ENABLE_FS)
if (TINYGLTF_BUILD_VALIDATOR_EXAMPLE)
ADD_SUBDIRECTORY ( examples/validator )
endif (TINYGLTF_BUILD_VALIDATOR_EXAMPLE)
add_tinygltf_v3_c_test(tester_v3_json_c tests/tester_v3_json_c.c)
if (TINYGLTF_BUILD_BUILDER_EXAMPLE)
ADD_SUBDIRECTORY ( examples/build-gltf )
endif (TINYGLTF_BUILD_BUILDER_EXAMPLE)
add_tinygltf_v3_c_test(tester_v3_freestanding tests/tester_v3_freestanding.c)
if (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(tester_v3_freestanding PRIVATE -ffreestanding)
endif()
endif ()
#
# for add_subdirectory and standalone build
#
if (TINYGLTF_HEADER_ONLY)
add_library(tinygltf INTERFACE)
if (TINYGLTF3_INSTALL)
install(FILES
tiny_gltf_v3.h
tiny_gltf_v3.c
tinygltf_json_c.h
DESTINATION
${TINYGLTF3_INSTALL_DIR}
target_include_directories(tinygltf
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endif ()
else (TINYGLTF_HEADER_ONLY)
add_library(tinygltf)
target_sources(tinygltf PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/tiny_gltf.cc)
target_include_directories(tinygltf
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endif (TINYGLTF_HEADER_ONLY)
if (TINYGLTF_INSTALL)
install(TARGETS tinygltf EXPORT tinygltfTargets)
install(EXPORT tinygltfTargets NAMESPACE tinygltf:: FILE TinyGLTFTargets.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TinyGLTFConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/TinyGLTFConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TinyGLTFConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
# Do not install .lib even if !TINYGLTF_HEADER_ONLY
INSTALL ( FILES
json.hpp
stb_image.h
stb_image_write.h
tiny_gltf.h
${TINYGLTF_EXTRA_SOUECES}
DESTINATION
include
)
endif(TINYGLTF_INSTALL)
+10 -11
View File
@@ -1,14 +1,13 @@
# tinygltf v3 (C) — convenience build entry point.
#
# make — build all v3 C unit testers
# make test — build and run all v3 C unit testers
# make clean — remove test binaries
# Use this for strict compilation check(will work on clang 3.8+)
#EXTRA_CXXFLAGS := -fsanitize=address -Wall -Werror -Weverything -Wno-c++11-long-long -Wno-c++98-compat
# With draco
# EXTRA_CXXFLAGS := -I../draco/src/ -I../draco/build -DTINYGLTF_ENABLE_DRACO -L../draco/build
# EXTRA_LINKFLAGS := -L../draco/build/ -ldracodec -ldraco
all:
$(MAKE) -C tests all
clang++ $(EXTRA_CXXFLAGS) -std=c++11 -g -O0 -o loader_example loader_example.cc $(EXTRA_LINKFLAGS)
test: all
$(MAKE) -C tests run
clean:
$(MAKE) -C tests clean
lint:
deps/cpplint.py tiny_gltf.h
+265 -91
View File
@@ -1,105 +1,279 @@
# tinygltf v3 — C glTF 2.0 loader/saver
# Header only C++ tiny glTF library(loader/saver).
`TinyGLTF v3` is a C11-first implementation of a glTF 2.0
https://github.com/KhronosGroup/glTF loader and writer.
`TinyGLTF` is a header only C++11 glTF 2.0 https://github.com/KhronosGroup/glTF library.
- **Pure C POD API** (`tiny_gltf_v3.h` + `tiny_gltf_v3.c` + `tinygltf_json_c.h`) — no STL, no RTTI, no exceptions required; easy to bind to other languages.
- **Arena-based memory management** — all parse-time allocations come from a single arena; a single `tg3_model_free()` frees everything.
- **Structured error reporting** — `tg3_error_stack` provides machine-readable errors with severity levels and source locations.
- **Custom JSON backend** — `tinygltf_json_c.h` is a locale-independent pure-C JSON parser/serializer used by the v3 runtime.
- **Streaming callbacks** — opt-in streaming parse/write via user-supplied callbacks.
- **Opt-in filesystem and image I/O** — `TINYGLTF3_ENABLE_FS` / `TINYGLTF3_ENABLE_STB_IMAGE` are off by default; you control when and how assets are loaded.
- **C++20 coroutine facade** (optional, auto-detected). C17/C++17 default.
- **Hardened against untrusted input** — URI sanitization, post-parse index-bounds validation (default-on, opt-out via `tg3_parse_options.validate_indices = 0`), strict numeric range checks; exercised by a libFuzzer harness. See the `Security Considerations` block at the top of `tiny_gltf_v3.h`.
## Quick start
Copy `tiny_gltf_v3.h`, `tiny_gltf_v3.c`, and `tinygltf_json_c.h` to your project.
Compile `tiny_gltf_v3.c` as C11 or newer. Define `TINYGLTF3_ENABLE_FS` when
building `tiny_gltf_v3.c` if you want `tg3_parse_file()` to use stdio-backed
filesystem helpers. The legacy `TINYGLTF3_IMPLEMENTATION` include path remains
available for compatibility.
```c
#include "tiny_gltf_v3.h"
```
Loading a glTF file:
```c
tg3_parse_options opts;
tg3_error_stack errors;
tg3_model model;
tg3_parse_options_init(&opts);
tg3_error_stack_init(&errors);
tg3_error_code err = tg3_parse_file(&model, &errors, "scene.gltf", 10, &opts);
if (err != TG3_OK) {
for (uint32_t i = 0; i < errors.count; i++) {
fprintf(stderr, "[%d] %s\n", (int)errors.entries[i].severity,
errors.entries[i].message ? errors.entries[i].message : "(null)");
}
}
// ... use model ...
tg3_model_free(&model);
tg3_error_stack_free(&errors);
```
## Testing & verification
The v3 C runtime ships with three layers of automated coverage:
- **`tests/tester_v3_c.c`** — internal unit checks plus security regression tests (path traversal, negative `byteStride`, OOB indices, error-message lifetime, …). Build via `make` in `tests/`; run `./tester_v3_c` for the internal suite or `./tester_v3_c <file.gltf|file.glb>` to parse a single asset.
- **`tests/tester_v3_c_v1port.c`** — v3 C port of the legacy unit tests, keeping behavioral parity with the old C++ API.
- **`tests/tester_v3_json_c.c`** and **`tests/tester_v3_freestanding.c`** — JSON backend and freestanding (no libc) checks.
- **`test_runner.py`** — model verifier that runs `tests/tester_v3_c` against every model in `glTF-Sample-Models/2.0` and validates the structured COUNTS/DIGEST output.
- **`tests/v3/fuzzer/`** — libFuzzer harness with ASan + UBSan (`make run` builds and runs `fuzz_gltf_v3_c`). Crafted regression inputs live in `tests/v3/security/` and are seeded into `tests/v3/fuzzer/corpus/`.
### Building
```bash
# Plain make (gcc/clang)
$ make -C tests && make -C tests run
# CMake
$ cmake -B build && cmake --build build && ctest --test-dir build --output-on-failure
# Meson
$ meson setup build && meson compile -C build && meson test -C build
# WebAssembly (requires an Emscripten SDK, defaults to ~/work/emsdk)
$ make -C web && make -C web sample
```
## Web/WASM demo
[`web/`](web/) contains a browser demo that compiles the v3 C runtime with
Emscripten and renders glTF/GLB files with three.js (file picker + drag &
drop). See [`web/README.md`](web/README.md) for build instructions.
## Legacy v1/v2 (C++)
The previous C++ implementation (`tiny_gltf.h`, `tiny_gltf.cc`,
`tinygltf_json.h`, `json.hpp`, `loader_example.cc`, the C++ examples and
tests) is deprecated and has been moved to [`attic/`](attic/) for reference.
It is no longer built, tested, or installed. TinyGLTF v3 C is the mainline.
`TinyGLTF` uses Niels Lohmann's json library (https://github.com/nlohmann/json), so now it requires C++11 compiler.
(Also, you can use RadpidJSON as an JSON backend)
If you are looking for old, C++03 version, please use `devel-picojson` branch (but not maintained anymore).
## Status
TinyGLTF v3 (`tiny_gltf_v3.h` + `tiny_gltf_v3.c`) is the mainline release.
API additions and behavior changes go through the usual review process.
Currently TinyGLTF is stable and maintenance mode. No drastic changes and feature additions planned.
- v2.8.0 Add URICallbacks for custom URI handling in Buffer and Image. PR#397
- v2.7.0 Change WriteImageDataFunction user callback function signature. PR#393
- v2.6.0 Support serializing sparse accessor(Thanks to @fynv).
- v2.5.0 Add SetPreserveImageChannels() option to load image data as is.
- v2.4.0 Experimental RapidJSON support. Experimental C++14 support(C++14 may give better performance)
- v2.3.0 Modified Material representation according to glTF 2.0 schema(and introduced TextureInfo class)
- v2.2.0 release(Support loading 16bit PNG. Sparse accessor support)
- v2.1.0 release(Draco decoding support)
- v2.0.0 release(22 Aug, 2018)!
### Branches
* `sajson` : Use sajson to parse JSON. Parsing only but faster compile time(2x reduction compared to json.hpp and RapidJson), but not well maintained.
## Builds
[![Build Status](https://travis-ci.org/syoyo/tinygltf.svg?branch=devel)](https://travis-ci.org/syoyo/tinygltf)
[![Build status](https://ci.appveyor.com/api/projects/status/warngenu9wjjhlm8?svg=true)](https://ci.appveyor.com/project/syoyo/tinygltf)
![C/C++ CI](https://github.com/syoyo/tinygltf/workflows/C/C++%20CI/badge.svg)
## Features
Probably mostly feature-complete. Last missing feature is Draco encoding: https://github.com/syoyo/tinygltf/issues/207
* Written in portable C++. C++-11 with STL dependency only.
* [x] macOS + clang(LLVM)
* [x] iOS + clang
* [x] Linux + gcc/clang
* [x] Windows + MinGW
* [x] Windows + Visual Studio 2015 Update 3 or later.
* Visual Studio 2013 is not supported since they have limited C++11 support and failed to compile `json.hpp`.
* [x] Android NDK
* [x] Android + CrystaX(NDK drop-in replacement) GCC
* [x] Web using Emscripten(LLVM)
* Moderate parsing time and memory consumption.
* glTF specification v2.0.0
* [x] ASCII glTF
* [x] Load
* [x] Save
* [x] Binary glTF(GLB)
* [x] Load
* [x] Save(.bin embedded .glb)
* Buffers
* [x] Parse BASE64 encoded embedded buffer data(DataURI).
* [x] Load `.bin` file.
* Image(Using stb_image)
* [x] Parse BASE64 encoded embedded image data(DataURI).
* [x] Load external image file.
* [x] Load PNG(8bit and 16bit)
* [x] Load JPEG(8bit only)
* [x] Load BMP
* [x] Load GIF
* [x] Custom Image decoder callback(e.g. for decoding OpenEXR image)
* Morph traget
* [x] Sparse accessor
* Load glTF from memory
* Custom callback handler
* [x] Image load
* [x] Image save
* Extensions
* [x] Draco mesh decoding
* [ ] Draco mesh encoding
## Note on extension property
In extension(`ExtensionMap`), JSON number value is parsed as int or float(number) and stored as `tinygltf::Value` object. If you want a floating point value from `tinygltf::Value`, use `GetNumberAsDouble()` method.
`IsNumber()` returns true if the underlying value is an int value or a floating point value.
## Examples
* [glview](examples/glview) : Simple glTF geometry viewer.
* [validator](examples/validator) : Simple glTF validator with JSON schema.
* [basic](examples/basic) : Basic glTF viewer with texturing support.
* [build-gltf](examples/build-gltf) : Build simple glTF scene from a scratch.
### WASI/WASM build
Users who want to run TinyGLTF securely and safely(e.g. need to handle malcious glTF file to serve online glTF conver),
I recommend to build TinyGLTF for WASM target.
WASI build example is located in [wasm](wasm) .
## Projects using TinyGLTF
* px_render Single header C++ Libraries for Thread Scheduling, Rendering, and so on... https://github.com/pplux/px
* Physical based rendering with Vulkan using glTF 2.0 models https://github.com/SaschaWillems/Vulkan-glTF-PBR
* GLTF loader plugin for OGRE 2.1. Support for PBR materials via HLMS/PBS https://github.com/Ybalrid/Ogre_glTF
* [TinyGltfImporter](http://doc.magnum.graphics/magnum/classMagnum_1_1Trade_1_1TinyGltfImporter.html) plugin for [Magnum](https://github.com/mosra/magnum), a lightweight and modular C++11/C++14 graphics middleware for games and data visualization.
* [Diligent Engine](https://github.com/DiligentGraphics/DiligentEngine) - A modern cross-platform low-level graphics library and rendering framework
* Lighthouse 2: a rendering framework for real-time ray tracing / path tracing experiments. https://github.com/jbikker/lighthouse2
* [QuickLook GLTF](https://github.com/toshiks/glTF-quicklook) - quicklook plugin for macos. Also SceneKit wrapper for tinygltf.
* [GlslViewer](https://github.com/patriciogonzalezvivo/glslViewer) - live GLSL coding for MacOS and Linux
* [Vulkan-Samples](https://github.com/KhronosGroup/Vulkan-Samples) - The Vulkan Samples is collection of resources to help you develop optimized Vulkan applications.
* [TDME2](https://github.com/andreasdr/tdme2) - TDME2 - ThreeDeeMiniEngine2 is a lightweight 3D engine including tools suited for 3D game development using C++11
* [SanityEngine](https://github.com/DethRaid/SanityEngine) - A C++/D3D12 renderer focused on the personal and professional development of its developer
* [Open3D](http://www.open3d.org/) - A Modern Library for 3D Data Processing
* [Supernova Engine](https://github.com/supernovaengine/supernova) - Game engine for 2D and 3D projects with Lua or C++ in data oriented design.
* Your projects here! (Please send PR)
## TODOs
* [ ] Robust URI decoding/encoding. https://github.com/syoyo/tinygltf/issues/369
* [ ] Mesh Compression/decompression(Open3DGC, etc)
* [x] Load Draco compressed mesh
* [ ] Save Draco compressed mesh
* [ ] Open3DGC?
* [x] Support `extensions` and `extras` property
* [ ] HDR image?
* [ ] OpenEXR extension through TinyEXR.
* [ ] 16bit PNG support in Serialization
* [ ] Write example and tests for `animation` and `skin`
### Optional
* [ ] Write C++ code generator which emits C++ code from JSON schema for robust parsing?
## Licenses
TinyGLTF is licensed under MIT license. See [LICENSE](LICENSE).
TinyGLTF is licensed under MIT license.
TinyGLTF v3 uses the following third party code:
TinyGLTF uses the following third party libraries.
* fast_float (JSON number parsing, in `tinygltf_json_c.h`): Copyright (c) 2021 The fast_float authors. Apache License 2.0 / MIT / Boost 1.0.
* dragonbox (JSON number serialization, in `tinygltf_json_c.h`): Copyright 2020-2024 Junekey Jeon. Apache 2.0 with LLVM exceptions / Boost 1.0.
* stb_image.h (optional, `TINYGLTF3_ENABLE_STB_IMAGE`) : public domain image loader - [Github link](https://github.com/nothings/stb/blob/master/stb_image.h)
* json.hpp : Copyright (c) 2013-2017 Niels Lohmann. MIT license.
* base64 : Copyright (C) 2004-2008 René Nyffenegger
* stb_image.h : v2.08 - public domain image loader - [Github link](https://github.com/nothings/stb/blob/master/stb_image.h)
* stb_image_write.h : v1.09 - public domain image writer - [Github link](https://github.com/nothings/stb/blob/master/stb_image_write.h)
## Build and example
Copy `stb_image.h`, `stb_image_write.h`, `json.hpp` and `tiny_gltf.h` to your project.
### Loading glTF 2.0 model
```c++
// Define these only in *one* .cc file.
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
// #define TINYGLTF_NOEXCEPTION // optional. disable exception handling.
#include "tiny_gltf.h"
using namespace tinygltf;
Model model;
TinyGLTF loader;
std::string err;
std::string warn;
bool ret = loader.LoadASCIIFromFile(&model, &err, &warn, argv[1]);
//bool ret = loader.LoadBinaryFromFile(&model, &err, &warn, argv[1]); // for binary glTF(.glb)
if (!warn.empty()) {
printf("Warn: %s\n", warn.c_str());
}
if (!err.empty()) {
printf("Err: %s\n", err.c_str());
}
if (!ret) {
printf("Failed to parse glTF\n");
return -1;
}
```
#### Loader options
* `TinyGLTF::SetPreserveimageChannels(bool onoff)`. `true` to preserve image channels as stored in image file for loaded image. `false` by default for backward compatibility(image channels are widen to `RGBA` 4 channels). Effective only when using builtin image loader(STB image loader).
## Compile options
* `TINYGLTF_NOEXCEPTION` : Disable C++ exception in JSON parsing. You can use `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION` and `TINYGLTF_NOEXCEPTION` to fully remove C++ exception codes when compiling TinyGLTF.
* `TINYGLTF_NO_STB_IMAGE` : Do not load images with stb_image. Instead use `TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data)` to set a callback for loading images.
* `TINYGLTF_NO_STB_IMAGE_WRITE` : Do not write images with stb_image_write. Instead use `TinyGLTF::SetImageWriter(WriteimageDataFunction WriteImageData, void *user_data)` to set a callback for writing images.
* `TINYGLTF_NO_EXTERNAL_IMAGE` : Do not try to load external image file. This option would be helpful if you do not want to load image files during glTF parsing.
* `TINYGLTF_ANDROID_LOAD_FROM_ASSETS`: Load all files from packaged app assets instead of the regular file system. **Note:** You must pass a valid asset manager from your android app to `tinygltf::asset_manager` beforehand.
* `TINYGLTF_ENABLE_DRACO`: Enable Draco compression. User must provide include path and link correspnding libraries in your project file.
* `TINYGLTF_NO_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.
* `TINYGLTF_NO_INCLUDE_RAPIDJSON `: Disable including RapidJson's header files from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.
* `TINYGLTF_NO_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.
* `TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.
* `TINYGLTF_USE_RAPIDJSON` : Use RapidJSON as a JSON parser/serializer. RapidJSON files are not included in TinyGLTF repo. Please set an include path to RapidJSON if you enable this feature.
* `TINYGLTF_USE_CPP14` : Use C++14 feature(requires C++14 compiler). This may give better performance than C++11.
### Wuffs image loader option(faster and secure JPEG/PNG deocoding)
You can use `wuffs` image loader to load JPEG and PNG in fast and securely.
(`stb_image` has some security issues, whereas `wuffs` is well fuzz tested)
Not that some uncommon JPEG format is unsupported in `wuffs` `std/jpeg` decoder.
* `TINYGLTF_USE_WUFFS_IMAGE_LOADER` : Use `wuffs` to load images. `stb_image` related stuff will be disabled.
* `TINYGLTF_NO_STB_IMAGE` supercedes `wuffs` macros. i.e. when `TINYGLTF_NO_STB_IMAGE` is defined, both `stb_image` and `wuffs` are disabled.
* `TINYGLTF_NO_WUFFS_IMPLEMENTATION` : Do not define `WUFFS_IMPLEMENTATION` inside `tiny_gltf.h`. Define this macro if you use `wuffs` in another C/C++ file.
## CMake options
You can add tinygltf using `add_subdirectory` feature.
If you add tinygltf to your project using `add_subdirectory`, it would be better to set `TINYGLTF_HEADER_ONLY` on(just add an include path to tinygltf) and `TINYGLTF_INSTALL` off(Which does not install tinygltf files).
```
// Your project's CMakeLists.txt
...
set(TINYGLTF_HEADER_ONLY ON CACHE INTERNAL "" FORCE)
set(TINYGLTF_INSTALL OFF CACHE INTERNAL "" FORCE)
add_subdirectory(/path/to/tinygltf)
```
### Saving gltTF 2.0 model
* Buffers.
* [x] To file
* [x] Embedded
* [ ] Draco compressed?
* [x] Images
* [x] To file
* [x] Embedded
* Binary(.glb)
* [x] .bin embedded single .glb
* [ ] External .bin
## Running tests.
### glTF parsing test
#### Setup
Python required.
Git clone https://github.com/KhronosGroup/glTF-Sample-Models to your local dir.
#### Run parsing test
After building `loader_example`, edit `test_runner.py`, then,
```bash
$ python test_runner.py
```
### Unit tests
```bash
$ cd tests
$ make
$ ./tester
$ ./tester_noexcept
```
### Fuzzing tests
See `tests/fuzzer` for details.
After running fuzzer on Ryzen9 3950X a week, at least `LoadASCIIFromString` looks safe except for out-of-memory error in Fuzzer.
We may be better to introduce bounded memory size checking when parsing glTF data.
## Third party licenses
* json.hpp : Licensed under the MIT License <http://opensource.org/licenses/MIT>. Copyright (c) 2013-2017 Niels Lohmann <http://nlohmann.me>.
* stb_image : Public domain.
* catch : Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. Distributed under the Boost Software License, Version 1.0.
* RapidJSON : Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. http://rapidjson.org/
* dlib(uridecode, uriencode) : Copyright (C) 2003 Davis E. King Boost Software License 1.0. http://dlib.net/dlib/server/server_http.cpp.html
+18
View File
@@ -0,0 +1,18 @@
version: 0.9.{build}
image:
- Visual Studio 2015
# scripts that runs after repo cloning.
install:
- vcsetup.bat
platform: x64
configuration: Release
build:
parallel: true
project: TinyGLTFSolution.sln
after_build:
- examples.bat
-13
View File
@@ -1,13 +0,0 @@
# Use this for strict compilation check(will work on clang 3.8+)
#EXTRA_CXXFLAGS := -fsanitize=address -Wall -Werror -Weverything -Wno-c++11-long-long -Wno-c++98-compat
# With draco
# EXTRA_CXXFLAGS := -I../draco/src/ -I../draco/build -DTINYGLTF_ENABLE_DRACO -L../draco/build
# EXTRA_LINKFLAGS := -L../draco/build/ -ldracodec -ldraco
all:
clang++ $(EXTRA_CXXFLAGS) -std=c++11 -g -O0 -o loader_example loader_example.cc $(EXTRA_LINKFLAGS)
lint:
deps/cpplint.py tiny_gltf.h
@@ -1,117 +0,0 @@
{
"scenes" : [
{
"nodes" : [ 0 ]
}
],
"nodes" : [
{
"mesh" : 0,
"rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
}
],
"animations": [
{
"samplers" : [
{
"input" : 2,
"interpolation" : "LINEAR",
"output" : 3
}
],
"channels" : [ {
"sampler" : 0,
"target" : {
"node" : 0,
"path" : "rotation"
}
} ]
}
],
"buffers" : [
{
"uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=",
"byteLength" : 44
},
{
"uri" : "data:application/octet-stream;base64,AAAAAAAAgD4AAAA/AABAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAPT9ND/0/TS/AAAAAAAAAAAAAAAAAACAPw==",
"byteLength" : 100
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 6,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 8,
"byteLength" : 36,
"target" : 34962
},
{
"buffer" : 1,
"byteOffset" : 0,
"byteLength" : 100
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 3,
"type" : "SCALAR",
"max" : [ 2 ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
},
{
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 5,
"type" : "SCALAR",
"max" : [ 1.0 ],
"min" : [ 0.0 ]
},
{
"bufferView" : 2,
"byteOffset" : 20,
"componentType" : 5126,
"count" : 5,
"type" : "VEC4",
"max" : [ 0.0, 0.0, 1.0, 1.0 ],
"min" : [ 0.0, 0.0, 0.0, -0.707 ]
}
],
"asset" : {
"version" : "2.0"
}
}
-47
View File
@@ -1,47 +0,0 @@
This software is available as a choice of the following licenses. Choose
whichever you prefer.
===============================================================================
ALTERNATIVE 1 - Public Domain (www.unlicense.org)
===============================================================================
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
===============================================================================
ALTERNATIVE 2 - MIT No Attribution
===============================================================================
Copyright 2020 David Reid
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-2
View File
@@ -1,2 +0,0 @@
all:
clang++ -O1 -g -I../../ main.cc
-3
View File
@@ -1,3 +0,0 @@
Simple example playing embedded audio data thorough OMI_audio_emitter.
Supported audio file: mp3
File diff suppressed because it is too large Load Diff
-67
View File
@@ -1,67 +0,0 @@
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "tiny_gltf.h"
#define DR_MP3_IMPLEMENTATION
#include "dr_mp3.h"
#include <iostream>
static std::string GetFilePathExtension(const std::string &FileName) {
if (FileName.find_last_of(".") != std::string::npos)
return FileName.substr(FileName.find_last_of(".") + 1);
return "";
}
int main(int argc, char **argv) {
if (argc < 2) {
std::cout << "gltf_audio input.gltf/.glb" << std::endl;
}
float scale = 1.0f;
if (argc > 2) {
scale = atof(argv[2]);
}
tinygltf::Model model;
tinygltf::TinyGLTF loader;
std::string err;
std::string warn;
#ifdef _WIN32
#ifdef _DEBUG
std::string input_filename(argv[1] ? argv[1]
: "../../../models/Cube/Cube.gltf");
#endif
#else
std::string input_filename(argv[1] ? argv[1] : "../../models/Cube/Cube.gltf");
#endif
std::string ext = GetFilePathExtension(input_filename);
bool ret = false;
if (ext.compare("glb") == 0) {
// assume binary glTF.
ret =
loader.LoadBinaryFromFile(&model, &err, &warn, input_filename.c_str());
} else {
// assume ascii glTF.
ret = loader.LoadASCIIFromFile(&model, &err, &warn, input_filename.c_str());
}
if (!warn.empty()) {
printf("Warn: %s\n", warn.c_str());
}
if (!err.empty()) {
printf("ERR: %s\n", err.c_str());
}
if (!ret) {
printf("Failed to load .glTF : %s\n", argv[1]);
exit(-1);
}
return EXIT_SUCCESS;
}
-61
View File
@@ -1,61 +0,0 @@
# GNU Make workspace makefile autogenerated by Premake
ifndef config
config=debug_native
endif
ifndef verbose
SILENT = @
endif
ifeq ($(config),debug_native)
basic_viewer_config = debug_native
endif
ifeq ($(config),debug_x64)
basic_viewer_config = debug_x64
endif
ifeq ($(config),debug_x32)
basic_viewer_config = debug_x32
endif
ifeq ($(config),release_native)
basic_viewer_config = release_native
endif
ifeq ($(config),release_x64)
basic_viewer_config = release_x64
endif
ifeq ($(config),release_x32)
basic_viewer_config = release_x32
endif
PROJECTS := basic_viewer
.PHONY: all clean help $(PROJECTS)
all: $(PROJECTS)
basic_viewer:
ifneq (,$(basic_viewer_config))
@echo "==== Building basic_viewer ($(basic_viewer_config)) ===="
@${MAKE} --no-print-directory -C . -f basic_viewer.make config=$(basic_viewer_config)
endif
clean:
@${MAKE} --no-print-directory -C . -f basic_viewer.make clean
help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " debug_native"
@echo " debug_x64"
@echo " debug_x32"
@echo " release_native"
@echo " release_x64"
@echo " release_x32"
@echo ""
@echo "TARGETS:"
@echo " all (default)"
@echo " clean"
@echo " basic_viewer"
@echo ""
@echo "For more information, see https://github.com/premake/premake-core/wiki"
-250
View File
@@ -1,250 +0,0 @@
# GNU Make project makefile autogenerated by Premake
ifndef config
config=debug_native
endif
ifndef verbose
SILENT = @
endif
.PHONY: clean prebuild prelink
ifeq ($(config),debug_native)
RESCOMP = windres
TARGETDIR = bin/native/Debug
TARGET = $(TARGETDIR)/basic_viewer
OBJDIR = obj/native/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../.. -I../common/glm
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra -fsanitize=address
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra -std=c++11 -fsanitize=address
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -fsanitize=address `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),debug_x64)
RESCOMP = windres
TARGETDIR = bin/x64/Debug
TARGET = $(TARGETDIR)/basic_viewer
OBJDIR = obj/x64/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../.. -I../common/glm
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra -fsanitize=address
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra -std=c++11 -fsanitize=address
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -fsanitize=address `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),debug_x32)
RESCOMP = windres
TARGETDIR = bin/x32/Debug
TARGET = $(TARGETDIR)/basic_viewer
OBJDIR = obj/x32/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../.. -I../common/glm
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra -fsanitize=address
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra -std=c++11 -fsanitize=address
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 -fsanitize=address `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_native)
RESCOMP = windres
TARGETDIR = bin/native/Release
TARGET = $(TARGETDIR)/basic_viewer
OBJDIR = obj/native/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../.. -I../common/glm
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra -fsanitize=address
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra -std=c++11 -fsanitize=address
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -s -fsanitize=address `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_x64)
RESCOMP = windres
TARGETDIR = bin/x64/Release
TARGET = $(TARGETDIR)/basic_viewer
OBJDIR = obj/x64/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../.. -I../common/glm
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra -fsanitize=address
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra -std=c++11 -fsanitize=address
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -s -fsanitize=address `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_x32)
RESCOMP = windres
TARGETDIR = bin/x32/Release
TARGET = $(TARGETDIR)/basic_viewer
OBJDIR = obj/x32/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../.. -I../common/glm
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra -fsanitize=address
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra -std=c++11 -fsanitize=address
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 -s -fsanitize=address `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
OBJECTS := \
$(OBJDIR)/main.o \
$(OBJDIR)/shaders.o \
$(OBJDIR)/window.o \
RESOURCES := \
CUSTOMFILES := \
SHELLTYPE := posix
ifeq (.exe,$(findstring .exe,$(ComSpec)))
SHELLTYPE := msdos
endif
$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR)
@echo Linking basic_viewer
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
$(CUSTOMFILES): | $(OBJDIR)
$(TARGETDIR):
@echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif
$(OBJDIR):
@echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
clean:
@echo Cleaning basic_viewer
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(TARGET)
$(SILENT) rm -rf $(OBJDIR)
else
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
endif
prebuild:
$(PREBUILDCMDS)
prelink:
$(PRELINKCMDS)
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif
$(OBJDIR)/main.o: main.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/shaders.o: shaders.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/window.o: window.cpp
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
-include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH))
-include $(OBJDIR)/$(notdir $(PCH)).d
endif
-152
View File
@@ -1,152 +0,0 @@
{
"asset" : {
"generator" : "Khronos glTF Blender I/O v1.1.46",
"version" : "2.0"
},
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0,
1,
2
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
},
{
"name" : "Light",
"rotation" : [
0.16907575726509094,
0.7558803558349609,
-0.27217137813568115,
0.570947527885437
],
"translation" : [
4.076245307922363,
5.903861999511719,
-1.0054539442062378
]
},
{
"name" : "Camera",
"rotation" : [
0.483536034822464,
0.33687159419059753,
-0.20870360732078552,
0.7804827094078064
],
"translation" : [
7.358891487121582,
4.958309173583984,
6.925790786743164
]
}
],
"materials" : [
{
"doubleSided" : true,
"emissiveFactor" : [
0,
0,
0
],
"name" : "Material",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.800000011920929,
0.800000011920929,
0.800000011920929,
1
],
"metallicFactor" : 0,
"roughnessFactor" : 0.4000000059604645
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"POSITION" : 0,
"NORMAL" : 1,
"TEXCOORD_0" : 2
},
"indices" : 3,
"material" : 0
}
]
}
],
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 3,
"componentType" : 5123,
"count" : 36,
"type" : "SCALAR"
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 0
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 288
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 576
},
{
"buffer" : 0,
"byteLength" : 72,
"byteOffset" : 768
}
],
"buffers" : [
{
"byteLength" : 840,
"uri" : "data:application/octet-stream;base64,AACAPwAAgD8AAIA/AACAPwAAgD8AAIC/AACAvwAAgD8AAIC/AACAvwAAgD8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAvwAAgD8AAIC/AACAvwAAgL8AAIC/AACAvwAAgL8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAvwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAPwAAgL8AAIA/AACAPwAAgL8AAIC/AACAPwAAgD8AAIC/AACAPwAAgD8AAIC/AACAPwAAgL8AAIC/AACAvwAAgL8AAIC/AACAvwAAgD8AAIC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAgPwAAgD4AACA/AAAAPwAAYD8AAAA/AABgPwAAgD4AACA/AAAAAAAAwD4AAAAAAADAPgAAgD4AACA/AACAPgAAID8AAEA/AADAPgAAQD8AAMA+AACAPwAAID8AAIA/AAAAPgAAgD4AAAA+AAAAPwAAwD4AAAA/AADAPgAAgD4AACA/AACAPgAAwD4AAIA+AADAPgAAAD8AACA/AAAAPwAAID8AAAA/AADAPgAAAD8AAMA+AABAPwAAID8AAEA/AAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcA"
}
]
}
-5
View File
@@ -1,5 +0,0 @@
include_directories(${CMAKE_SOURCE_DIR})
add_executable(create_triangle_gltf create_triangle_gltf.cpp)
target_compile_options(create_triangle_gltf PUBLIC -Wall)
target_link_libraries(create_triangle_gltf )
@@ -1,129 +0,0 @@
// An example of how to generate a gltf file from scratch. This example
// was translated from the pygltlib documentation in the pypi project page,
// which in turn is based on the Khronos Sample Models at:
//
// https://github.com/KhronosGroup/glTF-Sample-Models
//
// This example is released under the MIT license.
//
// 2021-02-25 Thu
// Dov Grobgeld <dov.grobgeld@gmail.com>
// Define these only in *one* .cc file.
#define TINYGLTF_IMPLEMENTATION
#define TINYGLTF_USE_RAPIDJSON
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
// #define TINYGLTF_NOEXCEPTION // optional. disable exception handling.
#include "tiny_gltf.h"
int main(int argc, char **argv)
{
// Create a model with a single mesh and save it as a gltf file
tinygltf::Model m;
tinygltf::Scene scene;
tinygltf::Mesh mesh;
tinygltf::Primitive primitive;
tinygltf::Node node;
tinygltf::Buffer buffer;
tinygltf::BufferView bufferView1;
tinygltf::BufferView bufferView2;
tinygltf::Accessor accessor1;
tinygltf::Accessor accessor2;
tinygltf::Asset asset;
// This is the raw data buffer.
buffer.data = {
// 6 bytes of indices and two bytes of padding
0x00,0x00,0x01,0x00,0x02,0x00,0x00,0x00,
// 36 bytes of floating point numbers
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3f,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3f,
0x00,0x00,0x00,0x00};
// "The indices of the vertices (ELEMENT_ARRAY_BUFFER) take up 6 bytes in the
// start of the buffer.
bufferView1.buffer = 0;
bufferView1.byteOffset=0;
bufferView1.byteLength=6;
bufferView1.target = TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER;
// The vertices take up 36 bytes (3 vertices * 3 floating points * 4 bytes)
// at position 8 in the buffer and are of type ARRAY_BUFFER
bufferView2.buffer = 0;
bufferView2.byteOffset=8;
bufferView2.byteLength=36;
bufferView2.target = TINYGLTF_TARGET_ARRAY_BUFFER;
// Describe the layout of bufferView1, the indices of the vertices
accessor1.bufferView = 0;
accessor1.byteOffset = 0;
accessor1.componentType = TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT;
accessor1.count = 3;
accessor1.type = TINYGLTF_TYPE_SCALAR;
accessor1.maxValues.push_back(2);
accessor1.minValues.push_back(0);
// Describe the layout of bufferView2, the vertices themself
accessor2.bufferView = 1;
accessor2.byteOffset = 0;
accessor2.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
accessor2.count = 3;
accessor2.type = TINYGLTF_TYPE_VEC3;
accessor2.maxValues = {1.0, 1.0, 0.0};
accessor2.minValues = {0.0, 0.0, 0.0};
// Build the mesh primitive and add it to the mesh
primitive.indices = 0; // The index of the accessor for the vertex indices
primitive.attributes["POSITION"] = 1; // The index of the accessor for positions
primitive.material = 0;
primitive.mode = TINYGLTF_MODE_TRIANGLES;
mesh.primitives.push_back(primitive);
// Other tie ups
node.mesh = 0;
scene.nodes.push_back(0); // Default scene
// Define the asset. The version is required
asset.version = "2.0";
asset.generator = "tinygltf";
// Now all that remains is to tie back all the loose objects into the
// our single model.
m.scenes.push_back(scene);
m.meshes.push_back(mesh);
m.nodes.push_back(node);
m.buffers.push_back(buffer);
m.bufferViews.push_back(bufferView1);
m.bufferViews.push_back(bufferView2);
m.accessors.push_back(accessor1);
m.accessors.push_back(accessor2);
m.asset = asset;
// Create a simple material
tinygltf::Material mat;
mat.pbrMetallicRoughness.baseColorFactor = {1.0f, 0.9f, 0.9f, 1.0f};
mat.doubleSided = true;
m.materials.push_back(mat);
// lights
tinygltf::Light dummyLight;
dummyLight.name = "bora";
m.lights.push_back(dummyLight);
tinygltf::Value dummyVal(3.14);
m.extensions.emplace("ext1", dummyVal);
// Save it to a file
tinygltf::TinyGLTF gltf;
gltf.WriteGltfSceneToFile(&m, "triangle.gltf",
true, // embedImages
true, // embedBuffers
true, // pretty print
false); // write binary
exit(0);
}
Binary file not shown.
-94
View File
@@ -1,94 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5123,
"count": 3,
"max": [
2
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 3,
"max": [
1.0,
1.0,
0.0
],
"min": [
0.0,
0.0,
0.0
],
"type": "VEC3"
}
],
"asset": {
"generator": "tinygltf",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 6,
"target": 34963
},
{
"buffer": 0,
"byteLength": 36,
"byteOffset": 8,
"target": 34962
}
],
"buffers": [
{
"byteLength": 44,
"uri": "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA="
}
],
"materials": [
{
"doubleSided": true,
"pbrMetallicRoughness": {
"baseColorFactor": [
1.0,
0.8999999761581421,
0.8999999761581421,
1.0
]
}
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"POSITION": 1
},
"indices": 0,
"material": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0
}
],
"scenes": [
{
"nodes": [
0
]
}
]
}
-61
View File
@@ -1,61 +0,0 @@
# GNU Make workspace makefile autogenerated by Premake
ifndef config
config=debug_native
endif
ifndef verbose
SILENT = @
endif
ifeq ($(config),debug_native)
glview_config = debug_native
endif
ifeq ($(config),debug_x64)
glview_config = debug_x64
endif
ifeq ($(config),debug_x32)
glview_config = debug_x32
endif
ifeq ($(config),release_native)
glview_config = release_native
endif
ifeq ($(config),release_x64)
glview_config = release_x64
endif
ifeq ($(config),release_x32)
glview_config = release_x32
endif
PROJECTS := glview
.PHONY: all clean help $(PROJECTS)
all: $(PROJECTS)
glview:
ifneq (,$(glview_config))
@echo "==== Building glview ($(glview_config)) ===="
@${MAKE} --no-print-directory -C . -f glview.make config=$(glview_config)
endif
clean:
@${MAKE} --no-print-directory -C . -f glview.make clean
help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " debug_native"
@echo " debug_x64"
@echo " debug_x32"
@echo " release_native"
@echo " release_x64"
@echo " release_x32"
@echo ""
@echo "TARGETS:"
@echo " all (default)"
@echo " clean"
@echo " glview"
@echo ""
@echo "For more information, see https://github.com/premake/premake-core/wiki"
-246
View File
@@ -1,246 +0,0 @@
# GNU Make project makefile autogenerated by Premake
ifndef config
config=debug_native
endif
ifndef verbose
SILENT = @
endif
.PHONY: clean prebuild prelink
ifeq ($(config),debug_native)
RESCOMP = windres
TARGETDIR = bin/native/Debug
TARGET = $(TARGETDIR)/glview
OBJDIR = obj/native/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../.. -I../common
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),debug_x64)
RESCOMP = windres
TARGETDIR = bin/x64/Debug
TARGET = $(TARGETDIR)/glview
OBJDIR = obj/x64/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../.. -I../common
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),debug_x32)
RESCOMP = windres
TARGETDIR = bin/x32/Debug
TARGET = $(TARGETDIR)/glview
OBJDIR = obj/x32/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../.. -I../common
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_native)
RESCOMP = windres
TARGETDIR = bin/native/Release
TARGET = $(TARGETDIR)/glview
OBJDIR = obj/native/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../.. -I../common
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -s `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_x64)
RESCOMP = windres
TARGETDIR = bin/x64/Release
TARGET = $(TARGETDIR)/glview
OBJDIR = obj/x64/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../.. -I../common
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -s `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_x32)
RESCOMP = windres
TARGETDIR = bin/x32/Release
TARGET = $(TARGETDIR)/glview
OBJDIR = obj/x32/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../.. -I../common
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 -s `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
OBJECTS := \
$(OBJDIR)/trackball.o \
$(OBJDIR)/glview.o \
RESOURCES := \
CUSTOMFILES := \
SHELLTYPE := posix
ifeq (.exe,$(findstring .exe,$(ComSpec)))
SHELLTYPE := msdos
endif
$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR)
@echo Linking glview
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
$(CUSTOMFILES): | $(OBJDIR)
$(TARGETDIR):
@echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif
$(OBJDIR):
@echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
clean:
@echo Cleaning glview
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(TARGET)
$(SILENT) rm -rf $(OBJDIR)
else
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
endif
prebuild:
$(PREBUILDCMDS)
prelink:
$(PRELINKCMDS)
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif
$(OBJDIR)/trackball.o: ../common/trackball.cc
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/glview.o: glview.cc
@echo $(notdir $<)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
-include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH))
-include $(OBJDIR)/$(notdir $(PCH)).d
endif
-12
View File
@@ -1,12 +0,0 @@
Jsonnet representation of glTF
https://jsonnet.org/
# Benefit
You can assign id programatically
```
{
```
@@ -1,11 +0,0 @@
newmtl hairSG
Ka 0.000000 0.000000 0.000000
Kd 0.000000 0.000000 0.000000
Ks 0.000000 0.000000 0.000000
Kt 1.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ns 1.000000
Ni 1.000000
illum 4
map_Kd color.png
-102
View File
@@ -1,102 +0,0 @@
newmtl _blinn1SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl blinn1SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd skin_dif.tif
Ni 1.00
Ks 0.28 0.28 0.28
newmtl eyeMTLSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl eyebrows_hairTubeShader2SG1
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl eyelushes_hairTubeShader3SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl face_eye_mouth_blinn2SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd HWI_male_gum_dif.jpg
Ni 1.00
Ks 0.50 0.50 0.50
newmtl hairFrontHair_hairTubeShader1SG1
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl hairMainHair_hairTubeShader1SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl hairStrayHair_hairTubeShader1SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl hairTopFix_hairTubeShader1SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl hairTopFix_surfaceShader13SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl initialShadingGroup
illum 4
Kd 0.37 0.37 0.37
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
newmtl irisMTLSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl skinSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd skin_dif.tif
Ni 1.00
Ks 0.14 0.14 0.14
newmtl teethMTLSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
newmtl tongueMTLSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 0.00
File diff suppressed because it is too large Load Diff
@@ -1,11 +0,0 @@
{
"sim": {
"version": 1,
"id": "sim",
"name": "1",
"kind": "Puppeteer",
"mood": null,
"postPlaybackMood": null,
"duration": 3.75
}
}
File diff suppressed because it is too large Load Diff
@@ -1,11 +0,0 @@
{
"lowpoly": {
"version": 1,
"id": "lowpoly",
"name": "1",
"kind": "Puppeteer",
"mood": null,
"postPlaybackMood": null,
"duration": 62.5
}
}
File diff suppressed because it is too large Load Diff
-128
View File
@@ -1,128 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5125,
"count": 11532,
"max": [
11531.0
],
"min": [
0.0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 11532,
"max": [
14679.0,
1.0,
9728.0
],
"min": [
14678.0,
0.0,
9216.0
],
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 11532,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 11532,
"max": [
0.96875,
0.96875
],
"min": [
0.03125,
0.03125
],
"type": "VEC2"
}
],
"asset": {
"generator": "mesh-modify",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 46128,
"target": 34963
},
{
"buffer": 0,
"byteLength": 138384,
"byteOffset": 46128,
"target": 34962
},
{
"buffer": 0,
"byteLength": 138384,
"byteOffset": 184512,
"target": 34962
},
{
"buffer": 0,
"byteLength": 92256,
"byteOffset": 322896,
"target": 34962
}
],
"buffers": [
{
"byteLength": 415152,
"name": "bufffer0",
"uri": "output.bin"
}
],
"meshes": [
{
"name": "r.28.18.obj",
"primitives": [
{
"attributes": {
"NORMAL": 2,
"POSITION": 1,
"TEXCOORD_0": 3
},
"indices": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0,
"name": "mesh"
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
]
}
-185
View File
@@ -1,185 +0,0 @@
{
"asset": {
"copyright": "(C)2020 syoyo",
"generator": "maya2glTF master d293e09",
"version": "2.0"
},
"scenes": [
{
"nodes": [
0
]
}
],
"scene": 0,
"nodes": [
{
"name": "pPlane1",
"mesh": 0
}
],
"meshes": [
{
"name": "pPlaneShape1",
"extras": {
"targetNames": []
},
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 2,
"TANGENT": 3,
"TEXCOORD_0": 4
},
"indices": 0,
"mode": 4,
"material": 0
}
]
}
],
"materials": [
{
"name": "lambert1",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.4000000059604645,
0.4000000059604645,
0.4000000059604645,
1.0
],
"metallicFactor": 0.0,
"roughnessFactor": 1.0
}
}
],
"accessors": [
{
"name": "pPlaneShape1#0/indices",
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 24,
"max": [
8
],
"min": [
0
],
"type": "SCALAR"
},
{
"name": "pPlaneShape1#0/vertices/NORMAL",
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 9,
"max": [
0.0,
1.0,
0.0
],
"min": [
0.0,
1.0,
0.0
],
"type": "VEC3"
},
{
"name": "pPlaneShape1#0/vertices/POSITION",
"bufferView": 1,
"byteOffset": 108,
"componentType": 5126,
"count": 9,
"max": [
0.5,
0.0,
0.5
],
"min": [
-0.5,
0.0,
-0.5
],
"type": "VEC3"
},
{
"name": "pPlaneShape1#0/vertices/TANGENT",
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 9,
"max": [
1.0,
0.0,
0.0,
1.0
],
"min": [
1.0,
0.0,
0.0,
1.0
],
"type": "VEC4"
},
{
"name": "pPlaneShape1#0/vertices/TEXCOORD_0",
"bufferView": 3,
"byteOffset": 0,
"componentType": 5126,
"count": 9,
"max": [
1.0,
1.0
],
"min": [
0.0,
0.0
],
"type": "VEC2"
}
],
"bufferViews": [
{
"name": "plane/data/indices-2",
"buffer": 0,
"byteOffset": 432,
"byteLength": 48,
"target": 34963
},
{
"name": "plane/data/vertices-12",
"buffer": 0,
"byteOffset": 144,
"byteLength": 216,
"byteStride": 12,
"target": 34962
},
{
"name": "plane/data/vertices-16",
"buffer": 0,
"byteOffset": 0,
"byteLength": 144,
"byteStride": 16,
"target": 34962
},
{
"name": "plane/data/vertices-8",
"buffer": 0,
"byteOffset": 360,
"byteLength": 72,
"byteStride": 8,
"target": 34962
}
],
"buffers": [
{
"name": "plane/data",
"byteLength": 480,
"uri": "plane0.bin"
}
]
}
Binary file not shown.
-7
View File
@@ -1,7 +0,0 @@
#!/bin/bash
./mesh-conv --op gltf2obj -i ../hairsimtest/sim.gltf
#./mesh-conv --op obj2gltf --verbose -i hair_bfShape_0.obj
./mesh-conv --op obj2gltf -i hair_bfShape_1.obj -o hair_bfShape_1.gltf
@@ -1,224 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 36,
"max": [
35
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
1,
1.000001
],
"min": [
-1,
-1,
-1
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
1,
1
],
"min": [
-1,
-1,
-1
],
"type": "VEC3"
},
{
"bufferView": 3,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
-0,
-0,
1
],
"min": [
0,
-0,
-1,
-1
],
"type": "VEC4"
},
{
"bufferView": 4,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
1
],
"min": [
-1,
-1
],
"type": "VEC2"
}
],
"asset": {
"generator": "VKTS glTF 2.0 exporter",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 72,
"byteOffset": 0,
"target": 34963
},
{
"buffer": 0,
"byteLength": 432,
"byteOffset": 72,
"target": 34962
},
{
"buffer": 0,
"byteLength": 432,
"byteOffset": 504,
"target": 34962
},
{
"buffer": 0,
"byteLength": 576,
"byteOffset": 936,
"target": 34962
},
{
"buffer": 0,
"byteLength": 288,
"byteOffset": 1512,
"target": 34962
}
],
"buffers": [
{
"byteLength": 1800,
"uri": "Cube.bin"
}
],
"images": [
{
"0comment": "Use Cube_MetallicRoughness.png to reduce scene filesize",
"uri": "Cube_MetallicRoughness.png"
},
{
"uri": "Cube_MetallicRoughness.png"
}
],
"materials": [
{
"emissiveTexture": {
"index": 0,
"extensions": {
"KHR_texture_transform": {
"offset": [
0,
1
],
"scale": [
1,
-1
]
}
}
}
},
{
"name": "Cube",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicRoughnessTexture": {
"index": 1,
"extensions": {
"KHR_texture_transform": {
"offset": [
0,
1
],
"rotation": 1.57079632679,
"scale": [
0.5,
0.5
]
}
}
}
}
}
],
"meshes": [
{
"name": "Cube",
"primitives": [
{
"attributes": {
"NORMAL": 2,
"POSITION": 1,
"TANGENT": 3,
"TEXCOORD_0": 4
},
"indices": 0,
"material": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0,
"name": "Cube"
}
],
"samplers": [
{}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"textures": [
{
"sampler": 0,
"source": 0
},
{
"sampler": 0,
"source": 1
}
]
}
@@ -1,224 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 36,
"max": [
35
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
1,
1.000001
],
"min": [
-1,
-1,
-1
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
1,
1
],
"min": [
-1,
-1,
-1
],
"type": "VEC3"
},
{
"bufferView": 3,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
-0,
-0,
1
],
"min": [
0,
-0,
-1,
-1
],
"type": "VEC4"
},
{
"bufferView": 4,
"byteOffset": 0,
"componentType": 5126,
"count": 36,
"max": [
1,
1
],
"min": [
-1,
-1
],
"type": "VEC2"
}
],
"asset": {
"generator": "VKTS glTF 2.0 exporter",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 72,
"byteOffset": 0,
"target": 34963
},
{
"buffer": 0,
"byteLength": 432,
"byteOffset": 72,
"target": 34962
},
{
"buffer": 0,
"byteLength": 432,
"byteOffset": 504,
"target": 34962
},
{
"buffer": 0,
"byteLength": 576,
"byteOffset": 936,
"target": 34962
},
{
"buffer": 0,
"byteLength": 288,
"byteOffset": 1512,
"target": 34962
}
],
"buffers": [
{
"byteLength": 1800,
"uri": "Cube.bin"
}
],
"images": [
{
"0comment": "Use Cube_MetallicRoughness.png to reduce scene filesize",
"uri": "Cube_MetallicRoughness.png"
},
{
"uri": "Cube_MetallicRoughness.png"
}
],
"materials": [
{
"emissiveTexture": {
"index": 0,
"extensions": {
"KHR_texture_transform": {
"offset": [
0,
1
],
"scale": [
1,
-1
]
}
}
}
},
{
"name": "Cube",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicRoughnessTexture": {
"index": 1,
"extensions": {
"KHR_texture_transform": {
"offset": [
0,
1
],
"rotation": 1.57079632679,
"scale": [
0.5,
0.5
]
}
}
}
}
}
],
"meshes": [
{
"name": "Cube",
"primitives": [
{
"attributes": {
"NORMAL": 2,
"POSITION": 1,
"TANGENT": 3,
"TEXCOORD_0": 4
},
"indices": 0,
"material": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0,
"name": "Cube"
}
],
"samplers": [
{}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"textures": [
{
"sampler": 0,
"source": 0
},
{
"sampler": 0,
"source": 1
}
]
}
@@ -1,3 +0,0 @@
all:
python concat_mesh.py hair_bfShape_1.gltf hair_bfShape_0.gltf sim.gltf merged-sim.gltf
# python replace_attrib.py merged-sim.gltf replaced.gltf "added/hair_bfShape_1.obj" "hair_bfShape" 0 1
File diff suppressed because it is too large Load Diff
@@ -1,288 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5125,
"count": 79434,
"max": [
28135.0
],
"min": [
0.0
],
"name": "hair_bfShape_1.obj#0/indices",
"type": "SCALAR"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 28136,
"max": [
11.10669994354248,
170.1320037841797,
7.035999774932861
],
"min": [
-11.581600189208984,
142.8719940185547,
-15.023500442504883
],
"name": "hair_bfShape_1.obj#0/POSITION",
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 28136,
"max": [
0.9999430179595947,
0.9999679923057556,
0.9999390244483948
],
"min": [
-0.9997580051422119,
-0.8950620293617249,
-0.9999200105667114
],
"name": "hair_bfShape_1.obj#0/NORMAL",
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 28136,
"max": [
0.889851987361908,
0.998104989528656
],
"min": [
0.0014202300226315856,
-0.0010660899570211768
],
"name": "hair_bfShape_1.obj#0/TEXCOORD_0",
"type": "VEC2"
},
{
"bufferView": 4,
"componentType": 5123,
"count": 28136,
"max": [
97.0,
97.0,
94.0,
93.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/JOINTS_0",
"type": "VEC4"
},
{
"bufferView": 5,
"componentType": 5123,
"count": 28136,
"max": [
93.0,
93.0,
92.0,
92.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/JOINTS_1",
"type": "VEC4"
},
{
"bufferView": 6,
"componentType": 5123,
"count": 28136,
"max": [
91.0,
0.0,
0.0,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/JOINTS_2",
"type": "VEC4"
},
{
"bufferView": 7,
"componentType": 5126,
"count": 28136,
"max": [
1.0,
0.5,
0.3330000042915344,
0.24390600621700287
],
"min": [
0.2014250010251999,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/WEIGHTS_0",
"type": "VEC4"
},
{
"bufferView": 8,
"componentType": 5126,
"count": 28136,
"max": [
0.18594099581241608,
0.11678200215101242,
0.10268200188875198,
0.03563150018453598
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/WEIGHTS_1",
"type": "VEC4"
},
{
"bufferView": 9,
"componentType": 5126,
"count": 28136,
"max": [
0.001464050030335784,
0.0,
0.0,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/WEIGHTS_2",
"type": "VEC4"
}
],
"asset": {
"generator": "mesh-modify",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 317736,
"target": 34963
},
{
"buffer": 0,
"byteLength": 337632,
"byteOffset": 317736,
"target": 34962
},
{
"buffer": 0,
"byteLength": 337632,
"byteOffset": 655368,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 993000,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 1218088,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 1443176,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 1668264,
"target": 34962
},
{
"buffer": 0,
"byteLength": 450176,
"byteOffset": 1893352,
"target": 34962
},
{
"buffer": 0,
"byteLength": 450176,
"byteOffset": 2343528,
"target": 34962
},
{
"buffer": 0,
"byteLength": 450176,
"byteOffset": 2793704,
"target": 34962
}
],
"buffers": [
{
"byteLength": 3243880,
"name": "bufffer0",
"uri": "hair_bfShape_1.bin"
}
],
"meshes": [
{
"name": "hair_bfShape_1.obj",
"primitives": [
{
"attributes": {
"JOINTS_0": 4,
"JOINTS_1": 5,
"JOINTS_2": 6,
"NORMAL": 2,
"POSITION": 1,
"TEXCOORD_0": 3,
"WEIGHTS_0": 7,
"WEIGHTS_1": 8,
"WEIGHTS_2": 9
},
"indices": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0,
"name": "mesh"
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
]
}
@@ -1,288 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5125,
"count": 79434,
"max": [
28135.0
],
"min": [
0.0
],
"name": "hair_bfShape_1.obj#0/indices",
"type": "SCALAR"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 28136,
"max": [
11.10669994354248,
170.1320037841797,
7.035999774932861
],
"min": [
-11.581600189208984,
142.8719940185547,
-15.023500442504883
],
"name": "hair_bfShape_1.obj#0/POSITION",
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 28136,
"max": [
0.9999430179595947,
0.9999679923057556,
0.9999390244483948
],
"min": [
-0.9997580051422119,
-0.8950620293617249,
-0.9999200105667114
],
"name": "hair_bfShape_1.obj#0/NORMAL",
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 28136,
"max": [
0.889851987361908,
0.998104989528656
],
"min": [
0.0014202300226315856,
-0.0010660899570211768
],
"name": "hair_bfShape_1.obj#0/TEXCOORD_0",
"type": "VEC2"
},
{
"bufferView": 4,
"componentType": 5123,
"count": 28136,
"max": [
97.0,
97.0,
94.0,
93.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/JOINTS_0",
"type": "VEC4"
},
{
"bufferView": 5,
"componentType": 5123,
"count": 28136,
"max": [
93.0,
93.0,
92.0,
92.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/JOINTS_1",
"type": "VEC4"
},
{
"bufferView": 6,
"componentType": 5123,
"count": 28136,
"max": [
91.0,
0.0,
0.0,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/JOINTS_2",
"type": "VEC4"
},
{
"bufferView": 7,
"componentType": 5126,
"count": 28136,
"max": [
1.0,
0.5,
0.3330000042915344,
0.24390600621700287
],
"min": [
0.2014250010251999,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/WEIGHTS_0",
"type": "VEC4"
},
{
"bufferView": 8,
"componentType": 5126,
"count": 28136,
"max": [
0.18594099581241608,
0.11678200215101242,
0.10268200188875198,
0.03563150018453598
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/WEIGHTS_1",
"type": "VEC4"
},
{
"bufferView": 9,
"componentType": 5126,
"count": 28136,
"max": [
0.001464050030335784,
0.0,
0.0,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"name": "hair_bfShape_1.obj#0/WEIGHTS_2",
"type": "VEC4"
}
],
"asset": {
"generator": "mesh-modify",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 317736,
"target": 34963
},
{
"buffer": 0,
"byteLength": 337632,
"byteOffset": 317736,
"target": 34962
},
{
"buffer": 0,
"byteLength": 337632,
"byteOffset": 655368,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 993000,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 1218088,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 1443176,
"target": 34962
},
{
"buffer": 0,
"byteLength": 225088,
"byteOffset": 1668264,
"target": 34962
},
{
"buffer": 0,
"byteLength": 450176,
"byteOffset": 1893352,
"target": 34962
},
{
"buffer": 0,
"byteLength": 450176,
"byteOffset": 2343528,
"target": 34962
},
{
"buffer": 0,
"byteLength": 450176,
"byteOffset": 2793704,
"target": 34962
}
],
"buffers": [
{
"byteLength": 3243880,
"name": "bufffer0",
"uri": "hair_bfShape_1.bin"
}
],
"meshes": [
{
"name": "hair_bfShape_1.obj",
"primitives": [
{
"attributes": {
"JOINTS_0": 4,
"JOINTS_1": 5,
"JOINTS_2": 6,
"NORMAL": 2,
"POSITION": 1,
"TEXCOORD_0": 3,
"WEIGHTS_0": 7,
"WEIGHTS_1": 8,
"WEIGHTS_2": 9
},
"indices": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0,
"name": "mesh"
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
]
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-278
View File
@@ -1,278 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5125,
"count": 120,
"max": [
41.0
],
"min": [
0.0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 42,
"max": [
7.569169998168945,
158.69000244140625,
0.8566960096359253
],
"min": [
6.6432600021362305,
151.98899841308594,
-3.55295991897583
],
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 42,
"max": [
0.980184018611908,
0.3233279883861542,
0.4895069897174835
],
"min": [
0.8707389831542969,
-0.3086549937725067,
-0.2010059952735901
],
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 42,
"max": [
0.7207019925117493,
0.8640819787979126
],
"min": [
0.7156370282173157,
0.8067020177841187
],
"type": "VEC2"
},
{
"bufferView": 4,
"componentType": 5123,
"count": 42,
"max": [
0.0,
74.0,
73.0,
75.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"type": "VEC4"
},
{
"bufferView": 5,
"componentType": 5123,
"count": 42,
"max": [
68.0,
78.0,
70.0,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"type": "VEC4"
},
{
"bufferView": 6,
"componentType": 5123,
"count": 42,
"max": [
0.0,
0.0,
0.0,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"type": "VEC4"
},
{
"bufferView": 7,
"componentType": 5126,
"count": 42,
"max": [
1.0,
0.02313319966197014,
0.01985890045762062,
0.005621309857815504
],
"min": [
0.9537339806556702,
0.0,
0.0,
0.0
],
"type": "VEC4"
},
{
"bufferView": 8,
"componentType": 5126,
"count": 42,
"max": [
0.0003756110090762377,
0.0002766030083876103,
2.8980000479350565e-06,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"type": "VEC4"
},
{
"bufferView": 9,
"componentType": 5126,
"count": 42,
"max": [
0.0,
0.0,
0.0,
0.0
],
"min": [
0.0,
0.0,
0.0,
0.0
],
"type": "VEC4"
}
],
"asset": {
"generator": "mesh-modify",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 480,
"target": 34963
},
{
"buffer": 0,
"byteLength": 504,
"byteOffset": 480,
"target": 34962
},
{
"buffer": 0,
"byteLength": 504,
"byteOffset": 984,
"target": 34962
},
{
"buffer": 0,
"byteLength": 336,
"byteOffset": 1488,
"target": 34962
},
{
"buffer": 0,
"byteLength": 336,
"byteOffset": 1824,
"target": 34962
},
{
"buffer": 0,
"byteLength": 336,
"byteOffset": 2160,
"target": 34962
},
{
"buffer": 0,
"byteLength": 336,
"byteOffset": 2496,
"target": 34962
},
{
"buffer": 0,
"byteLength": 672,
"byteOffset": 2832,
"target": 34962
},
{
"buffer": 0,
"byteLength": 672,
"byteOffset": 3504,
"target": 34962
},
{
"buffer": 0,
"byteLength": 672,
"byteOffset": 4176,
"target": 34962
}
],
"buffers": [
{
"byteLength": 4848,
"name": "bufffer0",
"uri": "output.bin"
}
],
"meshes": [
{
"name": "hair_bfShape_0.obj",
"primitives": [
{
"attributes": {
"JOINTS_0": 4,
"JOINTS_1": 5,
"JOINTS_2": 6,
"NORMAL": 2,
"POSITION": 1,
"TEXCOORD_0": 3,
"WEIGHTS_0": 7,
"WEIGHTS_1": 8,
"WEIGHTS_2": 9
},
"indices": 0,
"mode": 4
}
]
}
],
"nodes": [
{
"mesh": 0,
"name": "mesh"
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
]
}
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
all:
python strip-buffer.py cloth.gltf
@@ -1,3 +0,0 @@
# Strip unused buffer data.
T.B.W.
File diff suppressed because it is too large Load Diff
@@ -1,24 +0,0 @@
import json
import struct
import sys
if len(sys.argv) < 2:
print("Need input.gltf")
sys.exit(-1)
gltf_file = sys.argv[1]
#bin_file = sys.argv[1]
gltf = json.loads(open(gltf_file, "r", encoding='utf-8').read())
print(gltf)
#data = open(bin_file, "rb").read()
#print(len(data))
#
#out = data[100:]
#print(len(out))
#
#with open("output.bin", "wb") as f:
# f.write(out)
#
#print("DONE!")
-1
View File
@@ -1 +0,0 @@
{ "buffer" : 0 }
-6
View File
@@ -1,6 +0,0 @@
local lib = import 'lowpoly-nodes.gltf';
{
//"muda": lib.skins[0].joints,
"bora": if std.length(lib.assets) then 0 else 1,
}
-6
View File
@@ -1,6 +0,0 @@
newmtl initialShadingGroup
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
-61
View File
@@ -1,61 +0,0 @@
# GNU Make workspace makefile autogenerated by Premake
ifndef config
config=release_native
endif
ifndef verbose
SILENT = @
endif
ifeq ($(config),release_native)
viwewer_config = release_native
endif
ifeq ($(config),release_x64)
viwewer_config = release_x64
endif
ifeq ($(config),release_x32)
viwewer_config = release_x32
endif
ifeq ($(config),debug_native)
viwewer_config = debug_native
endif
ifeq ($(config),debug_x64)
viwewer_config = debug_x64
endif
ifeq ($(config),debug_x32)
viwewer_config = debug_x32
endif
PROJECTS := viwewer
.PHONY: all clean help $(PROJECTS)
all: $(PROJECTS)
viwewer:
ifneq (,$(viwewer_config))
@echo "==== Building viwewer ($(viwewer_config)) ===="
@${MAKE} --no-print-directory -C . -f viwewer.make config=$(viwewer_config)
endif
clean:
@${MAKE} --no-print-directory -C . -f viwewer.make clean
help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " release_native"
@echo " release_x64"
@echo " release_x32"
@echo " debug_native"
@echo " debug_x64"
@echo " debug_x32"
@echo ""
@echo "TARGETS:"
@echo " all (default)"
@echo " clean"
@echo " viwewer"
@echo ""
@echo "For more information, see http://industriousone.com/premake/quick-start"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

-1
View File
@@ -1 +0,0 @@
Makefile.dev
Binary file not shown.
-191
View File
@@ -1,191 +0,0 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5123,
"count": 36,
"min": [
0.0
],
"max": [
35.0
],
"normalized": false,
"type": "SCALAR"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 36,
"min": [
-1.0,
-1.0,
-1.0
],
"max": [
1.0,
1.0,
1.000001
],
"normalized": false,
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 36,
"min": [
-1.0,
-1.0,
-1.0
],
"max": [
1.0,
1.0,
1.0
],
"normalized": false,
"type": "VEC3"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 36,
"min": [
0.0,
-0.0,
-1.0,
-1.0
],
"max": [
1.0,
-0.0,
-0.0,
1.0
],
"normalized": false,
"type": "VEC4"
},
{
"bufferView": 4,
"componentType": 5126,
"count": 36,
"min": [
-1.0,
-1.0
],
"max": [
1.0,
1.0
],
"normalized": false,
"type": "VEC2"
}
],
"asset": {
"generator": "VKTS glTF 2.0 exporter",
"version": "2.0"
},
"buffers": [
{
"byteLength": 1800,
"uri": "Cube.bin"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 72,
"target": 34963
},
{
"buffer": 0,
"byteLength": 432,
"byteOffset": 72,
"target": 34962
},
{
"buffer": 0,
"byteLength": 432,
"byteOffset": 504,
"target": 34962
},
{
"buffer": 0,
"byteLength": 576,
"byteOffset": 936,
"target": 34962
},
{
"buffer": 0,
"byteLength": 288,
"byteOffset": 1512,
"target": 34962
}
],
"images": [
{
"uri": "Cube_BaseColor.png"
},
{
"uri": "Cube_MetallicRoughness.png"
}
],
"materials": [
{
"name": "Cube"
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"NORMAL": 2,
"POSITION": 1,
"TANGENT": 3,
"TEXCOORD_0": 4
},
"indices": 0,
"material": 0,
"mode": 4
}
],
"name": "Cube"
}
],
"nodes": [
{
"mesh": 0,
"name": "Cube",
"children": []
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"textures": [
{
"sampler": 0,
"source": 0
},
{
"sampler": 0,
"source": 1
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9986,
"wrapR": 10497,
"wrapS": 10497,
"wrapT": 10497
}
]
}
Binary file not shown.
-61
View File
@@ -1,61 +0,0 @@
# GNU Make workspace makefile autogenerated by Premake
ifndef config
config=debug_native
endif
ifndef verbose
SILENT = @
endif
ifeq ($(config),debug_native)
skinning_config = debug_native
endif
ifeq ($(config),debug_x64)
skinning_config = debug_x64
endif
ifeq ($(config),debug_x32)
skinning_config = debug_x32
endif
ifeq ($(config),release_native)
skinning_config = release_native
endif
ifeq ($(config),release_x64)
skinning_config = release_x64
endif
ifeq ($(config),release_x32)
skinning_config = release_x32
endif
PROJECTS := skinning
.PHONY: all clean help $(PROJECTS)
all: $(PROJECTS)
skinning:
ifneq (,$(skinning_config))
@echo "==== Building skinning ($(skinning_config)) ===="
@${MAKE} --no-print-directory -C . -f skinning.make config=$(skinning_config)
endif
clean:
@${MAKE} --no-print-directory -C . -f skinning.make clean
help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " debug_native"
@echo " debug_x64"
@echo " debug_x32"
@echo " release_native"
@echo " release_x64"
@echo " release_x32"
@echo ""
@echo "TARGETS:"
@echo " all (default)"
@echo " clean"
@echo " skinning"
@echo ""
@echo "For more information, see http://industriousone.com/premake/quick-start"
-276
View File
@@ -1,276 +0,0 @@
# GNU Make project makefile autogenerated by Premake
ifndef config
config=debug_native
endif
ifndef verbose
SILENT = @
endif
.PHONY: clean prebuild prelink
ifeq ($(config),debug_native)
RESCOMP = windres
TARGETDIR = bin/native/Debug
TARGET = $(TARGETDIR)/skinning
OBJDIR = obj/native/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../..
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),debug_x64)
RESCOMP = windres
TARGETDIR = bin/x64/Debug
TARGET = $(TARGETDIR)/skinning
OBJDIR = obj/x64/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../..
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),debug_x32)
RESCOMP = windres
TARGETDIR = bin/x32/Debug
TARGET = $(TARGETDIR)/skinning
OBJDIR = obj/x32/Debug
DEFINES += -DDEBUG
INCLUDES += -I. -I../..
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_native)
RESCOMP = windres
TARGETDIR = bin/native/Release
TARGET = $(TARGETDIR)/skinning
OBJDIR = obj/native/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../..
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -s `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_x64)
RESCOMP = windres
TARGETDIR = bin/x64/Release
TARGET = $(TARGETDIR)/skinning
OBJDIR = obj/x64/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../..
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -s `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
ifeq ($(config),release_x32)
RESCOMP = windres
TARGETDIR = bin/x32/Release
TARGET = $(TARGETDIR)/skinning
OBJDIR = obj/x32/Release
DEFINES += -DNDEBUG
INCLUDES += -I. -I../..
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O2 -Wall -Wextra -std=c++11
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lGL -lGLU -lm -lGLEW -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -ldl
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 -s `pkg-config --libs glfw3`
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
all: prebuild prelink $(TARGET)
@:
endif
OBJECTS := \
$(OBJDIR)/matrix.o \
$(OBJDIR)/trackball.o \
$(OBJDIR)/main.o \
$(OBJDIR)/morph-targets.o \
$(OBJDIR)/skinning.o \
RESOURCES := \
CUSTOMFILES := \
SHELLTYPE := msdos
ifeq (,$(ComSpec)$(COMSPEC))
SHELLTYPE := posix
endif
ifeq (/bin,$(findstring /bin,$(SHELL)))
SHELLTYPE := posix
endif
$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES)
@echo Linking skinning
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)
clean:
@echo Cleaning skinning
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(TARGET)
$(SILENT) rm -rf $(OBJDIR)
else
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
endif
prebuild:
$(PREBUILDCMDS)
prelink:
$(PRELINKCMDS)
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH)
$(GCH): $(PCH)
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
endif
$(OBJDIR)/matrix.o: ../common/matrix.cc
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/trackball.o: ../common/trackball.cc
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/main.o: main.cc
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/morph-targets.o: morph-targets.cc
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/skinning.o: skinning.cc
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
-include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH))
-include $(OBJDIR)/$(notdir $(PCH)).d
endif
-7
View File
@@ -1,7 +0,0 @@
# Use this for strict compilation check(will work on clang 3.8+)
EXTRA_CXXFLAGS := -Wall -Werror -Weverything -Wno-c++11-long-long -Wno-c++98-compat
all:
clang++ $(EXTRA_CXXFLAGS) -I../../ -std=c++11 -g -O0 -o main main.cpp
-122
View File
@@ -1,122 +0,0 @@
{
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5121,
"count" : 36,
"max" : [
23
],
"min" : [
0
],
"type" : "SCALAR"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 24,
"max" : [
1.0000004768371582,
1.0,
1.0000005960464478
],
"min" : [
-1.0000003576278687,
-1.0,
-1.0000003576278687
],
"type" : "VEC3"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 24,
"max" : [
1.0,
1.0,
1.0
],
"min" : [
-1.0,
-1.0,
-1.0
],
"type" : "VEC3"
}
],
"asset" : {
"generator" : "Khronos Blender glTF 2.0 exporter",
"version" : "2.0"
},
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 36,
"byteOffset" : 0,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 36,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 324,
"target" : 34962
}
],
"buffers" : [
{
"byteLength" : 612,
"uri" : "data:application/octet-stream;base64,AAECAwEABAUGBAcFCAkKCAsJDA0ODA8NEBESEBMRFBUWFBcVAACAPwAAgL///3+/AQCAvwAAgL/9/38/+v9/vwAAgL8DAIC/AACAPwAAgL8AAIA/AwCAvwAAgD/6/38/BACAPwAAgD/3/3+///9/vwAAgD8AAIC/9f9/PwAAgD8FAIA/BACAPwAAgD/3/3+/AACAPwAAgL8AAIA/AACAPwAAgL///3+/9f9/PwAAgD8FAIA/9f9/PwAAgD8FAIA/AQCAvwAAgL/9/38/AACAPwAAgL8AAIA/AwCAvwAAgD/6/38/AwCAvwAAgD/6/38/+v9/vwAAgL8DAIC/AQCAvwAAgL/9/38///9/vwAAgD8AAIC///9/vwAAgD8AAIC/AACAPwAAgL///3+/+v9/vwAAgL8DAIC/BACAPwAAgD/3/3+/AAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAACAP+z/PzMAAJg0AACAP+z/PzMAAJg0AACAP+z/PzMAAJg0AACAP+z/PzMAAJg0AACYtAkA4LMAAIA/AACYtAkA4LMAAIA/AACYtAkA4LMAAIA/AACYtAkA4LMAAIA/AACAv///D7QCAHC0AACAv///D7QCAHC0AACAv///D7QCAHC0AACAv///D7QCAHC0AACANAAAYDQAAIC/AACANAAAYDQAAIC/AACANAAAYDQAAIC/AACANAAAYDQAAIC/"
}
],
"materials" : [
{
"name" : "Material",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.6400000190734865,
0.6400000190734865,
0.6400000190734865,
1.0
],
"metallicFactor" : 0.0
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"NORMAL" : 2,
"POSITION" : 1
},
"indices" : 0,
"material" : 0
}
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
}
],
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0
]
}
]
}
-67
View File
@@ -1,67 +0,0 @@
#include <stdio.h>
#define TINYGLTF_IMPLEMENTATION
#define TINYGLTF_NO_STB_IMAGE
#define TINYGLTF_NO_STB_IMAGE_WRITE
#include "tiny_gltf.h"
#ifdef __clang__
#pragma clang diagnostic ignored "-Weverything"
#endif
static int _allocs = 0;
void* operator new( size_t size )
{
++_allocs;
return malloc( size );
}
void* operator new[]( size_t size )
{
++_allocs;
return malloc( size );
}
void operator delete( void* memory )
{
--_allocs;
free( memory );
}
void operator delete( void* memory, size_t size )
{
--_allocs;
free( memory );
}
void operator delete[]( void* memory )
{
--_allocs;
free( memory );
}
void operator delete[]( void* memory, size_t size )
{
--_allocs;
free( memory );
}
void test()
{
tinygltf::TinyGLTF loader;
tinygltf::Model model;
bool status = loader.LoadASCIIFromFile( &model, NULL, NULL, "box.gltf" );
printf( "status: %d\n", status );
}
int main()
{
printf( "before: %d\n", _allocs );
test();
printf( "after: %d\n", _allocs );
return 0;
}
@@ -1,87 +0,0 @@
#ifdef VALIJSON_BUILD_CXX11_ADAPTERS
#include <gtest/gtest.h>
#include <valijson/adapters/json11_adapter.hpp>
class TestJson11Adapter : public testing::Test
{
};
TEST_F(TestJson11Adapter, BasicArrayIteration)
{
const unsigned int numElements = 10;
// Create a Json11 document that consists of an array of numbers
json11::Json::array array;
for (unsigned int i = 0; i < numElements; i++) {
json11::Json value(static_cast<double>(i));
array.push_back(value);
}
json11::Json document(array);
// Ensure that wrapping the document preserves the array and does not allow
// it to be cast to other types
valijson::adapters::Json11Adapter adapter(document);
ASSERT_NO_THROW( adapter.getArray() );
ASSERT_ANY_THROW( adapter.getBool() );
ASSERT_ANY_THROW( adapter.getDouble() );
ASSERT_ANY_THROW( adapter.getObject() );
ASSERT_ANY_THROW( adapter.getString() );
// Ensure that the array contains the expected number of elements
EXPECT_EQ( numElements, adapter.getArray().size() );
// Ensure that the elements are returned in the order they were inserted
unsigned int expectedValue = 0;
for (const valijson::adapters::Json11Adapter value : adapter.getArray()) {
ASSERT_TRUE( value.isNumber() );
EXPECT_EQ( double(expectedValue), value.getDouble() );
expectedValue++;
}
// Ensure that the correct number of elements were iterated over
EXPECT_EQ(numElements, expectedValue);
}
TEST_F(TestJson11Adapter, BasicObjectIteration)
{
const unsigned int numElements = 10;
// Create a DropBoxJson11 document that consists of an object that maps numeric
// strings their corresponding numeric values
json11::Json::object object;
for (unsigned int i = 0; i < numElements; i++) {
std::string name(std::to_string(i));
object[name] = json11::Json(static_cast<double>(i));
}
json11::Json document(object);
// Ensure that wrapping the document preserves the object and does not
// allow it to be cast to other types
valijson::adapters::Json11Adapter adapter(document);
ASSERT_NO_THROW( adapter.getObject() );
ASSERT_ANY_THROW( adapter.getArray() );
ASSERT_ANY_THROW( adapter.getBool() );
ASSERT_ANY_THROW( adapter.getDouble() );
ASSERT_ANY_THROW( adapter.getString() );
// Ensure that the object contains the expected number of members
EXPECT_EQ( numElements, adapter.getObject().size() );
// Ensure that the members are returned in the order they were inserted
unsigned int expectedValue = 0;
for (const valijson::adapters::Json11Adapter::ObjectMember member : adapter.getObject()) {
ASSERT_TRUE( member.second.isNumber() );
EXPECT_EQ( std::to_string(expectedValue), member.first );
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
expectedValue++;
}
// Ensure that the correct number of elements were iterated over
EXPECT_EQ( numElements, expectedValue );
}
#endif // VALIJSON_BUILD_CXX11_ADAPTERS
-2
View File
@@ -1,2 +0,0 @@
all:
python gen.py /home/syoyo/work/glTF/specification/2.0/schema/
-5
View File
@@ -1,5 +0,0 @@
CXX=/mnt/data/local/llvm-mingw-20200325-ubuntu-18.04/bin/x86_64-w64-mingw32-clang++
#CXX=x86_64-w64-mingw32-g++
all: ../tiny_gltf.h
$(CXX) -fuse-ld=lld -I../ $(EXTRA_CXXFLAGS) -std=c++11 -g -O0 -o tester.exe tester.cc
@@ -1,76 +0,0 @@
/*
* LLVM libFuzzer harness for tinygltf with the custom JSON backend
* (tinygltf_json.h).
*
* Exercises:
* 1. LoadASCIIFromString – glTF JSON parsing
* 2. LoadBinaryFromMemory – GLB binary parsing
*
* Build (clang with libFuzzer):
* clang++ -std=c++11 -fsanitize=address,fuzzer \
* -DTINYGLTF_USE_CUSTOM_JSON \
* -I../../ fuzz_gltf_customjson.cc \
* -o fuzz_gltf_customjson
*
* Run:
* ./fuzz_gltf_customjson -rss_limit_mb=20000 -jobs 4
*/
#include <cstdint>
#include <cstring>
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define TINYGLTF_IMPLEMENTATION
#ifndef TINYGLTF_USE_CUSTOM_JSON
#define TINYGLTF_USE_CUSTOM_JSON
#endif
#include "tiny_gltf.h"
/* Fuzz the ASCII (JSON) parser path */
static void fuzz_ascii(const uint8_t *data, size_t size) {
tinygltf::Model model;
tinygltf::TinyGLTF ctx;
std::string err;
std::string warn;
const char *str = reinterpret_cast<const char *>(data);
bool ret =
ctx.LoadASCIIFromString(&model, &err, &warn, str,
static_cast<unsigned int>(size), /* base_dir */ "");
(void)ret;
}
/* Fuzz the binary (GLB) parser path */
static void fuzz_binary(const uint8_t *data, size_t size) {
tinygltf::Model model;
tinygltf::TinyGLTF ctx;
std::string err;
std::string warn;
bool ret = ctx.LoadBinaryFromMemory(&model, &err, &warn, data,
static_cast<unsigned int>(size),
/* base_dir */ "");
(void)ret;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size == 0) return 0;
/* Use the lowest bit of the first byte to select the parse path.
* The remaining bits are left for the fuzzer engine to explore;
* additional paths (e.g. LoadASCIIFromFile, check_sections flags)
* can be added here in the future using more selector bits. */
uint8_t selector = data[0];
const uint8_t *payload = data + 1;
size_t payload_size = size - 1;
if (selector & 1) {
fuzz_binary(payload, payload_size);
} else {
fuzz_ascii(payload, payload_size);
}
return 0;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-209
View File
@@ -1,209 +0,0 @@
{
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 36,
"max" : [
35
],
"min" : [
0
],
"type" : "SCALAR"
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000001
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
-0.000000,
-0.000000,
1.000000
],
"min" : [
0.000000,
-0.000000,
-1.000000,
-1.000000
],
"type" : "VEC4"
},
{
"bufferView" : 4,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000
],
"type" : "VEC2"
}
],
"asset" : {
"generator" : "VKTS glTF 2.0 exporter",
"version" : "2.0"
},
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 72,
"byteOffset" : 0,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 432,
"byteOffset" : 72,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 432,
"byteOffset" : 504,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 576,
"byteOffset" : 936,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1512,
"target" : 34962
}
],
"buffers" : [
{
"byteLength" : 1800,
"uri" : "Cube.bin"
}
],
"images" : [
{
"uri" : "Cube_BaseColor.png"
},
{
"uri" : "Cube_MetallicRoughness.png"
}
],
"materials" : [
{"emissiveTexture": {
"index": 0,
"extensions": {
"KHR_texture_transform": {
"offset": [0, 1],
"scale": [1, -1]
}
}
}},
{
"name" : "Cube",
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 0
},
"metallicRoughnessTexture" : {
"index" : 1,
"extensions": {
"KHR_texture_transform": {
"offset": [0, 1],
"rotation": 1.57079632679,
"scale": [0.5, 0.5]
}
}
}
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"NORMAL" : 2,
"POSITION" : 1,
"TANGENT" : 3,
"TEXCOORD_0" : 4
},
"indices" : 0,
"material" : 0,
"mode" : 4
}
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
}
],
"samplers" : [
{}
],
"scene" : 0,
"scenes" : [
{
"nodes" : [
0
]
}
],
"textures" : [
{
"sampler" : 0,
"source" : 0
},
{
"sampler" : 0,
"source" : 1
}
]
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

-193
View File
@@ -1,193 +0,0 @@
{
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 36,
"max" : [
35
],
"min" : [
0
],
"type" : "SCALAR"
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000001
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
-0.000000,
-0.000000,
1.000000
],
"min" : [
0.000000,
-0.000000,
-1.000000,
-1.000000
],
"type" : "VEC4"
},
{
"bufferView" : 4,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000
],
"type" : "VEC2"
}
],
"asset" : {
"generator" : "VKTS glTF 2.0 exporter",
"version" : "2.0"
},
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 72,
"byteOffset" : 0,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 432,
"byteOffset" : 72,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 432,
"byteOffset" : 504,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 576,
"byteOffset" : 936,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1512,
"target" : 34962
}
],
"buffers" : [
{
"byteLength" : 1800,
"uri" : "Cube.bin"
}
],
"images" : [
{
"uri" : "Cube_BaseColor.png"
},
{
"uri" : "Cube_MetallicRoughness.png"
}
],
"materials" : [
{
"name" : "Cube",
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 0
},
"metallicRoughnessTexture" : {
"index" : 1
}
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"NORMAL" : 2,
"POSITION" : 1,
"TANGENT" : 3,
"TEXCOORD_0" : 4
},
"indices" : 0,
"material" : 0,
"mode" : 4
}
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
}
],
"samplers" : [
{}
],
"scene" : 0,
"scenes" : [
{
"nodes" : [
0
]
}
],
"textures" : [
{
"sampler" : 0,
"source" : 0
},
{
"sampler" : 0,
"source" : 1
}
]
}
-197
View File
@@ -1,197 +0,0 @@
{
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 36,
"max" : [
35
],
"min" : [
0
],
"type" : "SCALAR"
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000001
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
-0.000000,
-0.000000,
1.000000
],
"min" : [
0.000000,
-0.000000,
-1.000000,
-1.000000
],
"type" : "VEC4"
},
{
"bufferView" : 4,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000
],
"type" : "VEC2"
}
],
"asset" : {
"generator" : "VKTS glTF 2.0 exporter",
"version" : "2.0"
},
"bufferViews" : [
{
"buffer" : 1,
"byteLength" : 72,
"byteOffset" : 0,
"target" : 34963
},
{
"buffer" : 1,
"byteLength" : 432,
"byteOffset" : 72,
"target" : 34962
},
{
"buffer" : 1,
"byteLength" : 432,
"byteOffset" : 504,
"target" : 34962
},
{
"buffer" : 1,
"byteLength" : 576,
"byteOffset" : 936,
"target" : 34962
},
{
"buffer" : 1,
"byteLength" : 288,
"byteOffset" : 1512,
"target" : 34962
}
],
"buffers" : [
{
"byteLength" : 1800,
"uri" : "Cube.bin"
},
{
"byteLength" : 1800,
"uri" : "Cube.bin2"
}
],
"images" : [
{
"uri" : "Cube_BaseColor.png"
},
{
"uri" : "Cube_MetallicRoughness.png"
}
],
"materials" : [
{
"name" : "Cube",
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 0
},
"metallicRoughnessTexture" : {
"index" : 1
}
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"NORMAL" : 2,
"POSITION" : 1,
"TANGENT" : 3,
"TEXCOORD_0" : 4
},
"indices" : 0,
"material" : 0,
"mode" : 4
}
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
}
],
"samplers" : [
{}
],
"scene" : 0,
"scenes" : [
{
"nodes" : [
0
]
}
],
"textures" : [
{
"sampler" : 0,
"source" : 0
},
{
"sampler" : 0,
"source" : 1
}
]
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 B

-9
View File
@@ -1,9 +0,0 @@
rm -rf build
mkdir build
WASI_VERSION=16
WASI_VERSION_FULL=${WASI_VERSION}.0
WASI_SDK_PATH=$HOME/local/wasi-sdk-${WASI_VERSION_FULL}
CC=${WASI_SDK_PATH}/bin/clang CXX=${WASI_SDK_PATH}/bin/clang++ cmake -DWASI_SDK_PATH=${WASI_SDK_PATH} -Bbuild -DCMAKE_BUILD_TYPE=MinSizeRel -S.
-7
View File
@@ -1,7 +0,0 @@
import wasmtime.loader
# Assuming `your_wasm_file.wasm` is in the python load path...
import loader_example
# Now you're compiled and instantiated and ready to go!
print(loader_example.main())
-223
View File
@@ -1,223 +0,0 @@
{
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 18,
"max" : [
35
],
"min" : [
0
],
"type" : "SCALAR"
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000001
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000,
-1.000000
],
"type" : "VEC3"
},
{
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
-0.000000,
-0.000000,
1.000000
],
"min" : [
0.000000,
-0.000000,
-1.000000,
-1.000000
],
"type" : "VEC4"
},
{
"bufferView" : 4,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 36,
"max" : [
1.000000,
1.000000
],
"min" : [
-1.000000,
-1.000000
],
"type" : "VEC2"
},
{
"bufferView" : 5,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 18,
"max" : [
71
],
"min" : [
36
],
"type" : "SCALAR"
}
],
"asset" : {
"generator" : "VKTS glTF 2.0 exporter",
"version" : "2.0"
},
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 36,
"byteOffset" : 0,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 432,
"byteOffset" : 72,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 432,
"byteOffset" : 504,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 576,
"byteOffset" : 936,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1512,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 36,
"byteOffset" : 36,
"target" : 34963
}
],
"buffers" : [
{
"byteLength" : 1800,
"uri" : "Cube.bin"
}
],
"images" : [
{
"uri" : "Cube_BaseColor.png"
},
{
"uri" : "Cube_MetallicRoughness.png"
}
],
"materials" : [
{
"name" : "Cube",
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 0
},
"metallicRoughnessTexture" : {
"index" : 1
}
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"NORMAL" : 2,
"POSITION" : 1,
"TANGENT" : 3,
"TEXCOORD_0" : 4
},
"indices" : 0,
"material" : 0,
"mode" : 4
},
{
"attributes" : {
"NORMAL" : 2,
"POSITION" : 1,
"TANGENT" : 3,
"TEXCOORD_0" : 4
},
"indices" : 5,
"material" : 0,
"mode" : 4
}
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
}
],
"samplers" : [
{}
],
"scene" : 0,
"scenes" : [
{
"nodes" : [
0
]
}
],
"textures" : [
{
"sampler" : 0,
"source" : 0
},
{
"sampler" : 0,
"source" : 1
}
]
}
-70
View File
@@ -1,70 +0,0 @@
# benchmark/Makefile — Build and run tinygltf v3 benchmarks
#
# Targets:
# make — build gen_synthetic + bench_v3
# make generate — generate synthetic test scenes
# make run — run benchmarks on all generated scenes
# make report — run benchmarks and produce CSV report
# make clean — remove binaries and generated scenes
CXX ?= g++
CXXFLAGS ?= -O2 -std=c++17 -Wall -Wextra -Wno-unused-function
CXXFLAGS += -fno-rtti -fno-exceptions
INCLUDES = -I..
BINDIR = .
GEN = $(BINDIR)/gen_synthetic
BENCH_V3 = $(BINDIR)/bench_v3
# Iteration counts
ITERATIONS ?= 10
WARMUP ?= 2
PREFIX ?= synthetic
.PHONY: all generate run report clean
all: $(GEN) $(BENCH_V3)
$(GEN): gen_synthetic.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
$(BENCH_V3): bench_v3.cpp ../tiny_gltf_v3.h ../tiny_gltf_v3.c ../tinygltf_json_c.h
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $<
# Generate synthetic scenes of varying sizes
generate: $(GEN)
@echo "=== Generating synthetic scenes ==="
./$(GEN) --prefix $(PREFIX)
@echo ""
@echo "Generated files (binary + GLB):"
@ls -lh $(PREFIX)_*.gltf $(PREFIX)_*.glb $(PREFIX)_*.bin 2>/dev/null || true
# Run benchmarks on all generated scenes
run: $(BENCH_V3) generate
@echo ""
@echo "================================================================="
@echo " tinygltf v3 Benchmark"
@echo "================================================================="
@echo ""
@for f in $(PREFIX)_*.glb $(PREFIX)_*.gltf; do \
if [ -f "$$f" ]; then \
./$(BENCH_V3) "$$f" --iterations $(ITERATIONS) --warmup $(WARMUP); \
echo ""; \
fi; \
done
# Run benchmarks and produce CSV report
report: $(BENCH_V3) generate
@echo "file,size_bytes,iterations,parse_min_ms,parse_max_ms,parse_avg_ms,parse_median_ms,throughput_mbs,arena_peak_bytes,meshes,nodes,accessors,materials,animations" > benchmark_report.csv
@for f in $(PREFIX)_*.glb $(PREFIX)_*.gltf; do \
if [ -f "$$f" ]; then \
./$(BENCH_V3) "$$f" --iterations $(ITERATIONS) --warmup $(WARMUP) --csv | tail -1 >> benchmark_report.csv; \
fi; \
done
@echo "=== Report written to benchmark_report.csv ==="
@cat benchmark_report.csv | column -t -s,
clean:
rm -f $(GEN) $(BENCH_V3)
rm -f $(PREFIX)_*.gltf $(PREFIX)_*.glb $(PREFIX)_*.bin
rm -f benchmark_report.csv
-414
View File
@@ -1,414 +0,0 @@
/*
* bench_v3.cpp — Benchmark tinygltf v3 parser: parse speed & memory.
*
* Measures:
* - File read time
* - JSON parse + model build time
* - Peak arena memory usage
* - Throughput (MB/s)
*
* Usage:
* bench_v3 <file.gltf|file.glb> [--iterations N] [--warmup N] [--quiet]
* bench_v3 --batch <file1> <file2> ... [--iterations N]
*/
#define TINYGLTF3_IMPLEMENTATION
#define TINYGLTF3_ENABLE_FS
#include "tiny_gltf_v3.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <chrono>
#if defined(__linux__)
#include <sys/resource.h>
#endif
/* ------------------------------------------------------------------ */
/* Timing helpers */
/* ------------------------------------------------------------------ */
using Clock = std::chrono::high_resolution_clock;
using TimePoint = Clock::time_point;
static double elapsed_ms(TimePoint start, TimePoint end) {
return std::chrono::duration<double, std::milli>(end - start).count();
}
/* ------------------------------------------------------------------ */
/* Memory tracking allocator */
/* ------------------------------------------------------------------ */
struct MemTracker {
size_t current;
size_t peak;
size_t total_allocs;
size_t total_frees;
};
static void *tracked_alloc(size_t size, void *ud) {
MemTracker *mt = (MemTracker *)ud;
void *ptr = malloc(size);
if (ptr) {
mt->current += size;
if (mt->current > mt->peak) mt->peak = mt->current;
mt->total_allocs++;
}
return ptr;
}
static void *tracked_realloc(void *ptr, size_t old_size, size_t new_size, void *ud) {
MemTracker *mt = (MemTracker *)ud;
void *new_ptr = realloc(ptr, new_size);
if (new_ptr) {
mt->current -= old_size;
mt->current += new_size;
if (mt->current > mt->peak) mt->peak = mt->current;
}
return new_ptr;
}
static void tracked_free(void *ptr, size_t size, void *ud) {
MemTracker *mt = (MemTracker *)ud;
if (ptr) {
mt->current -= size;
mt->total_frees++;
free(ptr);
}
}
/* ------------------------------------------------------------------ */
/* RSS measurement (Linux) */
/* ------------------------------------------------------------------ */
static size_t get_rss_bytes() {
#if defined(__linux__)
FILE *f = fopen("/proc/self/statm", "r");
if (!f) return 0;
long pages = 0;
if (fscanf(f, "%*s %ld", &pages) != 1) pages = 0;
fclose(f);
return (size_t)pages * 4096;
#else
return 0;
#endif
}
/* ------------------------------------------------------------------ */
/* Benchmark result */
/* ------------------------------------------------------------------ */
struct BenchResult {
std::string filename;
uint64_t file_size;
int iterations;
/* Parse timing (ms) */
double parse_min;
double parse_max;
double parse_avg;
double parse_median;
/* Memory */
size_t arena_peak; /* Peak arena allocation */
size_t rss_before;
size_t rss_after;
/* Model stats */
uint32_t meshes;
uint32_t nodes;
uint32_t accessors;
uint32_t materials;
uint32_t animations;
uint32_t buffers;
uint32_t buffer_views;
uint32_t images;
uint32_t textures;
/* Derived */
double throughput_mbs; /* MB/s based on median */
};
/* ------------------------------------------------------------------ */
/* Run benchmark for a single file */
/* ------------------------------------------------------------------ */
static BenchResult bench_file(const char *filename, int iterations, int warmup,
bool quiet, int float32_mode = 0,
int skip_extras_values = 0,
int borrow_input_buffers = 0) {
BenchResult r = {};
r.filename = filename;
r.iterations = iterations;
/* Read file into memory */
FILE *f = fopen(filename, "rb");
if (!f) {
fprintf(stderr, "ERROR: Cannot open '%s'\n", filename);
return r;
}
fseek(f, 0, SEEK_END);
long sz = ftell(f);
fseek(f, 0, SEEK_SET);
if (sz <= 0) { fclose(f); return r; }
std::vector<uint8_t> data((size_t)sz);
size_t rd = fread(data.data(), 1, (size_t)sz, f);
fclose(f);
if ((long)rd != sz) { return r; }
r.file_size = (uint64_t)sz;
/* Extract base dir */
std::string path(filename);
std::string base_dir;
size_t sep = path.find_last_of("/\\");
if (sep != std::string::npos) base_dir = path.substr(0, sep);
/* Warmup iterations (not measured) */
for (int i = 0; i < warmup; ++i) {
tg3_model model;
tg3_error_stack errors;
tg3_error_stack_init(&errors);
tg3_parse_auto(&model, &errors, data.data(), data.size(),
base_dir.c_str(), (uint32_t)base_dir.size(), NULL);
tg3_model_free(&model);
tg3_error_stack_free(&errors);
}
/* Benchmark iterations */
std::vector<double> times;
times.reserve(iterations);
MemTracker tracker_best;
memset(&tracker_best, 0, sizeof(tracker_best));
r.rss_before = get_rss_bytes();
for (int i = 0; i < iterations; ++i) {
MemTracker tracker;
memset(&tracker, 0, sizeof(tracker));
tg3_parse_options opts;
tg3_parse_options_init(&opts);
opts.memory.allocator.alloc = tracked_alloc;
opts.memory.allocator.realloc = tracked_realloc;
opts.memory.allocator.free = tracked_free;
opts.memory.allocator.user_data = &tracker;
opts.parse_float32 = float32_mode;
opts.skip_extras_values = skip_extras_values;
opts.borrow_input_buffers = borrow_input_buffers;
tg3_model model;
tg3_error_stack errors;
tg3_error_stack_init(&errors);
TimePoint t0 = Clock::now();
tg3_error_code err = tg3_parse_auto(&model, &errors,
data.data(), data.size(),
base_dir.c_str(),
(uint32_t)base_dir.size(),
&opts);
TimePoint t1 = Clock::now();
double ms = elapsed_ms(t0, t1);
times.push_back(ms);
/* Capture model stats on first successful iteration */
if (i == 0 && err == TG3_OK) {
r.meshes = model.meshes_count;
r.nodes = model.nodes_count;
r.accessors = model.accessors_count;
r.materials = model.materials_count;
r.animations = model.animations_count;
r.buffers = model.buffers_count;
r.buffer_views = model.buffer_views_count;
r.images = model.images_count;
r.textures = model.textures_count;
}
if (tracker.peak > tracker_best.peak) {
tracker_best = tracker;
}
tg3_model_free(&model);
tg3_error_stack_free(&errors);
if (err != TG3_OK && !quiet) {
fprintf(stderr, " Parse error on iteration %d: code %d\n", i, (int)err);
}
}
r.rss_after = get_rss_bytes();
r.arena_peak = tracker_best.peak;
/* Compute stats */
std::sort(times.begin(), times.end());
r.parse_min = times.front();
r.parse_max = times.back();
double sum = 0;
for (double t : times) sum += t;
r.parse_avg = sum / times.size();
r.parse_median = times[times.size() / 2];
/* Throughput: file_size / median_time */
if (r.parse_median > 0) {
r.throughput_mbs = ((double)r.file_size / (1024.0 * 1024.0)) /
(r.parse_median / 1000.0);
}
return r;
}
/* ------------------------------------------------------------------ */
/* Print results */
/* ------------------------------------------------------------------ */
static const char *human_bytes(size_t bytes, char *buf, size_t buf_sz) {
if (bytes >= 1024ULL * 1024 * 1024)
snprintf(buf, buf_sz, "%.2f GB", (double)bytes / (1024.0 * 1024 * 1024));
else if (bytes >= 1024 * 1024)
snprintf(buf, buf_sz, "%.2f MB", (double)bytes / (1024.0 * 1024));
else if (bytes >= 1024)
snprintf(buf, buf_sz, "%.2f KB", (double)bytes / 1024.0);
else
snprintf(buf, buf_sz, "%zu B", bytes);
return buf;
}
static void print_result(const BenchResult &r) {
char buf1[64], buf2[64];
printf("┌─────────────────────────────────────────────────────────────────┐\n");
printf("│ %-63s │\n", r.filename.c_str());
printf("├─────────────────────────────────────────────────────────────────┤\n");
printf("│ File size: %-47s │\n", human_bytes((size_t)r.file_size, buf1, sizeof(buf1)));
printf("│ Iterations: %-47d │\n", r.iterations);
printf("│ │\n");
printf("│ Parse time (ms): │\n");
printf("│ min: %10.3f │\n", r.parse_min);
printf("│ max: %10.3f │\n", r.parse_max);
printf("│ avg: %10.3f │\n", r.parse_avg);
printf("│ median: %10.3f │\n", r.parse_median);
printf("│ │\n");
printf("│ Throughput: %-47s │\n",
(snprintf(buf1, sizeof(buf1), "%.2f MB/s", r.throughput_mbs), buf1));
printf("│ Arena peak: %-47s │\n", human_bytes(r.arena_peak, buf1, sizeof(buf1)));
if (r.rss_before > 0) {
printf("│ RSS before: %-47s │\n", human_bytes(r.rss_before, buf1, sizeof(buf1)));
printf("│ RSS after: %-47s │\n", human_bytes(r.rss_after, buf2, sizeof(buf2)));
}
printf("│ │\n");
printf("│ Model: %u meshes, %u nodes, %u accessors, %u materials",
r.meshes, r.nodes, r.accessors, r.materials);
printf(" │\n");
printf("│ %u animations, %u buffers, %u images",
r.animations, r.buffers, r.images);
printf(" │\n");
printf("└─────────────────────────────────────────────────────────────────┘\n");
}
static void print_csv_header() {
printf("file,size_bytes,iterations,parse_min_ms,parse_max_ms,parse_avg_ms,"
"parse_median_ms,throughput_mbs,arena_peak_bytes,"
"meshes,nodes,accessors,materials,animations\n");
}
static void print_csv_row(const BenchResult &r) {
printf("%s,%lu,%d,%.3f,%.3f,%.3f,%.3f,%.2f,%zu,%u,%u,%u,%u,%u\n",
r.filename.c_str(), (unsigned long)r.file_size, r.iterations,
r.parse_min, r.parse_max, r.parse_avg, r.parse_median,
r.throughput_mbs, r.arena_peak,
r.meshes, r.nodes, r.accessors, r.materials, r.animations);
}
/* ------------------------------------------------------------------ */
/* Main */
/* ------------------------------------------------------------------ */
static void usage() {
fprintf(stderr,
"Usage:\n"
" bench_v3 <file> [--iterations N] [--warmup N] [--csv] [--quiet]\n"
" bench_v3 --batch <file1> [file2] ... [--iterations N] [--csv]\n"
"\n"
"Options:\n"
" --iterations N Number of timed parse iterations (default: 10)\n"
" --warmup N Number of warmup iterations (default: 2)\n"
" --csv Output in CSV format\n"
" --quiet Suppress per-iteration error messages\n"
" --batch Benchmark multiple files\n"
" --float32 Parse JSON floats as float32 (faster, less precise)\n"
" --skip-extras-values\n"
" Skip materializing extras/unknown extension values\n"
" --borrow-input-buffers\n"
" Let GLB buffers reference caller-owned input bytes\n");
}
int main(int argc, char **argv) {
if (argc < 2) { usage(); return 1; }
int iterations = 10;
int warmup = 2;
bool csv = false;
bool quiet = false;
int float32_mode = 0;
int skip_extras_values = 0;
int borrow_input_buffers = 0;
std::vector<std::string> files;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--iterations") == 0 && i + 1 < argc) {
iterations = atoi(argv[++i]);
} else if (strcmp(argv[i], "--warmup") == 0 && i + 1 < argc) {
warmup = atoi(argv[++i]);
} else if (strcmp(argv[i], "--csv") == 0) {
csv = true;
} else if (strcmp(argv[i], "--quiet") == 0) {
quiet = true;
} else if (strcmp(argv[i], "--float32") == 0) {
float32_mode = 1;
} else if (strcmp(argv[i], "--skip-extras-values") == 0) {
skip_extras_values = 1;
} else if (strcmp(argv[i], "--borrow-input-buffers") == 0) {
borrow_input_buffers = 1;
} else if (strcmp(argv[i], "--batch") == 0) {
/* batch mode: just collect files */
} else if (argv[i][0] != '-') {
files.push_back(argv[i]);
}
}
if (files.empty()) { usage(); return 1; }
if (csv) print_csv_header();
for (const auto &file : files) {
if (!csv && !quiet) {
printf("Benchmarking: %s (%d iterations, %d warmup%s)\n",
file.c_str(), iterations, warmup,
float32_mode ? ", float32" :
skip_extras_values ? ", skip extras" :
borrow_input_buffers ? ", borrow buffers" : "");
}
BenchResult r = bench_file(file.c_str(), iterations, warmup, quiet,
float32_mode, skip_extras_values,
borrow_input_buffers);
if (csv) {
print_csv_row(r);
} else {
print_result(r);
printf("\n");
}
}
return 0;
}
-740
View File
@@ -1,740 +0,0 @@
/*
* gen_synthetic.cpp — Generate synthetic glTF 2.0 scenes for benchmarking.
*
* Produces .gltf (ASCII) and .glb (binary) files with configurable:
* - Number of meshes, each with N vertices/triangles
* - Number of nodes (flat hierarchy)
* - Number of materials
* - Number of animations with M keyframes
*
* Usage:
* gen_synthetic [--meshes N] [--verts-per-mesh N] [--nodes N]
* [--materials N] [--animations N] [--keyframes N]
* [--prefix NAME]
*
* Outputs: <prefix>_<label>.gltf and <prefix>_<label>.glb
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <cstdint>
/* ------------------------------------------------------------------ */
/* Tiny JSON writer (no dependencies) */
/* ------------------------------------------------------------------ */
struct JsonWriter {
std::string buf;
int indent;
bool need_comma;
std::vector<bool> stack; /* true = array context */
JsonWriter() : indent(0), need_comma(false) {}
void comma() {
if (need_comma) buf += ",";
buf += "\n";
for (int i = 0; i < indent; ++i) buf += " ";
}
void begin_obj() {
if (!stack.empty()) comma();
buf += "{";
indent++;
need_comma = false;
stack.push_back(false);
}
void end_obj() {
indent--;
buf += "\n";
for (int i = 0; i < indent; ++i) buf += " ";
buf += "}";
stack.pop_back();
need_comma = true;
}
void begin_arr() {
if (!stack.empty() && !need_comma) { /* first elem */ }
buf += "[";
indent++;
need_comma = false;
stack.push_back(true);
}
void end_arr() {
indent--;
buf += "\n";
for (int i = 0; i < indent; ++i) buf += " ";
buf += "]";
stack.pop_back();
need_comma = true;
}
void key(const char *k) {
comma();
buf += "\"";
buf += k;
buf += "\": ";
need_comma = false;
}
void val_str(const char *v) {
if (stack.back()) comma();
buf += "\"";
buf += v;
buf += "\"";
need_comma = true;
}
void val_int(int64_t v) {
if (stack.back()) comma();
buf += std::to_string(v);
need_comma = true;
}
void val_double(double v) {
if (stack.back()) comma();
char tmp[64];
snprintf(tmp, sizeof(tmp), "%.6g", v);
buf += tmp;
need_comma = true;
}
void val_bool(bool v) {
if (stack.back()) comma();
buf += v ? "true" : "false";
need_comma = true;
}
void kv_str(const char *k, const char *v) { key(k); val_str(v); need_comma = true; }
void kv_int(const char *k, int64_t v) { key(k); val_int(v); need_comma = true; }
void kv_double(const char *k, double v) { key(k); val_double(v); need_comma = true; }
void kv_bool(const char *k, bool v) { key(k); val_bool(v); need_comma = true; }
};
/* ------------------------------------------------------------------ */
/* Binary buffer builder */
/* ------------------------------------------------------------------ */
struct BinBuffer {
std::vector<uint8_t> data;
size_t offset() const { return data.size(); }
void push_float(float v) {
const uint8_t *p = reinterpret_cast<const uint8_t*>(&v);
data.insert(data.end(), p, p + 4);
}
void push_u16(uint16_t v) {
const uint8_t *p = reinterpret_cast<const uint8_t*>(&v);
data.insert(data.end(), p, p + 2);
}
void push_u32(uint32_t v) {
const uint8_t *p = reinterpret_cast<const uint8_t*>(&v);
data.insert(data.end(), p, p + 4);
}
void align4() {
while (data.size() % 4 != 0) data.push_back(0);
}
};
/* ------------------------------------------------------------------ */
/* Scene config */
/* ------------------------------------------------------------------ */
struct SceneConfig {
int num_meshes;
int verts_per_mesh;
int num_nodes;
int num_materials;
int num_animations;
int keyframes;
};
/* ------------------------------------------------------------------ */
/* Generate the scene */
/* ------------------------------------------------------------------ */
struct AccessorInfo {
int buffer_view;
int component_type;
int count;
const char *type;
float min_vals[3];
float max_vals[3];
int min_max_components; /* 0 = none, 1 = scalar, 3 = vec3 */
};
static void generate_scene(const SceneConfig &cfg,
std::string &out_json,
std::vector<uint8_t> &out_bin) {
BinBuffer bin;
/* Pre-compute sizes */
int tris_per_mesh = cfg.verts_per_mesh / 3;
if (tris_per_mesh < 1) tris_per_mesh = 1;
int actual_verts = tris_per_mesh * 3;
/*
* For each mesh:
* - positions: actual_verts * 3 floats
* - normals: actual_verts * 3 floats
* - indices: tris_per_mesh * 3 uint16 (or uint32 if >65535)
*
* For each animation:
* - time keys: keyframes floats
* - translation values: keyframes * 3 floats
*/
/* Track buffer views and accessors */
std::vector<size_t> bv_offsets;
std::vector<size_t> bv_lengths;
std::vector<AccessorInfo> accessors;
int bv_idx = 0;
bool use_u32_indices = (actual_verts > 65535);
/* === Mesh data === */
for (int m = 0; m < cfg.num_meshes; ++m) {
float mesh_offset_x = (float)m * 5.0f;
/* Positions */
size_t pos_off = bin.offset();
float pmin[3] = {1e30f, 1e30f, 1e30f};
float pmax[3] = {-1e30f, -1e30f, -1e30f};
for (int v = 0; v < actual_verts; ++v) {
float angle = (float)v / (float)actual_verts * 6.2831853f;
float r = 1.0f + 0.3f * sinf(angle * 5.0f);
float x = mesh_offset_x + r * cosf(angle);
float y = r * sinf(angle);
float z = 0.5f * sinf(angle * 3.0f + (float)m);
bin.push_float(x); bin.push_float(y); bin.push_float(z);
if (x < pmin[0]) pmin[0] = x;
if (x > pmax[0]) pmax[0] = x;
if (y < pmin[1]) pmin[1] = y;
if (y > pmax[1]) pmax[1] = y;
if (z < pmin[2]) pmin[2] = z;
if (z > pmax[2]) pmax[2] = z;
}
size_t pos_len = bin.offset() - pos_off;
bin.align4();
bv_offsets.push_back(pos_off); bv_lengths.push_back(pos_len);
int pos_bv = bv_idx++;
AccessorInfo pos_acc;
pos_acc.buffer_view = pos_bv;
pos_acc.component_type = 5126; /* FLOAT */
pos_acc.count = actual_verts;
pos_acc.type = "VEC3";
memcpy(pos_acc.min_vals, pmin, sizeof(pmin));
memcpy(pos_acc.max_vals, pmax, sizeof(pmax));
pos_acc.min_max_components = 3;
accessors.push_back(pos_acc);
/* Normals */
size_t norm_off = bin.offset();
for (int v = 0; v < actual_verts; ++v) {
float angle = (float)v / (float)actual_verts * 6.2831853f;
float nx = cosf(angle), ny = sinf(angle), nz = 0.0f;
float len = sqrtf(nx*nx + ny*ny + nz*nz);
if (len > 0) { nx /= len; ny /= len; nz /= len; }
bin.push_float(nx); bin.push_float(ny); bin.push_float(nz);
}
size_t norm_len = bin.offset() - norm_off;
bin.align4();
bv_offsets.push_back(norm_off); bv_lengths.push_back(norm_len);
int norm_bv = bv_idx++;
AccessorInfo norm_acc;
norm_acc.buffer_view = norm_bv;
norm_acc.component_type = 5126;
norm_acc.count = actual_verts;
norm_acc.type = "VEC3";
norm_acc.min_max_components = 0;
accessors.push_back(norm_acc);
/* Indices */
size_t idx_off = bin.offset();
for (int t = 0; t < tris_per_mesh; ++t) {
if (use_u32_indices) {
bin.push_u32((uint32_t)(t * 3));
bin.push_u32((uint32_t)(t * 3 + 1));
bin.push_u32((uint32_t)(t * 3 + 2));
} else {
bin.push_u16((uint16_t)(t * 3));
bin.push_u16((uint16_t)(t * 3 + 1));
bin.push_u16((uint16_t)(t * 3 + 2));
}
}
size_t idx_len = bin.offset() - idx_off;
bin.align4();
bv_offsets.push_back(idx_off); bv_lengths.push_back(idx_len);
int idx_bv = bv_idx++;
AccessorInfo idx_acc;
idx_acc.buffer_view = idx_bv;
idx_acc.component_type = use_u32_indices ? 5125 : 5123; /* UINT or USHORT */
idx_acc.count = tris_per_mesh * 3;
idx_acc.type = "SCALAR";
idx_acc.min_max_components = 0;
accessors.push_back(idx_acc);
}
/* === Animation data === */
int anim_time_accessor_start = (int)accessors.size();
for (int a = 0; a < cfg.num_animations; ++a) {
/* Time keys */
size_t time_off = bin.offset();
float tmin = 0.0f, tmax = 0.0f;
for (int k = 0; k < cfg.keyframes; ++k) {
float t = (float)k / (float)(cfg.keyframes - 1) * 10.0f;
bin.push_float(t);
if (k == 0) tmin = t;
tmax = t;
}
size_t time_len = bin.offset() - time_off;
bin.align4();
bv_offsets.push_back(time_off); bv_lengths.push_back(time_len);
int time_bv = bv_idx++;
AccessorInfo time_acc;
time_acc.buffer_view = time_bv;
time_acc.component_type = 5126;
time_acc.count = cfg.keyframes;
time_acc.type = "SCALAR";
time_acc.min_vals[0] = tmin;
time_acc.max_vals[0] = tmax;
time_acc.min_max_components = 1;
accessors.push_back(time_acc);
/* Translation values */
size_t val_off = bin.offset();
for (int k = 0; k < cfg.keyframes; ++k) {
float t = (float)k / (float)(cfg.keyframes - 1) * 10.0f;
float x = sinf(t * 0.5f + (float)a) * 2.0f;
float y = cosf(t * 0.3f) * 1.5f;
float z = sinf(t * 0.7f + (float)a * 0.5f);
bin.push_float(x); bin.push_float(y); bin.push_float(z);
}
size_t val_len = bin.offset() - val_off;
bin.align4();
bv_offsets.push_back(val_off); bv_lengths.push_back(val_len);
int val_bv = bv_idx++;
AccessorInfo val_acc;
val_acc.buffer_view = val_bv;
val_acc.component_type = 5126;
val_acc.count = cfg.keyframes;
val_acc.type = "VEC3";
val_acc.min_max_components = 0;
accessors.push_back(val_acc);
}
size_t total_bin = bin.data.size();
/* === Build JSON === */
JsonWriter w;
w.begin_obj();
/* asset */
w.key("asset"); w.begin_obj();
w.kv_str("version", "2.0");
w.kv_str("generator", "tinygltf_benchmark_gen");
w.end_obj();
/* scene */
w.kv_int("scene", 0);
/* scenes */
w.key("scenes"); w.begin_arr();
w.begin_obj();
w.kv_str("name", "BenchmarkScene");
w.key("nodes"); w.begin_arr();
for (int n = 0; n < cfg.num_nodes; ++n) w.val_int(n);
w.end_arr();
w.end_obj();
w.end_arr();
/* nodes */
w.key("nodes"); w.begin_arr();
for (int n = 0; n < cfg.num_nodes; ++n) {
w.begin_obj();
w.kv_str("name", ("Node_" + std::to_string(n)).c_str());
if (n < cfg.num_meshes) {
w.kv_int("mesh", n);
}
w.key("translation"); w.begin_arr();
w.val_double((double)n * 3.0);
w.val_double(0.0);
w.val_double(0.0);
w.end_arr();
w.end_obj();
}
w.end_arr();
/* meshes */
w.key("meshes"); w.begin_arr();
for (int m = 0; m < cfg.num_meshes; ++m) {
int base_acc = m * 3; /* pos, norm, idx per mesh */
w.begin_obj();
w.kv_str("name", ("Mesh_" + std::to_string(m)).c_str());
w.key("primitives"); w.begin_arr();
w.begin_obj();
w.key("attributes"); w.begin_obj();
w.kv_int("POSITION", base_acc);
w.kv_int("NORMAL", base_acc + 1);
w.end_obj();
w.kv_int("indices", base_acc + 2);
w.kv_int("material", m % cfg.num_materials);
w.kv_int("mode", 4);
w.end_obj();
w.end_arr();
w.end_obj();
}
w.end_arr();
/* materials */
w.key("materials"); w.begin_arr();
for (int m = 0; m < cfg.num_materials; ++m) {
w.begin_obj();
w.kv_str("name", ("Material_" + std::to_string(m)).c_str());
w.key("pbrMetallicRoughness"); w.begin_obj();
w.key("baseColorFactor"); w.begin_arr();
float hue = (float)m / (float)cfg.num_materials;
w.val_double(0.5 + 0.5 * sin(hue * 6.28));
w.val_double(0.5 + 0.5 * sin(hue * 6.28 + 2.09));
w.val_double(0.5 + 0.5 * sin(hue * 6.28 + 4.19));
w.val_double(1.0);
w.end_arr();
w.kv_double("metallicFactor", 0.2 + 0.6 * ((double)m / cfg.num_materials));
w.kv_double("roughnessFactor", 0.3 + 0.5 * ((double)(cfg.num_materials - m) / cfg.num_materials));
w.end_obj();
w.end_obj();
}
w.end_arr();
/* accessors */
w.key("accessors"); w.begin_arr();
for (size_t i = 0; i < accessors.size(); ++i) {
const AccessorInfo &a = accessors[i];
w.begin_obj();
w.kv_int("bufferView", a.buffer_view);
w.kv_int("componentType", a.component_type);
w.kv_int("count", a.count);
w.kv_str("type", a.type);
if (a.min_max_components == 1) {
w.key("min"); w.begin_arr(); w.val_double(a.min_vals[0]); w.end_arr();
w.key("max"); w.begin_arr(); w.val_double(a.max_vals[0]); w.end_arr();
} else if (a.min_max_components == 3) {
w.key("min"); w.begin_arr();
w.val_double(a.min_vals[0]); w.val_double(a.min_vals[1]); w.val_double(a.min_vals[2]);
w.end_arr();
w.key("max"); w.begin_arr();
w.val_double(a.max_vals[0]); w.val_double(a.max_vals[1]); w.val_double(a.max_vals[2]);
w.end_arr();
}
w.end_obj();
}
w.end_arr();
/* bufferViews */
w.key("bufferViews"); w.begin_arr();
for (int i = 0; i < bv_idx; ++i) {
w.begin_obj();
w.kv_int("buffer", 0);
w.kv_int("byteOffset", (int64_t)bv_offsets[i]);
w.kv_int("byteLength", (int64_t)bv_lengths[i]);
w.end_obj();
}
w.end_arr();
/* buffers */
w.key("buffers"); w.begin_arr();
w.begin_obj();
w.kv_int("byteLength", (int64_t)total_bin);
/* URI will be set by caller for .gltf, omitted for .glb */
w.end_obj();
w.end_arr();
/* animations */
if (cfg.num_animations > 0) {
w.key("animations"); w.begin_arr();
for (int a = 0; a < cfg.num_animations; ++a) {
int time_acc = anim_time_accessor_start + a * 2;
int val_acc = time_acc + 1;
/* Target node: cycle through available nodes */
int target_node = a % cfg.num_nodes;
w.begin_obj();
w.kv_str("name", ("Anim_" + std::to_string(a)).c_str());
w.key("channels"); w.begin_arr();
w.begin_obj();
w.kv_int("sampler", 0);
w.key("target"); w.begin_obj();
w.kv_int("node", target_node);
w.kv_str("path", "translation");
w.end_obj();
w.end_obj();
w.end_arr();
w.key("samplers"); w.begin_arr();
w.begin_obj();
w.kv_int("input", time_acc);
w.kv_int("output", val_acc);
w.kv_str("interpolation", "LINEAR");
w.end_obj();
w.end_arr();
w.end_obj();
}
w.end_arr();
}
w.end_obj();
out_json = w.buf;
out_bin = bin.data;
}
/* ------------------------------------------------------------------ */
/* Write .gltf + .bin */
/* ------------------------------------------------------------------ */
static void write_gltf(const std::string &prefix, const std::string &label,
const std::string &json_str,
const std::vector<uint8_t> &bin_data) {
std::string bin_name = prefix + "_" + label + ".bin";
std::string gltf_name = prefix + "_" + label + ".gltf";
/* Inject "uri" into the buffer object in JSON */
std::string json_patched = json_str;
/* Find the buffers array and add uri before the closing } of the buffer */
size_t pos = json_patched.find("\"byteLength\"");
if (pos != std::string::npos) {
/* Find the line end after byteLength value */
size_t line_end = json_patched.find('\n', pos);
if (line_end != std::string::npos) {
/* Extract just the filename for uri */
std::string bin_filename = prefix + "_" + label + ".bin";
std::string uri_line = ",\n \"uri\": \"" + bin_filename + "\"";
json_patched.insert(line_end, uri_line);
}
}
/* Write .bin */
FILE *f = fopen(bin_name.c_str(), "wb");
if (f) {
fwrite(bin_data.data(), 1, bin_data.size(), f);
fclose(f);
}
/* Write .gltf */
f = fopen(gltf_name.c_str(), "w");
if (f) {
fwrite(json_patched.c_str(), 1, json_patched.size(), f);
fclose(f);
}
printf(" Written: %s (%zu bytes JSON) + %s (%zu bytes binary)\n",
gltf_name.c_str(), json_patched.size(),
bin_name.c_str(), bin_data.size());
}
/* ------------------------------------------------------------------ */
/* Write .glb */
/* ------------------------------------------------------------------ */
static void write_glb(const std::string &prefix, const std::string &label,
const std::string &json_str,
const std::vector<uint8_t> &bin_data) {
std::string glb_name = prefix + "_" + label + ".glb";
uint32_t json_len = (uint32_t)json_str.size();
uint32_t json_padded = (json_len + 3) & ~3u;
uint32_t bin_len = (uint32_t)bin_data.size();
uint32_t bin_padded = (bin_len + 3) & ~3u;
uint32_t total = 12 + 8 + json_padded + 8 + bin_padded;
FILE *f = fopen(glb_name.c_str(), "wb");
if (!f) return;
/* Header */
fwrite("glTF", 1, 4, f);
uint32_t version = 2;
fwrite(&version, 4, 1, f);
fwrite(&total, 4, 1, f);
/* JSON chunk */
uint32_t json_type = 0x4E4F534A;
fwrite(&json_padded, 4, 1, f);
fwrite(&json_type, 4, 1, f);
fwrite(json_str.c_str(), 1, json_len, f);
for (uint32_t i = json_len; i < json_padded; ++i) {
char sp = ' ';
fwrite(&sp, 1, 1, f);
}
/* BIN chunk */
uint32_t bin_type = 0x004E4942;
fwrite(&bin_padded, 4, 1, f);
fwrite(&bin_type, 4, 1, f);
fwrite(bin_data.data(), 1, bin_len, f);
for (uint32_t i = bin_len; i < bin_padded; ++i) {
char z = 0;
fwrite(&z, 1, 1, f);
}
fclose(f);
printf(" Written: %s (%u bytes)\n", glb_name.c_str(), total);
}
/* ------------------------------------------------------------------ */
/* Preset configurations */
/* ------------------------------------------------------------------ */
struct Preset {
const char *label;
SceneConfig cfg;
};
static Preset presets[] = {
{"tiny", {1, 100, 2, 1, 0, 0}},
{"small", {5, 1000, 10, 3, 2, 50}},
{"medium", {20, 5000, 50, 10, 5, 200}},
{"large", {100, 10000, 200, 20, 10, 500}},
{"huge", {500, 50000, 1000, 50, 50, 1000}},
};
static const int num_presets = (int)(sizeof(presets) / sizeof(presets[0]));
/* ------------------------------------------------------------------ */
/* Generate float-heavy scene (~500MB of ASCII float values in JSON) */
/* ------------------------------------------------------------------ */
static void generate_float_heavy(const std::string &prefix, size_t target_mb) {
std::string gltf_name = prefix + "_float_heavy.gltf";
FILE *f = fopen(gltf_name.c_str(), "w");
if (!f) {
fprintf(stderr, "Cannot open %s\n", gltf_name.c_str());
return;
}
/* Write minimal valid glTF with massive extras float array */
fprintf(f, "{\n");
fprintf(f, " \"asset\": {\"version\": \"2.0\", \"generator\": \"tinygltf_benchmark_gen\"},\n");
fprintf(f, " \"scene\": 0,\n");
fprintf(f, " \"scenes\": [{\"name\": \"FloatHeavy\", \"nodes\": [0]}],\n");
fprintf(f, " \"nodes\": [{\"name\": \"Root\"}],\n");
fprintf(f, " \"extras\": {\n");
size_t target_bytes = target_mb * 1024ULL * 1024ULL;
size_t total_written = 0;
int num_channels = 10;
size_t per_channel = target_bytes / (size_t)num_channels;
for (int ch = 0; ch < num_channels; ++ch) {
fprintf(f, " \"channel_%d\": [\n ", ch);
size_t ch_written = 0;
size_t count = 0;
uint64_t seed = (uint64_t)ch * 7919ULL + 1;
bool first = true;
while (ch_written < per_channel) {
/* Comma before every value except the first */
if (!first) {
fwrite(",\n ", 1, 8, f);
ch_written += 8;
}
first = false;
/* Generate varied float values: mix of magnitudes and precisions */
seed = seed * 6364136223846793005ULL + 1442695040888963407ULL;
double raw = (double)(int64_t)seed / (double)INT64_MAX;
double val;
int kind = (int)(count % 5);
switch (kind) {
case 0: val = raw * 1000.0; break; /* large: -999.xxx */
case 1: val = raw * 0.001; break; /* small: 0.000xxx */
case 2: val = raw * 3.14159265358979; break; /* medium: -3.14..3.14 */
case 3: val = raw * 1e6; break; /* very large */
case 4: val = raw * 1e-6; break; /* very small */
default: val = raw; break;
}
char buf[64];
int len = snprintf(buf, sizeof(buf), "%.8g", val);
fwrite(buf, 1, (size_t)len, f);
ch_written += (size_t)len;
count++;
}
total_written += ch_written;
if (ch < num_channels - 1) {
fprintf(f, "\n ],\n");
} else {
fprintf(f, "\n ]\n");
}
}
fprintf(f, " }\n");
fprintf(f, "}\n");
fclose(f);
/* Report actual file size */
f = fopen(gltf_name.c_str(), "rb");
if (f) {
fseek(f, 0, SEEK_END);
long sz = ftell(f);
fclose(f);
printf(" Written: %s (%.1f MB, ~%zu float values across %d channels)\n",
gltf_name.c_str(), (double)sz / (1024.0 * 1024.0),
total_written / 12, num_channels);
}
}
/* ------------------------------------------------------------------ */
/* Main */
/* ------------------------------------------------------------------ */
int main(int argc, char **argv) {
std::string prefix = "synthetic";
/* Parse args */
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--prefix") == 0 && i + 1 < argc) {
prefix = argv[++i];
}
}
printf("Generating synthetic glTF benchmark scenes...\n\n");
for (int p = 0; p < num_presets; ++p) {
const Preset &pr = presets[p];
printf("[%s] meshes=%d verts/mesh=%d nodes=%d materials=%d "
"animations=%d keyframes=%d\n",
pr.label, pr.cfg.num_meshes, pr.cfg.verts_per_mesh,
pr.cfg.num_nodes, pr.cfg.num_materials,
pr.cfg.num_animations, pr.cfg.keyframes);
std::string json;
std::vector<uint8_t> bin;
generate_scene(pr.cfg, json, bin);
write_gltf(prefix, pr.label, json, bin);
write_glb(prefix, pr.label, json, bin);
printf("\n");
}
/* Float-heavy scene: ~500MB of ASCII floats in JSON */
printf("[float_heavy] ~500MB of ASCII float values in JSON extras\n");
generate_float_heavy(prefix, 500);
printf("\n");
printf("Done.\n");
return 0;
}
View File
View File

Some files were not shown because too many files have changed in this diff Show More