forked from CesiumGS/cesium-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce cesium-native library and move most of the code there.
- Loading branch information
0 parents
commit 2762434
Showing
57 changed files
with
2,507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"files.associations": { | ||
"variant": "cpp", | ||
"cmath": "cpp", | ||
"xutility": "cpp", | ||
"random": "cpp", | ||
"optional": "cpp", | ||
"type_traits": "cpp" | ||
}, | ||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.17) | ||
project( | ||
cesium-native | ||
VERSION 0.1.0 | ||
LANGUAGES CXX | ||
) | ||
|
||
# Use the multithreaded, release, DLL version of the runtime library no matter what. | ||
# This is appropriate for Unreal Engine, but needs to be configurable for other things. | ||
set(MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" CACHE STRING "MSVC runtime library") | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/extern/Catch2/contrib") | ||
|
||
include(CTest) | ||
enable_testing() | ||
|
||
# set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | ||
# set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) | ||
# include(CPack) | ||
|
||
add_subdirectory(extern/Catch2) | ||
add_subdirectory(extern/GSL) | ||
|
||
# set(CMAKE_BUILD_TYPE ${ORIGINAL_CMAKE_BUILD_TYPE}) | ||
add_subdirectory(src) | ||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Cesium Native (for Unreal Engine) | ||
|
||
## Prerequisites | ||
|
||
* Visual Studio 2019 | ||
* CMake (add it to your path during install!) | ||
|
||
## Getting Started | ||
|
||
* Check out the repo with `git clone [email protected]:CesiumGS/cesium-native.git --recurse-submodules` so that you get the third party submodules. | ||
* Build the draco library with CMake: | ||
* `pushd extern; mkdir build; cd build; mkdir draco; cd draco` | ||
* `cmake ../../draco/ -G "Visual Studio 16 2019"` | ||
* `cmake --build . --config Release` | ||
* `popd` | ||
* Build the uriparser library with CMake: | ||
* `pushd extern; mkdir build; cd build; mkdir uriparser; cd uriparser` | ||
* `cmake ../../uriparser/ -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -D URIPARSER_BUILD_TESTS:BOOL=OFF -D URIPARSER_BUILD_DOCS:BOOL=OFF -D BUILD_SHARED_LIBS:BOOL=OFF -D URIPARSER_ENABLE_INSTALL:BOOL=OFF -D URIPARSER_BUILD_TOOLS:BOOL=OFF` | ||
* `cmake --build . --config Release` | ||
* `popd` | ||
* Open the cesium-native folder with Visual Studio Code with the `CMake Tools` extension installed. It should prompt you to generate project files from CMake. Choose `Visual Studio 2019 Release - amd64` as the kit to build. Then press Ctrl-Shift-P and execute the `CMake: Build` task or press F7. Alternatively, you can build from the command-line as follows: | ||
* `mkdir build` | ||
* `cmake -B build -S . -G "Visual Studio 16 2019"` | ||
* `cmake --build build --config Debug` |
Submodule Catch2
added at
b1b5cb
Submodule GSL
added at
0f6dbc
Submodule draco
added at
83b092
Submodule glm
added at
bf71a8
Submodule tinygltf
added at
18f0e2
Submodule uriparser
added at
25dddb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <gsl/span> | ||
#include "TileContent.h" | ||
#include "tiny_gltf.h" | ||
|
||
namespace Cesium3DTiles { | ||
|
||
class Batched3DModelContent : public TileContent { | ||
public: | ||
Batched3DModelContent(const Tile& tile, const gsl::span<const uint8_t>& data); | ||
|
||
const tinygltf::Model& gltf() const { return this->_gltf; } | ||
|
||
private: | ||
tinygltf::Model _gltf; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include <glm/vec3.hpp> | ||
#include <glm/mat3x3.hpp> | ||
#include "CullingResult.h" | ||
|
||
namespace Cesium3DTiles { | ||
|
||
class Plane; | ||
|
||
class BoundingBox { | ||
public: | ||
BoundingBox() = default; | ||
|
||
BoundingBox( | ||
const glm::dvec3& center, | ||
const glm::dmat3& halfAxes | ||
) : | ||
center(center), | ||
halfAxes(halfAxes) | ||
{} | ||
|
||
CullingResult intersectPlane(const Plane& plane) const; | ||
|
||
glm::dvec3 center; | ||
glm::dmat3 halfAxes; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "CullingResult.h" | ||
|
||
namespace Cesium3DTiles { | ||
|
||
class Plane; | ||
|
||
class BoundingRegion { | ||
public: | ||
BoundingRegion() = default; | ||
BoundingRegion( | ||
double west, | ||
double south, | ||
double east, | ||
double north, | ||
double minimumHeight, | ||
double maximumHeight | ||
) : | ||
west(west), | ||
south(south), | ||
east(east), | ||
north(north), | ||
minimumHeight(minimumHeight), | ||
maximumHeight(maximumHeight) | ||
{ | ||
} | ||
|
||
CullingResult intersectPlane(const Plane& plane) const; | ||
|
||
double west; | ||
double south; | ||
double east; | ||
double north; | ||
double minimumHeight; | ||
double maximumHeight; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <glm/vec3.hpp> | ||
#include "CullingResult.h" | ||
|
||
namespace Cesium3DTiles { | ||
|
||
class Plane; | ||
|
||
class BoundingSphere { | ||
public: | ||
BoundingSphere() = default; | ||
|
||
BoundingSphere(const glm::dvec3& center, double radius) : | ||
center(center), | ||
radius(radius) | ||
{ | ||
} | ||
|
||
CullingResult intersectPlane(const Plane& plane) const; | ||
|
||
glm::dvec3 center; | ||
double radius; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <variant> | ||
#include "BoundingBox.h" | ||
#include "BoundingRegion.h" | ||
#include "BoundingSphere.h" | ||
|
||
namespace Cesium3DTiles { | ||
typedef std::variant<BoundingBox, BoundingRegion, BoundingSphere> BoundingVolume; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <glm/vec2.hpp> | ||
#include <glm/vec3.hpp> | ||
#include <glm/mat3x3.hpp> | ||
#include "BoundingVolume.h" | ||
#include "Plane.h" | ||
|
||
namespace Cesium3DTiles { | ||
|
||
class CESIUM3DTILES_API Camera { | ||
public: | ||
// TODO: Add support for orthographic and off-center perspective frustums | ||
|
||
Camera( | ||
const glm::dvec3& position, | ||
const glm::dvec3& direction, | ||
const glm::dvec3& up, | ||
const glm::dvec2& viewportSize, | ||
double horizontalFieldOfView, | ||
double verticalFieldOfView | ||
); | ||
|
||
/// <summary> | ||
/// Gets the position of the camera in Earth-centered, Earth-fixed coordinates. | ||
/// </summary> | ||
const glm::dvec3& getPosition() const { return this->_position; } | ||
|
||
/// <summary> | ||
/// Gets the look direction of the camera in Earth-centered, Earth-fixed coordinates. | ||
/// </summary> | ||
const glm::dvec3& getDirection() const { return this->_direction; } | ||
|
||
/// <summary> | ||
/// Gets the up direction of the camera in Earth-centered, Earth-fixed coordinates. | ||
/// </summary> | ||
const glm::dvec3& getUp() const { return this->_up; } | ||
|
||
/// <summary> | ||
/// Gets the size of the viewport in pixels. | ||
/// </summary> | ||
const glm::dvec2& getViewportSize() const { return this->_viewportSize; } | ||
|
||
/// <summary> | ||
/// Gets the horizontal field-of-view angle in radians. | ||
/// </summary> | ||
double getHorizontalFieldOfView() const { return this->_horizontalFieldOfView; } | ||
|
||
/// <summary> | ||
/// Gets the vertical field-of-view angle in radians. | ||
/// </summary> | ||
double getVerticalFieldOfView() const { return this->_verticalFieldOfView; } | ||
|
||
/// <summary> | ||
/// Gets the denominator used in screen-space error (SSE) computations, | ||
/// <c>2.0 * tan(0.5 * verticalFieldOfView)</c>. | ||
/// </summary> | ||
double getScreenSpaceErrorDenominator() const { return this->_sseDenominator; } | ||
|
||
/// <summary> | ||
/// Updates the position and orientation of the camera. | ||
/// </summary> | ||
/// <param name="position">The new position.</param> | ||
/// <param name="direction">The new look direction vector.</param> | ||
/// <param name="up">The new up vector.</param> | ||
void updatePositionAndOrientation(const glm::dvec3& position, const glm::dvec3& direction, const glm::dvec3& up); | ||
|
||
/// <summary> | ||
/// Updates the camera's view parameters. | ||
/// </summary> | ||
/// <param name="viewportSize">The new size of the viewport.</param> | ||
/// <param name="horizontalFieldOfView">The horizontal field of view angle in radians.</param> | ||
/// <param name="verticalFieldOfView">The vertical field of view angle in radians.</param> | ||
void updateViewParameters(const glm::dvec2& viewportSize, double horizontalFieldOfView, double verticalFieldOfView); | ||
|
||
bool isBoundingVolumeVisible(const BoundingVolume& boundingVolume) const; | ||
|
||
double computeDistanceToBoundingVolume(const BoundingVolume& boundingVolume) const; | ||
double computeScreenSpaceError(double geometricError, double distance) const; | ||
|
||
private: | ||
void _updateCullingVolume(); | ||
|
||
glm::dvec3 _position; | ||
glm::dvec3 _direction; | ||
glm::dvec3 _up; | ||
glm::dvec2 _viewportSize; | ||
double _horizontalFieldOfView; | ||
double _verticalFieldOfView; | ||
double _sseDenominator; | ||
|
||
Plane _leftPlane; | ||
Plane _rightPlane; | ||
Plane _topPlane; | ||
Plane _bottomPlane; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Epic Games, Inc. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "Modules/ModuleManager.h" | ||
|
||
class FCesium3DTilesModule : public IModuleInterface | ||
{ | ||
public: | ||
|
||
/** IModuleInterface implementation */ | ||
virtual void StartupModule() override; | ||
virtual void ShutdownModule() override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
namespace Cesium3DTiles { | ||
|
||
enum class CullingResult { | ||
/// <summary> | ||
/// Indicates that an object lies completely outside the culling volume. | ||
/// </summary> | ||
Outside = -1, | ||
|
||
/// <summary> | ||
/// Indicates that an object intersects with the boundary of the culling volume, | ||
/// so the object is partially inside and partially outside the culling volume. | ||
/// </summary> | ||
Intersecting = 0, | ||
|
||
/// <summary> | ||
/// Indicates that an object lies completely inside the culling volume. | ||
/// </summary> | ||
Inside = 1 | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <gsl/span> | ||
#include <tiny_gltf.h> | ||
|
||
namespace Cesium3DTiles { | ||
|
||
class CESIUM3DTILES_API Gltf { | ||
public: | ||
struct LoadResult { | ||
public: | ||
std::optional<tinygltf::Model> model; | ||
std::string warnings; | ||
std::string errors; | ||
}; | ||
|
||
static LoadResult load(const gsl::span<const uint8_t>& data); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include "IAssetRequest.h" | ||
|
||
namespace Cesium3DTiles { | ||
|
||
/// <summary> | ||
/// Provides asynchronous access to 3D Tiles assets like tileset.json and tile content. | ||
/// </summary> | ||
class IAssetAccessor { | ||
public: | ||
virtual ~IAssetAccessor() = default; | ||
|
||
/// <summary> | ||
/// Starts a new request for the asset with the given URL. The request proceeds asynchronously | ||
/// without blocking the calling thread. | ||
/// </summary> | ||
/// <param name="url">The URL of the asset.</param> | ||
/// <returns>The in-progress asset request.</returns> | ||
virtual std::unique_ptr<IAssetRequest> requestAsset(const std::string& url) = 0; | ||
}; | ||
|
||
} |
Oops, something went wrong.