Skip to content

Commit

Permalink
Merge pull request #106 from CesiumGS/gltf
Browse files Browse the repository at this point in the history
Replace tinygltf
  • Loading branch information
kring authored Feb 2, 2021
2 parents 49a7393 + e692908 commit c3d35cf
Show file tree
Hide file tree
Showing 197 changed files with 9,830 additions and 931 deletions.
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "extern/tinygltf"]
path = extern/tinygltf
url = https://github.com/syoyo/tinygltf
[submodule "extern/glm"]
path = extern/glm
url = https://github.com/g-truc/glm.git
Expand Down Expand Up @@ -28,3 +25,9 @@
[submodule "extern/rapidjson"]
path = extern/rapidjson
url = https://github.com/Tencent/rapidjson.git
[submodule "extern/glTF"]
path = extern/glTF
url = https://github.com/KhronosGroup/glTF.git
[submodule "extern/stb"]
path = extern/stb
url = https://github.com/nothings/stb.git
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@
"shared_mutex": "cpp",
"gsl_assert": "cpp",
"compare": "cpp",
"resumable": "cpp"
"resumable": "cpp",
"codecvt": "cpp",
"ranges": "cpp",
"scoped_allocator": "cpp",
"typeindex": "cpp"
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.configureOnOpen": true
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ target_link_libraries(cesium-native-tests PUBLIC Catch2::Catch2)
add_subdirectory(CesiumUtility)
add_subdirectory(CesiumGeometry)
add_subdirectory(CesiumGeospatial)
add_subdirectory(CesiumGltf)
add_subdirectory(CesiumGltfReader)
add_subdirectory(CesiumAsync)
add_subdirectory(Cesium3DTiles)

Expand Down
7 changes: 2 additions & 5 deletions Cesium3DTiles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ target_sources(
target_include_directories(
Cesium3DTiles
SYSTEM PUBLIC
# We're not using CMake for tinygltf at all, but it's header only. Add its headers here.
${CMAKE_CURRENT_SOURCE_DIR}/../extern/tinygltf

# Same with RapidJSON
${CMAKE_CURRENT_SOURCE_DIR}/../extern/rapidjson/include

# Draco's CMake doesn't use target_include_directories, so we need to manually add draco's include dirs here.
${CMAKE_CURRENT_SOURCE_DIR}/../extern/draco/src

${CMAKE_BINARY_DIR}
PUBLIC
include
Expand All @@ -33,4 +30,4 @@ target_include_directories(
"$<BUILD_INTERFACE:$<$<BOOL:$<TARGET_PROPERTY:Cesium3DTiles_PRIVATE_SRC>>:${CMAKE_CURRENT_SOURCE_DIR}/src>>"
)

target_link_libraries(Cesium3DTiles PUBLIC CesiumAsync CesiumGeospatial CesiumGeometry CesiumUtility uriparser draco tinyxml2 spdlog)
target_link_libraries(Cesium3DTiles PUBLIC CesiumAsync CesiumGeospatial CesiumGeometry CesiumGltf CesiumGltfReader CesiumUtility uriparser draco tinyxml2 spdlog)
56 changes: 13 additions & 43 deletions Cesium3DTiles/include/Cesium3DTiles/Gltf.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#pragma once

#include "Cesium3DTiles/Library.h"
#include "CesiumGltf/Model.h"
#include <glm/mat4x4.hpp>
#include <gsl/span>
#include <optional>
#include <tiny_gltf.h>
#include <functional>

namespace Cesium3DTiles {

/**
* @brief Functions for loading and processing glTF models.
*
* This class offers basic functions for loading glTF models as `tinygltf::Model`
* This class offers basic functions for loading glTF models as `CesiumGltf::Model`
* instances, and for processing the mesh primitives that appear in the resulting
* models.
*/
Expand All @@ -22,45 +23,14 @@ namespace Cesium3DTiles {
/** @brief This class cannot be instantiated */
Gltf() = delete;

/**
* @brief A summary of the result of loading a glTF model from raw data.
*/
struct LoadResult {
/**
* @brief The gltf model that was loaded.
*
* This will be `std::nullopt` if the model was not loaded successfully.
*/
std::optional<tinygltf::Model> model;

/**
* @brief Warning messages from the attempt to load the model.
*/
std::string warnings;

/**
* @brief Error messages from the attempt to load the model.
*/
std::string errors;
};

/**
* @brief Load a glTF model from the given input data.
*
* @param data The input data.
* @return The {@link LoadResult} containing the model (if it could be loaded),
* and possible warning- or error messages.
*/
static LoadResult load(const gsl::span<const uint8_t>& data);

/**
* @brief A callback function for {@link Gltf::forEachPrimitiveInScene}.
*/
typedef void ForEachPrimitiveInSceneCallback(
tinygltf::Model& gltf,
tinygltf::Node& node,
tinygltf::Mesh& mesh,
tinygltf::Primitive& primitive,
CesiumGltf::Model& gltf,
CesiumGltf::Node& node,
CesiumGltf::Mesh& mesh,
CesiumGltf::MeshPrimitive& primitive,
const glm::dmat4& transform
);

Expand All @@ -86,21 +56,21 @@ namespace Cesium3DTiles {
* @param sceneID The scene ID (index)
* @param callback The callback to apply
*/
static void forEachPrimitiveInScene(tinygltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneCallback>&& callback);
static void forEachPrimitiveInScene(CesiumGltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneCallback>&& callback);

/**
* @brief A callback function for {@link Gltf::forEachPrimitiveInScene}.
*/
typedef void ForEachPrimitiveInSceneConstCallback(
const tinygltf::Model& gltf,
const tinygltf::Node& node,
const tinygltf::Mesh& mesh,
const tinygltf::Primitive& primitive,
const CesiumGltf::Model& gltf,
const CesiumGltf::Node& node,
const CesiumGltf::Mesh& mesh,
const CesiumGltf::MeshPrimitive& primitive,
const glm::dmat4& transform
);

/** @copydoc Gltf::forEachPrimitiveInScene() */
static void forEachPrimitiveInScene(const tinygltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneConstCallback>&& callback);
static void forEachPrimitiveInScene(const CesiumGltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneConstCallback>&& callback);
};


Expand Down
154 changes: 0 additions & 154 deletions Cesium3DTiles/include/Cesium3DTiles/GltfAccessor.h

This file was deleted.

2 changes: 1 addition & 1 deletion Cesium3DTiles/include/Cesium3DTiles/GltfContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Cesium3DTiles {
* @return The bounding region.
*/
static CesiumGeospatial::BoundingRegion createRasterOverlayTextureCoordinates(
tinygltf::Model& gltf,
CesiumGltf::Model& gltf,
uint32_t textureCoordinateID,
const CesiumGeospatial::Projection& projection,
const CesiumGeometry::Rectangle& rectangle
Expand Down
Loading

0 comments on commit c3d35cf

Please sign in to comment.