Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Static glTF mesh loading #200

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
36a90e9
Add tinygltf library
JosiahWI Oct 16, 2022
a3b2dbd
Export tinygltf target
JosiahWI Oct 16, 2022
a0b7a15
Do CMake right
JosiahWI Oct 17, 2022
bde174d
Add GLTF mesh file loader
JosiahWI Oct 17, 2022
92862a3
Add test file for glTF mesh loading
JosiahWI Oct 17, 2022
4b6ab05
Run tests in Linux GL CI build
JosiahWI Oct 17, 2022
7900f0a
Fix path to tests in CI and use Ninja
JosiahWI Oct 17, 2022
a9f56df
Test that minimal triangle returns some mesh
JosiahWI Oct 17, 2022
5e2d9d9
Test that minimal triangle has correct vertices
JosiahWI Oct 17, 2022
30d5748
Test case when file is nullptr
JosiahWI Oct 17, 2022
2ae436c
Update vertex test for coordinate system
JosiahWI Oct 17, 2022
8c9c1e5
Specify all source fools directly on IrrlichtMt
JosiahWI Oct 18, 2022
21c3c16
Test invalid JSON
JosiahWI Oct 22, 2022
a20ac71
Load vertex coordinates from glTF buffer
JosiahWI Nov 6, 2022
3d2d3f8
Remove constexpr from readFloat
JosiahWI Nov 7, 2022
b4c4325
Add CI build for CMake 3.5 with GCC 5.3
JosiahWI Nov 7, 2022
82c547d
Test for correct vertex indices
JosiahWI Nov 10, 2022
12b760e
Use a better action for getting CMake 3.5
JosiahWI Nov 10, 2022
837b6be
Add test for blender cube
JosiahWI Nov 11, 2022
742307f
Scale cube vertices correctly
JosiahWI Nov 12, 2022
72cb09a
Test for texture coordinates on cube
JosiahWI Nov 12, 2022
7220104
Test vertex normals on cube
JosiahWI Nov 12, 2022
cdad3a8
Switch to fixed branch of lukka/get-cmake action
JosiahWI Nov 12, 2022
3dc24ab
Remove DESCRIPTION from tinygltf project
JosiahWI Nov 13, 2022
47a195b
Fix aliasing violation when reading primitives
JosiahWI Nov 13, 2022
a326f27
Fix coordinate system change
JosiahWI Nov 14, 2022
f1042bf
Update to latest branch of lukka/get-cmake
JosiahWI Nov 14, 2022
0216a02
Fix segfault from reading bad number of indices
JosiahWI Nov 15, 2022
08d226c
Fix indices, inverted models, & multiple models failing to load
jordan4ibanez Jan 28, 2023
4a8602e
Fix embedded textures causing a model not to load
jordan4ibanez Jan 28, 2023
971a9e2
Update code with requested changes
jordan4ibanez Jan 29, 2023
030abc7
spaces->tabs
jordan4ibanez Jan 31, 2023
246ee9c
Register Catch2 tests with CTest
JosiahWI Jan 31, 2023
5a190a6
Mark CGLTFMeshFileLoader constructor as noexcept
JosiahWI May 13, 2023
673de22
Do not fail to load glTF because of warnings
JosiahWI May 13, 2023
a3633af
Clarify behavior of BUILD_TESTING option in README
JosiahWI May 15, 2023
eaebd34
Remove unneeded tinygltf include from header
JosiahWI May 15, 2023
c9e05c6
Work around cmake<3.12 object target rules
JosiahWI May 15, 2023
4d4d8df
Work around TestBigEndian bug in cmake<3.9
JosiahWI May 15, 2023
9f2d5a1
Fix indentation style in CMakeLists
JosiahWI May 15, 2023
7741238
Set C compiler to g++-5 on minimum-cmake CI
JosiahWI May 15, 2023
5bae506
Set C compiler to gcc-5 for minimum-cmake CI
JosiahWI May 15, 2023
3bbf3f7
Disable -Werror on minimum-cmake CI
JosiahWI May 15, 2023
2175cf6
Restore path accidentally removed in 584a46f
JosiahWI May 15, 2023
7e0d57b
Reorganize CGLTFMeshFileLoader help functions
JosiahWI May 17, 2023
2dbe3b8
Fix CMake tinygltf dependencies
JosiahWI May 17, 2023
79bfd8a
Move parsing methods into ModelParser class
JosiahWI May 17, 2023
85fdf95
Fix function declaration indents
JosiahWI May 17, 2023
50da042
Add r-value reference constructor to ModelParser
JosiahWI May 17, 2023
8c9a576
Convert snake_case variable names to camelCase
JosiahWI May 17, 2023
5f5dd7a
Document coordinate system change at top of source
JosiahWI May 17, 2023
ea22b64
Refactor getIndices()
JosiahWI May 17, 2023
60a5f57
Return vector from getVertices
JosiahWI May 17, 2023
fd41ee0
Add const to numeric parameters
JosiahWI May 18, 2023
22f6012
Document readVec3DF and getScale
JosiahWI May 18, 2023
0f73c30
Mark ModelParser constructors noexcept
JosiahWI May 18, 2023
3930bd8
Rename ModelParser to MeshExtractor
JosiahWI May 18, 2023
0896aae
Extract loadPrimitives method from createMesh
JosiahWI May 18, 2023
53c92b0
Refactor vertex loading
JosiahWI May 18, 2023
16b7841
Print glTF loading issues to log
JosiahWI Oct 8, 2023
05ede68
Borrow CReadFile for tests
JosiahWI Nov 29, 2023
eabc84a
Do not install tinygltf export from Irrlicht
JosiahWI Nov 29, 2023
86026f9
Add operator<< definition for vector3d
JosiahWI Nov 30, 2023
95a4030
Handle byte stride on vertex buffers
JosiahWI Nov 30, 2023
f8f1024
Package glTF spec docs with comments
jordan4ibanez Dec 1, 2023
e2b05f0
Fix memory leak caused by missing `drop`
appgurueu Dec 1, 2023
f33b8a6
Axe the minimum-cmake CI build
JosiahWI Dec 2, 2023
777ec9d
Fix getScale()
jordan4ibanez Dec 2, 2023
0faf132
Move from tinygltf to tiniergltf (#13)
appgurueu Jan 19, 2024
036b40a
Fix gltf static mesh loading issues (#14)
appgurueu Apr 15, 2024
718c865
Move files
JosiahWI Apr 18, 2024
df4dd7b
Move libs
JosiahWI Apr 18, 2024
c263a28
Fix rebase mistakes in CMakeLists
JosiahWI Apr 18, 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
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
run: |
cmake . -DUSE_SDL2=OFF
make VERBOSE=1 -j2

- name: Test
run: |
./bin/Linux/tests

- name: Test
run: |
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@ scripts/glext.h

# vscode cmake plugin
build/*

# vscode clangd plugin
.cache
compile_commands.json

# build dependencies
_deps

# autogenerated test-related files
**/CTestTestfile.cmake
Testing
DartConfiguration.tcl
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"*.tcc": "cpp",
"iomanip": "cpp"
}
}
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ cmake_minimum_required(VERSION 3.12)

set(IRRLICHTMT_REVISION 15)

# workaround: cmake<3.9 requires C language for internal checks
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/487
project(Irrlicht
VERSION 1.9.0.${IRRLICHTMT_REVISION}
LANGUAGES CXX
LANGUAGES C CXX
)

message(STATUS "*** Building IrrlichtMt ${PROJECT_VERSION} ***")
Expand Down Expand Up @@ -33,9 +35,22 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
endif()

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
enable_testing()
add_subdirectory(src)

add_subdirectory(source/lib/catch2)
include(FetchContent)
FetchContent_Declare(
tiniergltf
GIT_REPOSITORY https://github.com/appgurueu/tiniergltf.git
GIT_TAG 05572e691ecf8bc3fce2da76251e73779b3577e6
)
FetchContent_MakeAvailable(tiniergltf)
add_subdirectory(source/Irrlicht)
add_subdirectory(test)

option(BUILD_EXAMPLES "Build example applications" FALSE)
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ The following libraries are required to be installed:
Aside from standard search options (`ZLIB_INCLUDE_DIR`, `ZLIB_LIBRARY`, ...) the following options are available:
* `BUILD_SHARED_LIBS` (default: `ON`) - Build IrrlichtMt as a shared library
* `BUILD_EXAMPLES` (default: `OFF`) - Build example applications
* `BUILD_TESTING` (default: `ON`) - Build Catch2 tests (only in top-level project)
* `ENABLE_OPENGL` - Enable OpenGL driver
* `ENABLE_OPENGL3` (default: `OFF`) - Enable OpenGL 3+ driver
* `ENABLE_GLES1` - Enable OpenGL ES driver, legacy
* `ENABLE_GLES2` - Enable OpenGL ES 2+ driver
* `USE_SDL2` (default: platform-dependent, usually `ON`) - Use SDL2 instead of older native device code
* `BUILD_TESTING` (default: `ON`) - Build Catch2 tests

e.g. on a Linux system you might want to build for local use like this:

Expand All @@ -49,6 +51,19 @@ Run the following script in PowerShell:
cd irrlicht
cmake -B build -G "Visual Studio 17 2022" -A "Win64" -DCMAKE_TOOLCHAIN_FILE=[vcpkg-root]/scripts/buildsystems/vcpkg.cmake -DBUILD_SHARED_LIBS=OFF
cmake --build build --config Release

Test
----

To run the Catch2 tests, the project must first be built with `BUILD_TESTING` enabled.

The tests can be run with ctest:

cd build
ctest

Run the tests directly for more detailed output:
build/bin/<sysname>/tests

Platforms
---------
Expand Down
3 changes: 3 additions & 0 deletions include/IMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ enum E_ANIMATED_MESH_TYPE
//! Halflife MDL model file
EAMT_MDL_HALFLIFE,

//! Graphics Language Transmission Format 2.0 (.gltf) mesh
EAMT_GLTF2,

//! generic skinned mesh
EAMT_SKINNED,

Expand Down
26 changes: 25 additions & 1 deletion include/SSkinMeshBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,31 @@ struct SSkinMeshBuffer : public IMeshBuffer
}

//! append the vertices and indices to the current buffer
void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override {}
void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) override {
if (vertices == getVertices())
throw std::logic_error("can't append own vertices");

if (VertexType != video::EVT_STANDARD)
throw std::logic_error("invalid vertex type");

const u32 prevVertexCount = getVertexCount();

Vertices_Standard.reallocate(prevVertexCount + numVertices);
for (u32 i=0; i < numVertices; ++i) {
Vertices_Standard.push_back(static_cast<const video::S3DVertex* const>(vertices)[i]);
BoundingBox.addInternalPoint(static_cast<const video::S3DVertex* const>(vertices)[i].Pos);
}

Indices.reallocate(getIndexCount() + numIndices);
for (u32 i=0; i < numIndices; ++i) {
Indices.push_back(indices[i] + prevVertexCount);
}
}

//! NOT IMPLEMENTED YET: append the meshbuffer to the current buffer
void append(const IMeshBuffer* const other) override {
throw std::logic_error("not implemented yet");
}

//! get the current hardware mapping hint for vertex buffers
E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override
Expand Down
Loading
Loading