162 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Selmar
a63cc6373d
correct Value::Equals mistake
a missing exclamation mark... ^^
2019-04-16 16:57:43 +02:00
Fabien Freling
9056aee823 Serialize accessor 'normalized' attribute. 2019-03-21 17:06:22 +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
Arthur Brainville (Ybalrid)
9223d3133a Ran clang-format on tiny_gltf.h 2019-03-06 14:00:56 +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
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
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
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
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
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
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
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
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
af3ebb2e76 Show more expressive messages when parsing image. 2019-01-06 18:55:57 +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
Peter Le Bek
463408c4a0 Fix incorrect index into bufferViews array 2018-12-08 16:04:42 -08:00
viperscape
9df05806ad find missing bufferView target types and fill them in 2018-12-05 14:11:01 -05: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