Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static glTF support #14557

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ec59500
Add glTF loader for static meshes
JosiahWI Oct 16, 2022
2627672
Remove EAMT_GLTF as it serves no purpose
JosiahWI May 21, 2024
1baa3f1
Clean up code style
JosiahWI May 21, 2024
b9b0355
Use main project cxx standard for unit tests
JosiahWI May 21, 2024
c803a9c
Add comment clarifying linking of object libraries
JosiahWI May 21, 2024
da722a8
Compile with runtime type information
JosiahWI May 21, 2024
b95dcb7
Preallocate the indices vector
JosiahWI May 21, 2024
5bd1d05
Remove unused method isSparseAccessor
JosiahWI May 21, 2024
8a2cae1
Mark transformation matrices as const
JosiahWI May 21, 2024
411969c
Bring accessor implementation from other branch over
appgurueu May 21, 2024
315c03b
Change "reflecting" to "mirroring" for readability
JosiahWI May 21, 2024
00d23d6
Add SPDX-License-Identifiers
appgurueu May 21, 2024
a2311dc
Check that enough bytes could be read
appgurueu May 21, 2024
a372397
Remove now obsolete getters for accessor indices
appgurueu May 21, 2024
818ac9e
Replace some spaces with tabs
appgurueu May 21, 2024
b734119
Move data directly rather than copying
appgurueu May 21, 2024
d4de89c
Remove unnecessary constructor
appgurueu May 21, 2024
88383e4
Reduce verbosity by introducing SelfType alias
appgurueu May 21, 2024
942d46d
Remove unused includes
appgurueu May 21, 2024
28299e7
Program more defensively
JosiahWI May 22, 2024
3a4dde4
Remove unneeded header
JosiahWI May 22, 2024
b419d0e
Use __BIG_ENDIAN_
JosiahWI May 22, 2024
be375cd
Do not stack-allocate SSkinMeshBuffer
appgurueu May 22, 2024
8c35461
Fix/improve reading from accessors
appgurueu May 22, 2024
b45aa1c
Get unit tests to build
JosiahWI May 22, 2024
0eef3b0
Fix minetestserver build
JosiahWI May 22, 2024
d4d9035
Fix improper unit test paths
JosiahWI May 22, 2024
8f6c24c
Fix improper unit tests paths again
JosiahWI May 22, 2024
2a9e570
Fix strict aliasing violations in glTF tests
JosiahWI May 22, 2024
d5450c6
Add f postfix to floating point test values
JosiahWI May 22, 2024
50d20a8
Fix -Wsign-compare warning
appgurueu Jun 7, 2024
50c8604
Fix snow man test texture coordinates
appgurueu Jun 7, 2024
59a173b
Clean up unit tests
appgurueu Jun 7, 2024
451978d
Move everything to sections of one big "gltf" test case
appgurueu Jun 8, 2024
1d185c1
Fix triangle with vertex stride test case
appgurueu Jun 8, 2024
580a715
Improve docs
appgurueu Jun 8, 2024
be03a43
Add copy & move constructor from STL string to Irrlicht string
appgurueu Jun 8, 2024
37c3edf
Move test assets to devtest, add corresponding entities
appgurueu Jun 8, 2024
9979264
Test fixes (get rid of device creation, fix error case tests)
appgurueu Jun 8, 2024
d6b6eec
Address minor TODOs in tiniergltf
appgurueu Jun 8, 2024
3969166
Add spider model
appgurueu Jun 8, 2024
616a27a
Work around lack of SKIP
appgurueu Jun 8, 2024
0ce6b3f
Implement clang-tidy suggestions in tiniergltf
appgurueu Jun 8, 2024
31ab21f
Update devtest mod count, add mod.conf
appgurueu Jun 8, 2024
8547a33
Use SKIP now that we can
appgurueu Jun 12, 2024
35466b2
Add applicable tests from animated branch
appgurueu Jun 12, 2024
3467d91
Fix sparse accessor handling in tiniergltf
appgurueu Jun 12, 2024
196bb56
Fix invalid bufferview bounds test
appgurueu Jun 12, 2024
6be3c1a
Rename (& minify) files to follow naming conventions
appgurueu Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add applicable tests from animated branch
  • Loading branch information
appgurueu committed Jun 12, 2024
commit 35466b227ac0dff5845d629af69f32c2cc170e73
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"scene":0,"scenes":[{"nodes":[0]}],"nodes":[{"mesh":0}],"meshes":[{"primitives":[{"attributes":{"POSITION":0}}]}],"buffers":[{"uri":"data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAA","byteLength":36}],"bufferViews":[{"buffer":0,"byteOffset":1,"byteLength":36,"target":34962}],"accessors":[{"bufferView":0,"byteOffset":0,"componentType":5126,"count":3,"type":"VEC3","max":[1,1,0],"min":[0,0,0]}],"asset":{"version":"2.0"}}
1 change: 1 addition & 0 deletions games/devtest/mods/gltf/models/simple_sparse_accessor.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"scene":0,"scenes":[{"nodes":[0]}],"nodes":[{"mesh":0}],"meshes":[{"primitives":[{"attributes":{"POSITION":1},"indices":0}]}],"buffers":[{"uri":"data:application/gltf-buffer;base64,AAAIAAcAAAABAAgAAQAJAAgAAQACAAkAAgAKAAkAAgADAAoAAwALAAoAAwAEAAsABAAMAAsABAAFAAwABQANAAwABQAGAA0AAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAQAAAAAAAAAAAAABAQAAAAAAAAAAAAACAQAAAAAAAAAAAAACgQAAAAAAAAAAAAADAQAAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAgD8AAAAAAAAAQAAAgD8AAAAAAABAQAAAgD8AAAAAAACAQAAAgD8AAAAAAACgQAAAgD8AAAAAAADAQAAAgD8AAAAACAAKAAwAAAAAAIA/AAAAQAAAAAAAAEBAAABAQAAAAAAAAKBAAACAQAAAAAA=","byteLength":284}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":72,"target":34963},{"buffer":0,"byteOffset":72,"byteLength":168},{"buffer":0,"byteOffset":240,"byteLength":6},{"buffer":0,"byteOffset":248,"byteLength":36}],"accessors":[{"bufferView":0,"byteOffset":0,"componentType":5123,"count":36,"type":"SCALAR","max":[13],"min":[0]},{"bufferView":1,"byteOffset":0,"componentType":5126,"count":14,"type":"VEC3","max":[6,4,0],"min":[0,0,0],"sparse":{"count":3,"indices":{"bufferView":2,"byteOffset":0,"componentType":5123},"values":{"bufferView":3,"byteOffset":0}}}],"asset":{"version":"2.0"}}
35 changes: 35 additions & 0 deletions src/unittest/test_irr_gltf_mesh_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ SECTION("error cases") {
SECTION("invalid JSON") {
CHECK(loadMesh(invalid_model_path + "json_missing_brace.gltf") == nullptr);
}

// This is an example of something that should be validated by tiniergltf.
SECTION("invalid bufferview bounds")
{
CHECK(loadMesh(invalid_model_path + "invalid_bufferview_bounds.gltf") == nullptr);
}
}

SECTION("minimal triangle") {
Expand Down Expand Up @@ -329,4 +335,33 @@ SECTION("snow man") {
}
}

// https://github.com/KhronosGroup/glTF-Sample-Models/tree/main/2.0/SimpleSparseAccessor
SECTION("simple sparse accessor")
{
const auto mesh = loadMesh(model_path + "simple_sparse_accessor.gltf");
REQUIRE(mesh != nullptr);
const auto *vertices = reinterpret_cast<irr::video::S3DVertex *>(
mesh->getMeshBuffer(0)->getVertices());
const std::array<v3f, 14> expectedPositions = {
// Lower
v3f(0, 0, 0),
v3f(1, 0, 0),
v3f(2, 0, 0),
v3f(3, 0, 0),
v3f(4, 0, 0),
v3f(5, 0, 0),
v3f(6, 0, 0),
// Upper
v3f(0, 1, 0),
v3f(1, 2, 0), // overridden
v3f(2, 1, 0),
v3f(3, 3, 0), // overridden
v3f(4, 1, 0),
v3f(5, 4, 0), // overridden
v3f(6, 1, 0),
};
for (std::size_t i = 0; i < expectedPositions.size(); ++i)
CHECK(vertices[i].Pos == expectedPositions[i]);
}

}