lots of changes
This commit is contained in:
+3
-3
@@ -1,3 +1,3 @@
|
||||
[submodule "vcpkg"]
|
||||
path = vcpkg
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
[submodule "vcpkg"]
|
||||
path = vcpkg
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
|
||||
+48
-48
@@ -1,48 +1,48 @@
|
||||
cmake_minimum_required(VERSION 3.7...3.23)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.12)
|
||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(VCPKG_INSTALL_OPTIONS "--allow-unsupported")
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
|
||||
|
||||
project(MeshShadingDemo)
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX "")
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
|
||||
find_package(Seele REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
find_package(assimp CONFIG REQUIRED)
|
||||
find_package(Stb REQUIRED)
|
||||
find_package(EnTT CONFIG REQUIRED)
|
||||
find_package(FreeType CONFIG REQUIRED)
|
||||
find_package(harfbuzz CONFIG REQUIRED)
|
||||
find_package(glfw3 CONFIG REQUIRED)
|
||||
find_package(glm CONFIG REQUIRED)
|
||||
find_package(Ktx CONFIG REQUIRED)
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
find_package(lunasvg CONFIG REQUIRED)
|
||||
find_package(metis CONFIG REQUIRED)
|
||||
find_package(meshoptimizer CONFIG REQUIRED)
|
||||
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
|
||||
|
||||
add_library(MeshShadingDemo SHARED "")
|
||||
target_link_libraries(MeshShadingDemo PUBLIC Seele::Engine)
|
||||
|
||||
target_include_directories(MeshShadingDemo PRIVATE src/)
|
||||
|
||||
target_compile_definitions(MeshShadingDemo PRIVATE BUILD_DLL)
|
||||
|
||||
add_subdirectory(src/)
|
||||
cmake_minimum_required(VERSION 3.7...3.23)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.12)
|
||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(VCPKG_INSTALL_OPTIONS "--allow-unsupported")
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
|
||||
|
||||
project(MeshShadingDemo)
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX "")
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
|
||||
find_package(Seele REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
find_package(assimp CONFIG REQUIRED)
|
||||
find_package(Stb REQUIRED)
|
||||
find_package(EnTT CONFIG REQUIRED)
|
||||
find_package(FreeType CONFIG REQUIRED)
|
||||
find_package(harfbuzz CONFIG REQUIRED)
|
||||
find_package(glfw3 CONFIG REQUIRED)
|
||||
find_package(glm CONFIG REQUIRED)
|
||||
find_package(Ktx CONFIG REQUIRED)
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
find_package(lunasvg CONFIG REQUIRED)
|
||||
find_package(metis CONFIG REQUIRED)
|
||||
find_package(meshoptimizer CONFIG REQUIRED)
|
||||
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
|
||||
|
||||
add_library(MeshShadingDemo SHARED "")
|
||||
target_link_libraries(MeshShadingDemo PUBLIC Seele::Engine)
|
||||
|
||||
target_include_directories(MeshShadingDemo PRIVATE src/)
|
||||
|
||||
target_compile_definitions(MeshShadingDemo PRIVATE BUILD_DLL)
|
||||
|
||||
add_subdirectory(src/)
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
Vec3(8.07149, 2.89742, 72.6628)
|
||||
Quat(0.0111646, -0.00056989, 0.998637, -0.0509748)
|
||||
Vec3(6.56899, 3.75079, 50.512)
|
||||
Quat(0.000180251, -9.01277e-07, 0.999987, -0.00500006)
|
||||
Vec3(5.36649, 3.97833, 33.2987)
|
||||
Quat(-0.064764, -0.0011011, 0.997756, 0.0169635)
|
||||
Vec3(9.95685, 3.66233, 1.15688)
|
||||
Quat(-0.243346, 0.000973386, 0.969931, -0.00387974)
|
||||
Vec3(19.6487, 3.52539, -13.0847)
|
||||
Quat(-0.353027, -0.00176514, 0.9356, 0.004678)
|
||||
Vec3(26.875, 3.30828, -19.2694)
|
||||
Quat(0.758938, -0.0334149, -0.649676, 0.0286042)
|
||||
Vec3(34.4412, 3.13038, -11.9002)
|
||||
Quat(0.767398, 0.0061393, -0.641121, -0.00512907)
|
||||
Vec3(41.6074, 3.17334, -7.07916)
|
||||
Quat(-0.552013, -0.00552028, 0.833776, 0.00833798)
|
||||
Vec3(52.3544, 3.22211, -6.32834)
|
||||
Quat(-0.333292, 0.00299973, 0.942781, -0.00848532)
|
||||
Vec3(59.6433, 2.86301, -16.1626)
|
||||
Quat(0.43648, -0.0200923, 0.898538, -0.0413619)
|
||||
Vec3(57.3598, 2.50521, -19.7923)
|
||||
Quat(0.814371, -0.0579177, 0.575992, -0.0409643)
|
||||
Vec3(52.312, 1.85907, -11.5477)
|
||||
Quat(0.758282, -0.0227553, 0.651236, -0.019543)
|
||||
Vec3(44.4041, 3.09733, -7.70407)
|
||||
Quat(0.58282, -0.00291417, 0.812586, -0.00406303)
|
||||
Vec3(31.0161, 3.27204, -16.1626)
|
||||
Quat(0.437852, 0.00218926, 0.899033, 0.00449516)
|
||||
Vec3(23.3012, 3.2754, -23.0331)
|
||||
Quat(0.388697, -0.000777387, 0.921364, -0.00184271)
|
||||
Vec3(11.1551, 3.20805, -35.1741)
|
||||
Quat(0.24373, -0.00170616, 0.969818, -0.00678891)
|
||||
Vec3(3.502, 2.87556, -43.9499)
|
||||
Quat(-0.213132, 0.00191825, 0.976982, -0.00879313)
|
||||
Vec3(10.4903, 3.0962, -52.2983)
|
||||
Quat(-0.272279, -0.00381216, 0.962116, 0.0134705)
|
||||
Vec3(16.7925, 2.39479, -62.9087)
|
||||
Quat(-0.287239, 0.0282399, 0.952849, -0.0936794)
|
||||
Vec3(23.1887, 1.41071, -88.6824)
|
||||
Quat(0.78488, 0.0566091, -0.615457, -0.0443896)
|
||||
Vec3(24.5556, 1.41071, -95.5271)
|
||||
Vec3(8.07149, 2.89742, 72.6628)
|
||||
Quat(0.0111646, -0.00056989, 0.998637, -0.0509748)
|
||||
Vec3(6.56899, 3.75079, 50.512)
|
||||
Quat(0.000180251, -9.01277e-07, 0.999987, -0.00500006)
|
||||
Vec3(5.36649, 3.97833, 33.2987)
|
||||
Quat(-0.064764, -0.0011011, 0.997756, 0.0169635)
|
||||
Vec3(9.95685, 3.66233, 1.15688)
|
||||
Quat(-0.243346, 0.000973386, 0.969931, -0.00387974)
|
||||
Vec3(19.6487, 3.52539, -13.0847)
|
||||
Quat(-0.353027, -0.00176514, 0.9356, 0.004678)
|
||||
Vec3(26.875, 3.30828, -19.2694)
|
||||
Quat(0.758938, -0.0334149, -0.649676, 0.0286042)
|
||||
Vec3(34.4412, 3.13038, -11.9002)
|
||||
Quat(0.767398, 0.0061393, -0.641121, -0.00512907)
|
||||
Vec3(41.6074, 3.17334, -7.07916)
|
||||
Quat(-0.552013, -0.00552028, 0.833776, 0.00833798)
|
||||
Vec3(52.3544, 3.22211, -6.32834)
|
||||
Quat(-0.333292, 0.00299973, 0.942781, -0.00848532)
|
||||
Vec3(59.6433, 2.86301, -16.1626)
|
||||
Quat(0.43648, -0.0200923, 0.898538, -0.0413619)
|
||||
Vec3(57.3598, 2.50521, -19.7923)
|
||||
Quat(0.814371, -0.0579177, 0.575992, -0.0409643)
|
||||
Vec3(52.312, 1.85907, -11.5477)
|
||||
Quat(0.758282, -0.0227553, 0.651236, -0.019543)
|
||||
Vec3(44.4041, 3.09733, -7.70407)
|
||||
Quat(0.58282, -0.00291417, 0.812586, -0.00406303)
|
||||
Vec3(31.0161, 3.27204, -16.1626)
|
||||
Quat(0.437852, 0.00218926, 0.899033, 0.00449516)
|
||||
Vec3(23.3012, 3.2754, -23.0331)
|
||||
Quat(0.388697, -0.000777387, 0.921364, -0.00184271)
|
||||
Vec3(11.1551, 3.20805, -35.1741)
|
||||
Quat(0.24373, -0.00170616, 0.969818, -0.00678891)
|
||||
Vec3(3.502, 2.87556, -43.9499)
|
||||
Quat(-0.213132, 0.00191825, 0.976982, -0.00879313)
|
||||
Vec3(10.4903, 3.0962, -52.2983)
|
||||
Quat(-0.272279, -0.00381216, 0.962116, 0.0134705)
|
||||
Vec3(16.7925, 2.39479, -62.9087)
|
||||
Quat(-0.287239, 0.0282399, 0.952849, -0.0936794)
|
||||
Vec3(23.1887, 1.41071, -88.6824)
|
||||
Quat(0.78488, 0.0566091, -0.615457, -0.0443896)
|
||||
Vec3(24.5556, 1.41071, -95.5271)
|
||||
Quat(0.764375, 0.026764, -0.643821, -0.0225429)
|
||||
+48
-48
@@ -1,49 +1,49 @@
|
||||
{
|
||||
"buildType": {
|
||||
"default": "debug",
|
||||
"description": "Configuration Type",
|
||||
"choices": {
|
||||
"debug": {
|
||||
"short": "Debug",
|
||||
"long": "Enable debugging and validation",
|
||||
"settings": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
"release": {
|
||||
"short": "Release",
|
||||
"long": "Optimize binary for speed",
|
||||
"settings": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
},
|
||||
"relwithdebinfo": {
|
||||
"short": "RelWithDebInfo",
|
||||
"long": "Release with debug symbols",
|
||||
"settings": {
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"architecture": {
|
||||
"default": "x64",
|
||||
"description": "Platform Architecture",
|
||||
"choices": {
|
||||
"x64": {
|
||||
"short": "x64",
|
||||
"long": "amd64 platform",
|
||||
"settings": {
|
||||
"CMAKE_PLATFORM": "x64"
|
||||
}
|
||||
},
|
||||
"arm64": {
|
||||
"short": "arm64",
|
||||
"long": "arm64 platform",
|
||||
"settings": {
|
||||
"CMAKE_PLATFORM": "arm64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"buildType": {
|
||||
"default": "debug",
|
||||
"description": "Configuration Type",
|
||||
"choices": {
|
||||
"debug": {
|
||||
"short": "Debug",
|
||||
"long": "Enable debugging and validation",
|
||||
"settings": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
"release": {
|
||||
"short": "Release",
|
||||
"long": "Optimize binary for speed",
|
||||
"settings": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
},
|
||||
"relwithdebinfo": {
|
||||
"short": "RelWithDebInfo",
|
||||
"long": "Release with debug symbols",
|
||||
"settings": {
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"architecture": {
|
||||
"default": "x64",
|
||||
"description": "Platform Architecture",
|
||||
"choices": {
|
||||
"x64": {
|
||||
"short": "x64",
|
||||
"long": "amd64 platform",
|
||||
"settings": {
|
||||
"CMAKE_PLATFORM": "x64"
|
||||
}
|
||||
},
|
||||
"arm64": {
|
||||
"short": "arm64",
|
||||
"long": "arm64 platform",
|
||||
"settings": {
|
||||
"CMAKE_PLATFORM": "arm64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
newmtl brick
|
||||
map_Kd brick.jpg
|
||||
newmtl brick
|
||||
map_Kd brick.jpg
|
||||
map_Ns brick_normal.jpg
|
||||
@@ -1,354 +1,354 @@
|
||||
Sponza 2022 Scene created by Frank Meinl.
|
||||
|
||||
Additional credit for reference photos
|
||||
Katica Putica
|
||||
Princino.photo
|
||||
Dubrovnik, Croatia
|
||||
www.princinophoto.com
|
||||
|
||||
|
||||
For personal use and educational use. Limited commercial use for marketing and print in educational, science papers, etc.
|
||||
Feel free to provide feedback and report any issues to [sponza _dot_ feedback AT intel _dot_ com].
|
||||
|
||||
|
||||
Please note that if these scenes are used in a publication, please include a citation using the following BibTeX template:
|
||||
|
||||
@misc{sponza22,
|
||||
Author = {Frank Meinl and Katica Putica and Cristiano Siqueira and Timothy Heath and Justin Prazen and Sebastian Herholz and Bruce Cherniak and Anton Kaplanyan},
|
||||
Year = {2022},
|
||||
Note = {https://www.intel.com/content/www/us/en/developer/topic-technology/graphics-processing-research/samples.html},
|
||||
Title = {Intel Sample Library}
|
||||
}
|
||||
|
||||
|
||||
Thanks to the Sponza and Addon Package Crew:
|
||||
Frank Meinl
|
||||
Katica Putica
|
||||
Cristiano Siqueira
|
||||
Timothy Heath
|
||||
Justin Prazen
|
||||
Sebastian Herholz
|
||||
Bruce Cherniak
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
Sponza 2022 Scene created by Frank Meinl.
|
||||
|
||||
Additional credit for reference photos
|
||||
Katica Putica
|
||||
Princino.photo
|
||||
Dubrovnik, Croatia
|
||||
www.princinophoto.com
|
||||
|
||||
|
||||
For personal use and educational use. Limited commercial use for marketing and print in educational, science papers, etc.
|
||||
Feel free to provide feedback and report any issues to [sponza _dot_ feedback AT intel _dot_ com].
|
||||
|
||||
|
||||
Please note that if these scenes are used in a publication, please include a citation using the following BibTeX template:
|
||||
|
||||
@misc{sponza22,
|
||||
Author = {Frank Meinl and Katica Putica and Cristiano Siqueira and Timothy Heath and Justin Prazen and Sebastian Herholz and Bruce Cherniak and Anton Kaplanyan},
|
||||
Year = {2022},
|
||||
Note = {https://www.intel.com/content/www/us/en/developer/topic-technology/graphics-processing-research/samples.html},
|
||||
Title = {Intel Sample Library}
|
||||
}
|
||||
|
||||
|
||||
Thanks to the Sponza and Addon Package Crew:
|
||||
Frank Meinl
|
||||
Katica Putica
|
||||
Cristiano Siqueira
|
||||
Timothy Heath
|
||||
Justin Prazen
|
||||
Sebastian Herholz
|
||||
Bruce Cherniak
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
+32190
-32190
File diff suppressed because it is too large
Load Diff
+19
-19
@@ -1,20 +1,20 @@
|
||||
mtllib brick
|
||||
usemtl brick
|
||||
|
||||
v -1 -1 0
|
||||
v 1 -1 0
|
||||
v -1 1 0
|
||||
v 1 1 0
|
||||
|
||||
vt 0 1
|
||||
vt 1 1
|
||||
vt 1 0
|
||||
vt 0 0
|
||||
|
||||
vn 0 0 1
|
||||
vn 0 0 1
|
||||
vn 0 0 1
|
||||
vn 0 0 1
|
||||
|
||||
f 1/1/1 2/2/2 3/3/3
|
||||
mtllib brick
|
||||
usemtl brick
|
||||
|
||||
v -1 -1 0
|
||||
v 1 -1 0
|
||||
v -1 1 0
|
||||
v 1 1 0
|
||||
|
||||
vt 0 1
|
||||
vt 1 1
|
||||
vt 1 0
|
||||
vt 0 0
|
||||
|
||||
vn 0 0 1
|
||||
vn 0 0 1
|
||||
vn 0 0 1
|
||||
vn 0 0 1
|
||||
|
||||
f 1/1/1 2/2/2 3/3/3
|
||||
f 3/3/3 2/2/2 1/1/1
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
+124
-124
@@ -1,125 +1,125 @@
|
||||
#crappy sky/atmosphere/etc format 1.0
|
||||
#
|
||||
#number of entries
|
||||
5
|
||||
#
|
||||
# *** normal unfancy mode ***
|
||||
#
|
||||
#name
|
||||
normal
|
||||
#light:ambient
|
||||
0.2 0.2 0.2
|
||||
#light:diffuse
|
||||
0.8 0.8 0.8
|
||||
#light:specular
|
||||
0.5 0.5 0.5
|
||||
#light:position
|
||||
0 0 1
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
0
|
||||
#fog:color
|
||||
0 0 0
|
||||
#fog:density
|
||||
0
|
||||
#fog:start
|
||||
0
|
||||
#fog:end
|
||||
0
|
||||
#skyboxname
|
||||
$DISABLED$
|
||||
#
|
||||
# *** sunset 1 ***
|
||||
#
|
||||
sunset1
|
||||
#light:ambient
|
||||
0.1064453125 0.1123046875 0.1337890625
|
||||
#light:diffuse
|
||||
0.9921 0.9058 0.5450
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 0.6186
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.427 0.423 0.478
|
||||
#fog:density
|
||||
0.65
|
||||
#fog:start
|
||||
1
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
skyboxsun5deg\skyrender
|
||||
#
|
||||
# *** sunset 2 ***
|
||||
#
|
||||
sunset2
|
||||
#light:ambient
|
||||
0.271484375 0.337890625 0.390625
|
||||
#light:diffuse
|
||||
1 1 0.654901
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 0.6186
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.368 0.368 0.431
|
||||
#fog:density
|
||||
0.65
|
||||
#fog:start
|
||||
1
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
skyboxsun5deg2\skyrender
|
||||
#
|
||||
# *** sun normal test ***
|
||||
#
|
||||
sunnormal
|
||||
#light:ambient
|
||||
0.2109375 0.236328125 0.29296875
|
||||
#light:diffuse
|
||||
1 0.98823 0.9058
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 2.66
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.8431 0.79607 0.69019
|
||||
#fog:density
|
||||
0.65
|
||||
#fog:start
|
||||
1
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
skyboxsun25degtest\skyrender
|
||||
#
|
||||
# *** rainy day test ***
|
||||
#
|
||||
rainyday
|
||||
#light:ambient
|
||||
0.25 0.25 0.25
|
||||
#light:diffuse
|
||||
0.9882 0.9764705 0.8980
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 5
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.56862 0.54901 0.50588
|
||||
#fog:density
|
||||
2.95
|
||||
#fog:start
|
||||
.5
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
#crappy sky/atmosphere/etc format 1.0
|
||||
#
|
||||
#number of entries
|
||||
5
|
||||
#
|
||||
# *** normal unfancy mode ***
|
||||
#
|
||||
#name
|
||||
normal
|
||||
#light:ambient
|
||||
0.2 0.2 0.2
|
||||
#light:diffuse
|
||||
0.8 0.8 0.8
|
||||
#light:specular
|
||||
0.5 0.5 0.5
|
||||
#light:position
|
||||
0 0 1
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
0
|
||||
#fog:color
|
||||
0 0 0
|
||||
#fog:density
|
||||
0
|
||||
#fog:start
|
||||
0
|
||||
#fog:end
|
||||
0
|
||||
#skyboxname
|
||||
$DISABLED$
|
||||
#
|
||||
# *** sunset 1 ***
|
||||
#
|
||||
sunset1
|
||||
#light:ambient
|
||||
0.1064453125 0.1123046875 0.1337890625
|
||||
#light:diffuse
|
||||
0.9921 0.9058 0.5450
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 0.6186
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.427 0.423 0.478
|
||||
#fog:density
|
||||
0.65
|
||||
#fog:start
|
||||
1
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
skyboxsun5deg\skyrender
|
||||
#
|
||||
# *** sunset 2 ***
|
||||
#
|
||||
sunset2
|
||||
#light:ambient
|
||||
0.271484375 0.337890625 0.390625
|
||||
#light:diffuse
|
||||
1 1 0.654901
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 0.6186
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.368 0.368 0.431
|
||||
#fog:density
|
||||
0.65
|
||||
#fog:start
|
||||
1
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
skyboxsun5deg2\skyrender
|
||||
#
|
||||
# *** sun normal test ***
|
||||
#
|
||||
sunnormal
|
||||
#light:ambient
|
||||
0.2109375 0.236328125 0.29296875
|
||||
#light:diffuse
|
||||
1 0.98823 0.9058
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 2.66
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.8431 0.79607 0.69019
|
||||
#fog:density
|
||||
0.65
|
||||
#fog:start
|
||||
1
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
skyboxsun25degtest\skyrender
|
||||
#
|
||||
# *** rainy day test ***
|
||||
#
|
||||
rainyday
|
||||
#light:ambient
|
||||
0.25 0.25 0.25
|
||||
#light:diffuse
|
||||
0.9882 0.9764705 0.8980
|
||||
#light:specular
|
||||
0 0 0
|
||||
#light:position
|
||||
5 -5 5
|
||||
#fog:enabled (0 or 1 or -1 or whatever)
|
||||
1
|
||||
#fog:color
|
||||
0.56862 0.54901 0.50588
|
||||
#fog:density
|
||||
2.95
|
||||
#fog:start
|
||||
.5
|
||||
#fog:end
|
||||
2.5
|
||||
#skyboxname
|
||||
skyboxsun45deg\skyrender
|
||||
@@ -1,7 +1,7 @@
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
FlyCam.h
|
||||
FlyCam.cpp
|
||||
PathFollowCam.h
|
||||
PathFollowCam.cpp
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
FlyCam.h
|
||||
FlyCam.cpp
|
||||
PathFollowCam.h
|
||||
PathFollowCam.cpp
|
||||
)
|
||||
+20
-20
@@ -1,21 +1,21 @@
|
||||
#include "FlyCam.h"
|
||||
|
||||
FlyCam::FlyCam(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::Camera>();
|
||||
attachComponent<Component::KeyboardInput>();
|
||||
}
|
||||
|
||||
FlyCam::~FlyCam()
|
||||
{}
|
||||
|
||||
Component::Camera& FlyCam::getCamera()
|
||||
{
|
||||
return accessComponent<Component::Camera>();
|
||||
}
|
||||
|
||||
Component::KeyboardInput& FlyCam::getKeyboardInput()
|
||||
{
|
||||
return accessComponent<Component::KeyboardInput>();
|
||||
#include "FlyCam.h"
|
||||
|
||||
FlyCam::FlyCam(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::Camera>();
|
||||
attachComponent<Component::KeyboardInput>();
|
||||
}
|
||||
|
||||
FlyCam::~FlyCam()
|
||||
{}
|
||||
|
||||
Component::Camera& FlyCam::getCamera()
|
||||
{
|
||||
return accessComponent<Component::Camera>();
|
||||
}
|
||||
|
||||
Component::KeyboardInput& FlyCam::getKeyboardInput()
|
||||
{
|
||||
return accessComponent<Component::KeyboardInput>();
|
||||
}
|
||||
+16
-16
@@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Actor/Actor.h>
|
||||
#include <Component/KeyboardInput.h>
|
||||
#include <Component/Camera.h>
|
||||
|
||||
class FlyCam : public Actor
|
||||
{
|
||||
public:
|
||||
FlyCam(PScene scene);
|
||||
virtual ~FlyCam();
|
||||
Component::KeyboardInput& getKeyboardInput();
|
||||
Component::Camera& getCamera();
|
||||
private:
|
||||
};
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Actor/Actor.h>
|
||||
#include <Component/KeyboardInput.h>
|
||||
#include <Component/Camera.h>
|
||||
|
||||
class FlyCam : public Actor
|
||||
{
|
||||
public:
|
||||
FlyCam(PScene scene);
|
||||
virtual ~FlyCam();
|
||||
Component::KeyboardInput& getKeyboardInput();
|
||||
Component::Camera& getCamera();
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(FlyCam)
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
#include "PathFollowCam.h"
|
||||
|
||||
PathFollowCam::PathFollowCam(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::Camera>();
|
||||
attachComponent<PathFollow>();
|
||||
}
|
||||
|
||||
PathFollowCam::~PathFollowCam()
|
||||
{}
|
||||
|
||||
PathFollow& PathFollowCam::getPathFollow()
|
||||
{
|
||||
return accessComponent<PathFollow>();
|
||||
}
|
||||
|
||||
Component::Camera& PathFollowCam::getCamera()
|
||||
{
|
||||
return accessComponent<Component::Camera>();
|
||||
}
|
||||
|
||||
#include "PathFollowCam.h"
|
||||
|
||||
PathFollowCam::PathFollowCam(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::Camera>();
|
||||
attachComponent<PathFollow>();
|
||||
}
|
||||
|
||||
PathFollowCam::~PathFollowCam()
|
||||
{}
|
||||
|
||||
PathFollow& PathFollowCam::getPathFollow()
|
||||
{
|
||||
return accessComponent<PathFollow>();
|
||||
}
|
||||
|
||||
Component::Camera& PathFollowCam::getCamera()
|
||||
{
|
||||
return accessComponent<Component::Camera>();
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Actor/Actor.h>
|
||||
#include <Component/PathFollow.h>
|
||||
#include <Component/Camera.h>
|
||||
|
||||
class PathFollowCam : public Actor
|
||||
{
|
||||
public:
|
||||
PathFollowCam(PScene scene);
|
||||
virtual ~PathFollowCam();
|
||||
PathFollow& getPathFollow();
|
||||
Component::Camera& getCamera();
|
||||
private:
|
||||
};
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Actor/Actor.h>
|
||||
#include <Component/PathFollow.h>
|
||||
#include <Component/Camera.h>
|
||||
|
||||
class PathFollowCam : public Actor
|
||||
{
|
||||
public:
|
||||
PathFollowCam(PScene scene);
|
||||
virtual ~PathFollowCam();
|
||||
PathFollow& getPathFollow();
|
||||
Component::Camera& getCamera();
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(PathFollowCam)
|
||||
+9
-9
@@ -1,9 +1,9 @@
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
Define.h
|
||||
MeshShadingDemoGame.h
|
||||
MeshShadingDemoGame.cpp)
|
||||
|
||||
add_subdirectory(Actor/)
|
||||
add_subdirectory(Component/)
|
||||
add_subdirectory(System/)
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
Define.h
|
||||
MeshShadingDemoGame.h
|
||||
MeshShadingDemoGame.cpp)
|
||||
|
||||
add_subdirectory(Actor/)
|
||||
add_subdirectory(Component/)
|
||||
add_subdirectory(System/)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(MeshShadingDemo
|
||||
PRIVATE
|
||||
Path.h
|
||||
target_sources(MeshShadingDemo
|
||||
PRIVATE
|
||||
Path.h
|
||||
PathFollow.h)
|
||||
+187
-187
@@ -1,188 +1,188 @@
|
||||
#pragma once
|
||||
#include <Define.h>
|
||||
#include <MinimalEngine.h>
|
||||
#include <Containers/Array.h>
|
||||
#include <Math/Vector.h>
|
||||
#include <Graphics/DebugVertex.h>
|
||||
|
||||
struct Path
|
||||
{
|
||||
static constexpr float ARC_LENGTH_TABLE_DISTANCE = 0.05f;
|
||||
static constexpr float LAST_POS_EPSILON = 0.015f;
|
||||
|
||||
Path(Array<Vector> points)
|
||||
: points(std::move(points))
|
||||
{
|
||||
createDebugVertices();
|
||||
updateArcLengthTable();
|
||||
}
|
||||
// How sharply the curve bends at the interpolated points, between 0 and 1.
|
||||
float tension = 0.5f;
|
||||
// The points of the Catmull-Rom curve
|
||||
Array<Vector> points = Array<Vector>();
|
||||
// Offset How many points should be skipped when checking arc length table to find distance (optimization)
|
||||
int pointOffset = 0;
|
||||
// Whether to start from the first point once the last point has been reached.
|
||||
bool looping = false;
|
||||
// Arc Length table, stores for each arc (between two consecutive points)
|
||||
// a list of chord length distances. The chord length entries are stored with a distance
|
||||
// of ARC_LENGTH_TABLE_DISTANCE and contain the arc length approximated by cummulative chord lengths.
|
||||
// E.g. if ARC_LENGTH_TABLE_DISTANCE = 0.2f, then the first entry in the first vector is
|
||||
// the chord length (=direct distance) between t=0 and t=0.2,
|
||||
// the second one the distance between t=0 and t=0.4, and so on
|
||||
Array<Array<float>> arcLengthTable = Array<Array<float>>();
|
||||
|
||||
bool showSplineCurve = false;
|
||||
bool showControlPoints = false;
|
||||
bool showArcLengthTableSamplePoints = false;
|
||||
|
||||
int debugSplineCurveVerticesCount = 0;
|
||||
int debugArcLengthTableSampleVerticesCount = 0;
|
||||
|
||||
private:
|
||||
Array<DebugVertex> verticesSplineCurve;
|
||||
Array<DebugVertex> verticesArcLengthTableSample;
|
||||
|
||||
public:
|
||||
// Needs to be called the first time.
|
||||
// Creates vertices used for rendering the debug lines and control points
|
||||
void createDebugVertices()
|
||||
{
|
||||
updateDebugControlPoints();
|
||||
updateDebugSplineCurveVertices(Array<Vector>());
|
||||
updateDebugArcLengthTableSample(Array<Vector>());
|
||||
}
|
||||
|
||||
void updateDebugControlPoints()
|
||||
{
|
||||
Array<DebugVertex> verticesControlPoints = Array<DebugVertex>();
|
||||
for (uint32_t i = 0; i < points.size(); i++)
|
||||
{
|
||||
DebugVertex v = DebugVertex{
|
||||
.position = points[i],
|
||||
.color = Vector(1, 0, 0),
|
||||
};
|
||||
verticesControlPoints.add(v);
|
||||
}
|
||||
}
|
||||
|
||||
void updateDebugSplineCurveVertices(const Array<Vector>& newSplineCurvePoints)
|
||||
{
|
||||
for (uint32_t i = 1; i < newSplineCurvePoints.size(); i++) // First one can be skipped, as it's always the last one from previous call
|
||||
{
|
||||
DebugVertex v = DebugVertex{
|
||||
.position = newSplineCurvePoints[i],
|
||||
.color = Vector(0, 0, 1),
|
||||
};
|
||||
verticesSplineCurve.add(v);
|
||||
}
|
||||
debugSplineCurveVerticesCount = verticesSplineCurve.size();
|
||||
}
|
||||
|
||||
void updateDebugArcLengthTableSample(const Array<Vector>& newArcLengthTablePositions)
|
||||
{
|
||||
for (uint32_t i = 1; i < newArcLengthTablePositions.size(); i++) // First one can be skipped, as it's always the last one from previous call
|
||||
{
|
||||
DebugVertex v = DebugVertex{
|
||||
.position = newArcLengthTablePositions[i],
|
||||
.color = Vector(0, 1, 0),
|
||||
};
|
||||
verticesArcLengthTableSample.add(v);
|
||||
}
|
||||
debugArcLengthTableSampleVerticesCount = verticesArcLengthTableSample.size();
|
||||
}
|
||||
void updateArcLengthTable()
|
||||
{
|
||||
assert(points.size() > 3);
|
||||
Array<Vector> debugPoints = Array<Vector>(); //only used for debug visualization
|
||||
|
||||
// don't recalculate existing entries
|
||||
int startIndex = arcLengthTable.size();
|
||||
float previousDistance = 0.0f;
|
||||
if (arcLengthTable.size() > 0)
|
||||
{
|
||||
Array<float> pChoordLength = arcLengthTable[arcLengthTable.size() - 1];
|
||||
previousDistance = pChoordLength[pChoordLength.size() - 1];
|
||||
}
|
||||
int stepsPerP = 1.0f / Path::ARC_LENGTH_TABLE_DISTANCE;
|
||||
|
||||
// If path is looping, we need to check all points
|
||||
int p0IndexBorder = looping ? points.size() : points.size() - 3;
|
||||
// First distance is p1 to p2 (since p0 is skipped), but we check loop by p0
|
||||
for (int p0Index = startIndex; p0Index < p0IndexBorder; p0Index++)
|
||||
{
|
||||
Array<float> choordLengths = Array<float>();
|
||||
|
||||
Vector pA = catmullrom(0,
|
||||
points[(p0Index) % points.size()],
|
||||
points[(p0Index + 1) % points.size()],
|
||||
points[(p0Index + 2) % points.size()],
|
||||
points[(p0Index + 3) % points.size()],
|
||||
tension);
|
||||
debugPoints.add(pA);
|
||||
// First distance is always same as last distance from previous step/point
|
||||
choordLengths.add(previousDistance);
|
||||
|
||||
for (int step = 1; step < (stepsPerP + 1); step++)
|
||||
{
|
||||
Vector pB = catmullrom(step * Path::ARC_LENGTH_TABLE_DISTANCE,
|
||||
points[(p0Index) % points.size()],
|
||||
points[(p0Index + 1) % points.size()],
|
||||
points[(p0Index + 2) % points.size()],
|
||||
points[(p0Index + 3) % points.size()],
|
||||
tension);
|
||||
debugPoints.add(pB);
|
||||
previousDistance += glm::distance(pA, pB);
|
||||
choordLengths.add(previousDistance);
|
||||
|
||||
pA = pB;
|
||||
}
|
||||
|
||||
Array<float>& arr = arcLengthTable.add();
|
||||
arr = std::move(choordLengths);
|
||||
}
|
||||
|
||||
updateDebugArcLengthTableSample(debugPoints);
|
||||
updateDebugSplineCurveVertices(debugPoints);
|
||||
}
|
||||
|
||||
void appendPoints(const Array<Vector>& toBeAppendedPoints, Vector pointPositionOffset)
|
||||
{
|
||||
size_t originalSize = points.size();
|
||||
points.resize(originalSize + toBeAppendedPoints.size());
|
||||
for (size_t i = 0; i < toBeAppendedPoints.size(); i++)
|
||||
{
|
||||
points[originalSize + i] = toBeAppendedPoints[i] + pointPositionOffset;
|
||||
}
|
||||
updateDebugControlPoints();
|
||||
}
|
||||
float getPathLength() const
|
||||
{
|
||||
if (arcLengthTable.size() == 0 || arcLengthTable.back().size() == 0)
|
||||
return 0.f;
|
||||
return arcLengthTable.back().back();
|
||||
}
|
||||
|
||||
// Returns float P(t) between p1 and p2
|
||||
static float catmullrom(float t, float p0, float p1, float p2, float p3, float tension)
|
||||
{
|
||||
// TODO: The tension variable doesn't fully influence this function.
|
||||
// If it's something else than 0.5, This would need to be rewritten, as the matrix would be a bit different then
|
||||
return tension * (
|
||||
(2 * p1) +
|
||||
(-p0 + p2) * t +
|
||||
(2 * p0 - 5 * p1 + 4 * p2 - p3) * t * t +
|
||||
(-p0 + 3 * p1 - 3 * p2 + p3) * t * t * t
|
||||
);
|
||||
}
|
||||
|
||||
// Returns point P(t) between p1 and p2
|
||||
static Vector catmullrom(float t, Vector p0, Vector p1, Vector p2, Vector p3, float tension)
|
||||
{
|
||||
return Vector(
|
||||
catmullrom(t, p0.x, p1.x, p2.x, p3.x, tension),
|
||||
catmullrom(t, p0.y, p1.y, p2.y, p3.y, tension),
|
||||
catmullrom(t, p0.z, p1.z, p2.z, p3.z, tension)
|
||||
);
|
||||
}
|
||||
#pragma once
|
||||
#include <Define.h>
|
||||
#include <MinimalEngine.h>
|
||||
#include <Containers/Array.h>
|
||||
#include <Math/Vector.h>
|
||||
#include <Graphics/DebugVertex.h>
|
||||
|
||||
struct Path
|
||||
{
|
||||
static constexpr float ARC_LENGTH_TABLE_DISTANCE = 0.05f;
|
||||
static constexpr float LAST_POS_EPSILON = 0.015f;
|
||||
|
||||
Path(Array<Vector> points)
|
||||
: points(std::move(points))
|
||||
{
|
||||
createDebugVertices();
|
||||
updateArcLengthTable();
|
||||
}
|
||||
// How sharply the curve bends at the interpolated points, between 0 and 1.
|
||||
float tension = 0.5f;
|
||||
// The points of the Catmull-Rom curve
|
||||
Array<Vector> points = Array<Vector>();
|
||||
// Offset How many points should be skipped when checking arc length table to find distance (optimization)
|
||||
int pointOffset = 0;
|
||||
// Whether to start from the first point once the last point has been reached.
|
||||
bool looping = false;
|
||||
// Arc Length table, stores for each arc (between two consecutive points)
|
||||
// a list of chord length distances. The chord length entries are stored with a distance
|
||||
// of ARC_LENGTH_TABLE_DISTANCE and contain the arc length approximated by cummulative chord lengths.
|
||||
// E.g. if ARC_LENGTH_TABLE_DISTANCE = 0.2f, then the first entry in the first vector is
|
||||
// the chord length (=direct distance) between t=0 and t=0.2,
|
||||
// the second one the distance between t=0 and t=0.4, and so on
|
||||
Array<Array<float>> arcLengthTable = Array<Array<float>>();
|
||||
|
||||
bool showSplineCurve = false;
|
||||
bool showControlPoints = false;
|
||||
bool showArcLengthTableSamplePoints = false;
|
||||
|
||||
int debugSplineCurveVerticesCount = 0;
|
||||
int debugArcLengthTableSampleVerticesCount = 0;
|
||||
|
||||
private:
|
||||
Array<DebugVertex> verticesSplineCurve;
|
||||
Array<DebugVertex> verticesArcLengthTableSample;
|
||||
|
||||
public:
|
||||
// Needs to be called the first time.
|
||||
// Creates vertices used for rendering the debug lines and control points
|
||||
void createDebugVertices()
|
||||
{
|
||||
updateDebugControlPoints();
|
||||
updateDebugSplineCurveVertices(Array<Vector>());
|
||||
updateDebugArcLengthTableSample(Array<Vector>());
|
||||
}
|
||||
|
||||
void updateDebugControlPoints()
|
||||
{
|
||||
Array<DebugVertex> verticesControlPoints = Array<DebugVertex>();
|
||||
for (uint32_t i = 0; i < points.size(); i++)
|
||||
{
|
||||
DebugVertex v = DebugVertex{
|
||||
.position = points[i],
|
||||
.color = Vector(1, 0, 0),
|
||||
};
|
||||
verticesControlPoints.add(v);
|
||||
}
|
||||
}
|
||||
|
||||
void updateDebugSplineCurveVertices(const Array<Vector>& newSplineCurvePoints)
|
||||
{
|
||||
for (uint32_t i = 1; i < newSplineCurvePoints.size(); i++) // First one can be skipped, as it's always the last one from previous call
|
||||
{
|
||||
DebugVertex v = DebugVertex{
|
||||
.position = newSplineCurvePoints[i],
|
||||
.color = Vector(0, 0, 1),
|
||||
};
|
||||
verticesSplineCurve.add(v);
|
||||
}
|
||||
debugSplineCurveVerticesCount = verticesSplineCurve.size();
|
||||
}
|
||||
|
||||
void updateDebugArcLengthTableSample(const Array<Vector>& newArcLengthTablePositions)
|
||||
{
|
||||
for (uint32_t i = 1; i < newArcLengthTablePositions.size(); i++) // First one can be skipped, as it's always the last one from previous call
|
||||
{
|
||||
DebugVertex v = DebugVertex{
|
||||
.position = newArcLengthTablePositions[i],
|
||||
.color = Vector(0, 1, 0),
|
||||
};
|
||||
verticesArcLengthTableSample.add(v);
|
||||
}
|
||||
debugArcLengthTableSampleVerticesCount = verticesArcLengthTableSample.size();
|
||||
}
|
||||
void updateArcLengthTable()
|
||||
{
|
||||
assert(points.size() > 3);
|
||||
Array<Vector> debugPoints = Array<Vector>(); //only used for debug visualization
|
||||
|
||||
// don't recalculate existing entries
|
||||
int startIndex = arcLengthTable.size();
|
||||
float previousDistance = 0.0f;
|
||||
if (arcLengthTable.size() > 0)
|
||||
{
|
||||
Array<float> pChoordLength = arcLengthTable[arcLengthTable.size() - 1];
|
||||
previousDistance = pChoordLength[pChoordLength.size() - 1];
|
||||
}
|
||||
int stepsPerP = 1.0f / Path::ARC_LENGTH_TABLE_DISTANCE;
|
||||
|
||||
// If path is looping, we need to check all points
|
||||
int p0IndexBorder = looping ? points.size() : points.size() - 3;
|
||||
// First distance is p1 to p2 (since p0 is skipped), but we check loop by p0
|
||||
for (int p0Index = startIndex; p0Index < p0IndexBorder; p0Index++)
|
||||
{
|
||||
Array<float> choordLengths = Array<float>();
|
||||
|
||||
Vector pA = catmullrom(0,
|
||||
points[(p0Index) % points.size()],
|
||||
points[(p0Index + 1) % points.size()],
|
||||
points[(p0Index + 2) % points.size()],
|
||||
points[(p0Index + 3) % points.size()],
|
||||
tension);
|
||||
debugPoints.add(pA);
|
||||
// First distance is always same as last distance from previous step/point
|
||||
choordLengths.add(previousDistance);
|
||||
|
||||
for (int step = 1; step < (stepsPerP + 1); step++)
|
||||
{
|
||||
Vector pB = catmullrom(step * Path::ARC_LENGTH_TABLE_DISTANCE,
|
||||
points[(p0Index) % points.size()],
|
||||
points[(p0Index + 1) % points.size()],
|
||||
points[(p0Index + 2) % points.size()],
|
||||
points[(p0Index + 3) % points.size()],
|
||||
tension);
|
||||
debugPoints.add(pB);
|
||||
previousDistance += glm::distance(pA, pB);
|
||||
choordLengths.add(previousDistance);
|
||||
|
||||
pA = pB;
|
||||
}
|
||||
|
||||
Array<float>& arr = arcLengthTable.add();
|
||||
arr = std::move(choordLengths);
|
||||
}
|
||||
|
||||
updateDebugArcLengthTableSample(debugPoints);
|
||||
updateDebugSplineCurveVertices(debugPoints);
|
||||
}
|
||||
|
||||
void appendPoints(const Array<Vector>& toBeAppendedPoints, Vector pointPositionOffset)
|
||||
{
|
||||
size_t originalSize = points.size();
|
||||
points.resize(originalSize + toBeAppendedPoints.size());
|
||||
for (size_t i = 0; i < toBeAppendedPoints.size(); i++)
|
||||
{
|
||||
points[originalSize + i] = toBeAppendedPoints[i] + pointPositionOffset;
|
||||
}
|
||||
updateDebugControlPoints();
|
||||
}
|
||||
float getPathLength() const
|
||||
{
|
||||
if (arcLengthTable.size() == 0 || arcLengthTable.back().size() == 0)
|
||||
return 0.f;
|
||||
return arcLengthTable.back().back();
|
||||
}
|
||||
|
||||
// Returns float P(t) between p1 and p2
|
||||
static float catmullrom(float t, float p0, float p1, float p2, float p3, float tension)
|
||||
{
|
||||
// TODO: The tension variable doesn't fully influence this function.
|
||||
// If it's something else than 0.5, This would need to be rewritten, as the matrix would be a bit different then
|
||||
return tension * (
|
||||
(2 * p1) +
|
||||
(-p0 + p2) * t +
|
||||
(2 * p0 - 5 * p1 + 4 * p2 - p3) * t * t +
|
||||
(-p0 + 3 * p1 - 3 * p2 + p3) * t * t * t
|
||||
);
|
||||
}
|
||||
|
||||
// Returns point P(t) between p1 and p2
|
||||
static Vector catmullrom(float t, Vector p0, Vector p1, Vector p2, Vector p3, float tension)
|
||||
{
|
||||
return Vector(
|
||||
catmullrom(t, p0.x, p1.x, p2.x, p3.x, tension),
|
||||
catmullrom(t, p0.y, p1.y, p2.y, p3.y, tension),
|
||||
catmullrom(t, p0.z, p1.z, p2.z, p3.z, tension)
|
||||
);
|
||||
}
|
||||
};
|
||||
+26
-26
@@ -1,27 +1,27 @@
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <Math/Vector.h>
|
||||
#include <Actor/Actor.h>
|
||||
|
||||
struct PathFollow
|
||||
{
|
||||
enum class SpeedControl {
|
||||
Linear,
|
||||
EaseInEaseOut
|
||||
};
|
||||
|
||||
PEntity path;
|
||||
|
||||
// How many seconds since start of path, used to calculate new position in path
|
||||
float time = 0.0f;
|
||||
// How much distance per passed second will be traversed along the path
|
||||
float traversalSpeed = 1.0f;
|
||||
// The desired speed control function (choose Linear to simply use the traversal speed)
|
||||
SpeedControl speedControl = SpeedControl::Linear;
|
||||
// Distance travelled through the path
|
||||
float distance = 0.0f;
|
||||
// The entity's Transform will always get this offset applied
|
||||
Vector pathOffset = Seele::Vector(0);
|
||||
|
||||
Vector lastPos = Vector(0);
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <Math/Vector.h>
|
||||
#include <Actor/Actor.h>
|
||||
|
||||
struct PathFollow
|
||||
{
|
||||
enum class SpeedControl {
|
||||
Linear,
|
||||
EaseInEaseOut
|
||||
};
|
||||
|
||||
PEntity path;
|
||||
|
||||
// How many seconds since start of path, used to calculate new position in path
|
||||
float time = 0.0f;
|
||||
// How much distance per passed second will be traversed along the path
|
||||
float traversalSpeed = 1.0f;
|
||||
// The desired speed control function (choose Linear to simply use the traversal speed)
|
||||
SpeedControl speedControl = SpeedControl::Linear;
|
||||
// Distance travelled through the path
|
||||
float distance = 0.0f;
|
||||
// The entity's Transform will always get this offset applied
|
||||
Vector pathOffset = Seele::Vector(0);
|
||||
|
||||
Vector lastPos = Vector(0);
|
||||
};
|
||||
+13
-13
@@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
#include <MinimalEngine.h>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef BUILD_DLL
|
||||
#define MESHSHADINGDEMO_API __declspec(dllexport)
|
||||
#else
|
||||
#define MESHSHADINGDEMO_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define MESHSHADINGDEMO_API
|
||||
#pragma once
|
||||
#include <MinimalEngine.h>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef BUILD_DLL
|
||||
#define MESHSHADINGDEMO_API __declspec(dllexport)
|
||||
#else
|
||||
#define MESHSHADINGDEMO_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define MESHSHADINGDEMO_API
|
||||
#endif
|
||||
+217
-217
@@ -1,218 +1,218 @@
|
||||
#include "MeshShadingDemoGame.h"
|
||||
#include "Actor/FlyCam.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Component/TerrainTile.h"
|
||||
#include "System/FlyCamSystem.h"
|
||||
#include "Component/Path.h"
|
||||
#include "Component/WaterTile.h"
|
||||
#include "System/SplineCamSystem.h"
|
||||
#include "Graphics/StaticMeshVertexData.h"
|
||||
|
||||
MeshShadingDemoGame::MeshShadingDemoGame()
|
||||
{
|
||||
}
|
||||
|
||||
MeshShadingDemoGame::~MeshShadingDemoGame()
|
||||
{
|
||||
}
|
||||
|
||||
void MeshShadingDemoGame::setupScene(PScene scene, PSystemGraph graph)
|
||||
{
|
||||
flyCam = new FlyCam(scene);
|
||||
flyCam->attachComponent<Component::PointLight>(Vector(1, 1, 1), 1.0f, 2.0f);
|
||||
flyCam->getCamera().mainCamera = true;
|
||||
|
||||
followCam = new PathFollowCam(scene);
|
||||
//followCam->getCamera().mainCamera = true;
|
||||
|
||||
/* {
|
||||
Array<Vector> lightPoints = {
|
||||
Vector(13.542, 3.12369, -12.3293),
|
||||
Vector(20.6668, 3.04548, -20.9486),
|
||||
Vector(11.5522, 3.09676, -45.9563),
|
||||
Vector(10.392, 3.0536, -63.238),
|
||||
Vector(14.8289, 3.01454, -72.0112),
|
||||
Vector(16.9386, 3.06158, -80.7447),
|
||||
Vector(17.6772, 3.05903, -89.3406),
|
||||
Vector(17.4801, 3.03598, -97.9897),
|
||||
Vector(17.1882, 3.04928, -106.596),
|
||||
Vector(16.8547, 3.05735, -116.065),
|
||||
Vector(16.6074, 3.05262, -123.884),
|
||||
Vector(16.331, 3.03858, -132.499),
|
||||
Vector(16.0015, 3.07391, -141.126),
|
||||
Vector(26.1148, 3.05149, -141.591),
|
||||
Vector(26.4517, 3.06293, -132.945),
|
||||
Vector(26.7491, 3.06205, -124.321),
|
||||
Vector(27.0371, 3.11222, -115.731),
|
||||
Vector(28.7401, 3.063, -98.5291),
|
||||
Vector(29.0123, 3.09289, -89.8635),
|
||||
Vector(28.5112, 3.07688, -81.2221),
|
||||
Vector(26.8285, 3.12346, -72.5381),
|
||||
Vector(23.7577, 3.07845, -63.8065),
|
||||
Vector(18.4836, 3.07243, -54.9846),
|
||||
Vector(11.5667, 3.0757, -46.1511),
|
||||
Vector(44.4868, 3.169, -11.858),
|
||||
Vector(50.5335, 3.15588, -21.1511),
|
||||
Vector(54.2709, 3.18958, -30.2516),
|
||||
Vector(55.6934, 3.22225, -39.0652),
|
||||
Vector(55.8267, 3.16783, -47.748),
|
||||
Vector(55.0125, 3.20429, -56.3455),
|
||||
Vector(54.0781, 3.20927, -64.9114),
|
||||
Vector(53.1076, 3.17979, -74.2689),
|
||||
Vector(52.2437, 3.21515, -82.0613),
|
||||
Vector(51.3169, 3.19196, -90.6292),
|
||||
Vector(50.3008, 3.20521, -99.2916),
|
||||
Vector(60.4217, 3.17473, -100.424),
|
||||
Vector(61.3612, 3.21026, -91.855),
|
||||
Vector(62.2923, 3.1473, -83.2846),
|
||||
Vector(63.2343, 3.18438, -74.7077),
|
||||
Vector(66.1857, 3.23896, -57.6697),
|
||||
Vector(67.1304, 3.19608, -49.0803),
|
||||
Vector(67.2474, 3.17215, -40.4073),
|
||||
Vector(66.2297, 3.20527, -31.6281),
|
||||
Vector(63.8036, 3.21531, -22.7063),
|
||||
Vector(59.241, 3.19388, -13.5084),
|
||||
Vector(53.0474, 3.21296, -4.20644),
|
||||
Vector(4.588, 3.085, 4.934),
|
||||
Vector(7.953, 3.121, -3.686),
|
||||
Vector(13.556, 3.187, -20.951),
|
||||
Vector(28.248, 3.119, -12.431),
|
||||
Vector(21.286, 3.132, -3.812),
|
||||
Vector(16.584, 3.1152, 4.822),
|
||||
Vector(14.232, 3.151, 13.474),
|
||||
Vector(13.178, 3.144, 22.079),
|
||||
Vector(13.074, 3.176, 30.716),
|
||||
Vector(13.053, 3.136, 39.339),
|
||||
Vector(13.062, 3.163, 48.746),
|
||||
Vector(13.067, 3.097, 56.555),
|
||||
Vector(13.051, 3.109, 65.204),
|
||||
Vector(13.073, 3.107, 73.822),
|
||||
Vector(2.997, 3.1082, 73.903),
|
||||
Vector(2.951, 3.127, 65.324),
|
||||
Vector(2.939, 3.117, 56.713),
|
||||
Vector(2.939, 3.100, 48.078),
|
||||
Vector(1.819, 3.048, 30.881),
|
||||
Vector(1.812, 3.076, 22.211),
|
||||
Vector(2.647, 3.154, 13.573),
|
||||
};
|
||||
|
||||
Path p = Path({
|
||||
Vector(-16.9676, 5.7499, -77.5539),
|
||||
Vector(-3.95049, 3.51678, -60.7428),
|
||||
Vector(0.954792, 3.47537, -55.1175),
|
||||
Vector(16.9581, 3.26171, -34.3647),
|
||||
Vector(25.8841, 3.0817, -24.1843),
|
||||
Vector(42.8916, 2.71463, -7.55981),
|
||||
Vector(58.1216, 2.88532, -15.9938),
|
||||
Vector(67.3108, 3.40471, -48.757),
|
||||
Vector(73.9232, 3.10779, -144.263),
|
||||
Vector(81.7667, 3.32603, -172.821),
|
||||
});
|
||||
|
||||
for (auto p : lightPoints)
|
||||
{
|
||||
lights.add(new PointLightActor(scene, p, Vector(251 / 255.f, 207 / 255.f, 107 / 255.f), 2));
|
||||
}
|
||||
|
||||
path = new Entity(scene);
|
||||
path->attachComponent<Path>(p);
|
||||
chapel = new StaticMeshActor(scene, AssetRegistry::findMesh("Whitechapel", "Whitechapel"));
|
||||
followCam->getPathFollow().path = path;
|
||||
}*/
|
||||
/*
|
||||
{
|
||||
Path p = Path({
|
||||
Vector(-28.8013, 9.58383, -84.0442),
|
||||
Vector(-27.5597, 9.09855, -57.1531),
|
||||
Vector(-27.2196, 8.99756, -14.1793),
|
||||
Vector(-27.5354, 8.11755, 26.1741),
|
||||
Vector(-28.6125, 7.32383, 67.1864),
|
||||
Vector(-5.20891, 7.62963, 87.9103),
|
||||
Vector(18.1879, 8.19607, 113.661),
|
||||
Vector(18.8014, 5.01105, 149.623),
|
||||
Vector(18.6341, 4.84045, 183.52),
|
||||
Vector(21.6458, 4.17056, 190.23),
|
||||
});
|
||||
path = new Entity(scene);
|
||||
path->attachComponent<Path>(p);
|
||||
for (uint32 y = 0; y < 2; y++)
|
||||
{
|
||||
for (uint32 x = 0; x < 2; x++)
|
||||
{
|
||||
suburbs.add(new StaticMeshActor(scene, AssetRegistry::findMesh("suburbs", "city-suburbs")));
|
||||
suburbs.back()->getTransform().setPosition(Vector(x * 143, 0, y * 193));
|
||||
}
|
||||
}
|
||||
followCam->getPathFollow().path = path;
|
||||
}*/
|
||||
{
|
||||
Path p = Path({
|
||||
Vector(33.3414, 36.8653, 28.819),
|
||||
Vector(69.6004, 42.7509, 109.65),
|
||||
Vector(82.0893, 43.8156, 127.942),
|
||||
Vector(106.724, 42.0612, 154.561),
|
||||
Vector(168.118, 39.9358, 220.453),
|
||||
Vector(219.94, 42.453, 273.038),
|
||||
Vector(244.23, 44.1136, 289.115),
|
||||
Vector(253.318, 44.4212, 303.567),
|
||||
Vector(256.505, 44.6277, 324.343),
|
||||
Vector(282.637, 45.0222, 371.102),
|
||||
Vector(299.247, 45.3911, 375.493),
|
||||
Vector(393.234, 37.4515, 364.943),
|
||||
});
|
||||
//path = new Entity(scene);
|
||||
//path->attachComponent<Path>(p);
|
||||
//followCam->getPathFollow().path = path;
|
||||
//minecraft = new StaticMeshActor(scene, AssetRegistry::findMesh("minecraft", "minecraft-medieval-city"));
|
||||
//minecraft->getTransform().setScale(Vector(0.01, 0.01, 0.01));
|
||||
}
|
||||
{
|
||||
Path p = Path({
|
||||
Vector(89.3805, 153.648, 270.467),
|
||||
Vector(131.966, 119.247, 116.347),
|
||||
Vector(72.9846, 95.5085, 18.481),
|
||||
Vector(23.1404, 96.2972, 31.0632),
|
||||
Vector(-12.3954, 100.118, -10.2085),
|
||||
Vector(-11.1341, 104.619, -79.1077),
|
||||
Vector(-7.61656, 112.695, -102.459),
|
||||
});
|
||||
//path = new Entity(scene);
|
||||
//path->attachComponent<Path>(p);
|
||||
//followCam->getPathFollow().path = path;
|
||||
//volvo = new StaticMeshActor(scene, AssetRegistry::findMesh("Volvo", "Volvo"));
|
||||
}
|
||||
|
||||
|
||||
test = new StaticMeshActor(scene, AssetRegistry::findMesh("rttest", "rttest"));
|
||||
//test->getTransform().setScale(Vector(0.01, 0.01, 0.01));
|
||||
|
||||
/*for (int32 y = -40; y < 40; ++y)
|
||||
{
|
||||
for (int32 x = -40; x < 40; ++x)
|
||||
{
|
||||
scene->attachComponent<Component::WaterTile>(scene->createEntity(), Component::WaterTile{
|
||||
.location = IVector2(x, y),
|
||||
.height = 0,
|
||||
});
|
||||
}
|
||||
}*/
|
||||
|
||||
center = new PointLightActor(scene, Vector(0, 0, 0), 10, Vector(1, 1, 1), 10);
|
||||
xAxis = new PointLightActor(scene, Vector(10, 0, 0), 10, Vector(1, 0, 0), 10);
|
||||
yAxis = new PointLightActor(scene, Vector(0, 10, 0), 10, Vector(0, 1, 0), 10);
|
||||
zAxis = new PointLightActor(scene, Vector(0, 0, 10), 10, Vector(0, 0, 1), 10);
|
||||
light = new DirectionalLightActor(scene, Vector(1, 1, 1), 1, Vector(0.4, -0.4, 0));
|
||||
graph->addSystem(new FlyCamSystem(scene));
|
||||
graph->addSystem(new SplineCamSystem(scene));
|
||||
}
|
||||
|
||||
Game* createInstance()
|
||||
{
|
||||
return new MeshShadingDemoGame();
|
||||
}
|
||||
|
||||
void destroyInstance(Game* game)
|
||||
{
|
||||
delete game;
|
||||
#include "MeshShadingDemoGame.h"
|
||||
#include "Actor/FlyCam.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Component/TerrainTile.h"
|
||||
#include "System/FlyCamSystem.h"
|
||||
#include "Component/Path.h"
|
||||
#include "Component/WaterTile.h"
|
||||
#include "System/SplineCamSystem.h"
|
||||
#include "Graphics/StaticMeshVertexData.h"
|
||||
|
||||
MeshShadingDemoGame::MeshShadingDemoGame()
|
||||
{
|
||||
}
|
||||
|
||||
MeshShadingDemoGame::~MeshShadingDemoGame()
|
||||
{
|
||||
}
|
||||
|
||||
void MeshShadingDemoGame::setupScene(PScene scene, PSystemGraph graph)
|
||||
{
|
||||
flyCam = new FlyCam(scene);
|
||||
flyCam->attachComponent<Component::PointLight>(Vector(1, 1, 1), 1.0f, 2.0f);
|
||||
flyCam->getCamera().mainCamera = true;
|
||||
|
||||
followCam = new PathFollowCam(scene);
|
||||
//followCam->getCamera().mainCamera = true;
|
||||
|
||||
/* {
|
||||
Array<Vector> lightPoints = {
|
||||
Vector(13.542, 3.12369, -12.3293),
|
||||
Vector(20.6668, 3.04548, -20.9486),
|
||||
Vector(11.5522, 3.09676, -45.9563),
|
||||
Vector(10.392, 3.0536, -63.238),
|
||||
Vector(14.8289, 3.01454, -72.0112),
|
||||
Vector(16.9386, 3.06158, -80.7447),
|
||||
Vector(17.6772, 3.05903, -89.3406),
|
||||
Vector(17.4801, 3.03598, -97.9897),
|
||||
Vector(17.1882, 3.04928, -106.596),
|
||||
Vector(16.8547, 3.05735, -116.065),
|
||||
Vector(16.6074, 3.05262, -123.884),
|
||||
Vector(16.331, 3.03858, -132.499),
|
||||
Vector(16.0015, 3.07391, -141.126),
|
||||
Vector(26.1148, 3.05149, -141.591),
|
||||
Vector(26.4517, 3.06293, -132.945),
|
||||
Vector(26.7491, 3.06205, -124.321),
|
||||
Vector(27.0371, 3.11222, -115.731),
|
||||
Vector(28.7401, 3.063, -98.5291),
|
||||
Vector(29.0123, 3.09289, -89.8635),
|
||||
Vector(28.5112, 3.07688, -81.2221),
|
||||
Vector(26.8285, 3.12346, -72.5381),
|
||||
Vector(23.7577, 3.07845, -63.8065),
|
||||
Vector(18.4836, 3.07243, -54.9846),
|
||||
Vector(11.5667, 3.0757, -46.1511),
|
||||
Vector(44.4868, 3.169, -11.858),
|
||||
Vector(50.5335, 3.15588, -21.1511),
|
||||
Vector(54.2709, 3.18958, -30.2516),
|
||||
Vector(55.6934, 3.22225, -39.0652),
|
||||
Vector(55.8267, 3.16783, -47.748),
|
||||
Vector(55.0125, 3.20429, -56.3455),
|
||||
Vector(54.0781, 3.20927, -64.9114),
|
||||
Vector(53.1076, 3.17979, -74.2689),
|
||||
Vector(52.2437, 3.21515, -82.0613),
|
||||
Vector(51.3169, 3.19196, -90.6292),
|
||||
Vector(50.3008, 3.20521, -99.2916),
|
||||
Vector(60.4217, 3.17473, -100.424),
|
||||
Vector(61.3612, 3.21026, -91.855),
|
||||
Vector(62.2923, 3.1473, -83.2846),
|
||||
Vector(63.2343, 3.18438, -74.7077),
|
||||
Vector(66.1857, 3.23896, -57.6697),
|
||||
Vector(67.1304, 3.19608, -49.0803),
|
||||
Vector(67.2474, 3.17215, -40.4073),
|
||||
Vector(66.2297, 3.20527, -31.6281),
|
||||
Vector(63.8036, 3.21531, -22.7063),
|
||||
Vector(59.241, 3.19388, -13.5084),
|
||||
Vector(53.0474, 3.21296, -4.20644),
|
||||
Vector(4.588, 3.085, 4.934),
|
||||
Vector(7.953, 3.121, -3.686),
|
||||
Vector(13.556, 3.187, -20.951),
|
||||
Vector(28.248, 3.119, -12.431),
|
||||
Vector(21.286, 3.132, -3.812),
|
||||
Vector(16.584, 3.1152, 4.822),
|
||||
Vector(14.232, 3.151, 13.474),
|
||||
Vector(13.178, 3.144, 22.079),
|
||||
Vector(13.074, 3.176, 30.716),
|
||||
Vector(13.053, 3.136, 39.339),
|
||||
Vector(13.062, 3.163, 48.746),
|
||||
Vector(13.067, 3.097, 56.555),
|
||||
Vector(13.051, 3.109, 65.204),
|
||||
Vector(13.073, 3.107, 73.822),
|
||||
Vector(2.997, 3.1082, 73.903),
|
||||
Vector(2.951, 3.127, 65.324),
|
||||
Vector(2.939, 3.117, 56.713),
|
||||
Vector(2.939, 3.100, 48.078),
|
||||
Vector(1.819, 3.048, 30.881),
|
||||
Vector(1.812, 3.076, 22.211),
|
||||
Vector(2.647, 3.154, 13.573),
|
||||
};
|
||||
|
||||
Path p = Path({
|
||||
Vector(-16.9676, 5.7499, -77.5539),
|
||||
Vector(-3.95049, 3.51678, -60.7428),
|
||||
Vector(0.954792, 3.47537, -55.1175),
|
||||
Vector(16.9581, 3.26171, -34.3647),
|
||||
Vector(25.8841, 3.0817, -24.1843),
|
||||
Vector(42.8916, 2.71463, -7.55981),
|
||||
Vector(58.1216, 2.88532, -15.9938),
|
||||
Vector(67.3108, 3.40471, -48.757),
|
||||
Vector(73.9232, 3.10779, -144.263),
|
||||
Vector(81.7667, 3.32603, -172.821),
|
||||
});
|
||||
|
||||
for (auto p : lightPoints)
|
||||
{
|
||||
lights.add(new PointLightActor(scene, p, Vector(251 / 255.f, 207 / 255.f, 107 / 255.f), 2));
|
||||
}
|
||||
|
||||
path = new Entity(scene);
|
||||
path->attachComponent<Path>(p);
|
||||
chapel = new StaticMeshActor(scene, AssetRegistry::findMesh("Whitechapel", "Whitechapel"));
|
||||
followCam->getPathFollow().path = path;
|
||||
}*/
|
||||
/*
|
||||
{
|
||||
Path p = Path({
|
||||
Vector(-28.8013, 9.58383, -84.0442),
|
||||
Vector(-27.5597, 9.09855, -57.1531),
|
||||
Vector(-27.2196, 8.99756, -14.1793),
|
||||
Vector(-27.5354, 8.11755, 26.1741),
|
||||
Vector(-28.6125, 7.32383, 67.1864),
|
||||
Vector(-5.20891, 7.62963, 87.9103),
|
||||
Vector(18.1879, 8.19607, 113.661),
|
||||
Vector(18.8014, 5.01105, 149.623),
|
||||
Vector(18.6341, 4.84045, 183.52),
|
||||
Vector(21.6458, 4.17056, 190.23),
|
||||
});
|
||||
path = new Entity(scene);
|
||||
path->attachComponent<Path>(p);
|
||||
for (uint32 y = 0; y < 2; y++)
|
||||
{
|
||||
for (uint32 x = 0; x < 2; x++)
|
||||
{
|
||||
suburbs.add(new StaticMeshActor(scene, AssetRegistry::findMesh("suburbs", "city-suburbs")));
|
||||
suburbs.back()->getTransform().setPosition(Vector(x * 143, 0, y * 193));
|
||||
}
|
||||
}
|
||||
followCam->getPathFollow().path = path;
|
||||
}*/
|
||||
{
|
||||
Path p = Path({
|
||||
Vector(33.3414, 36.8653, 28.819),
|
||||
Vector(69.6004, 42.7509, 109.65),
|
||||
Vector(82.0893, 43.8156, 127.942),
|
||||
Vector(106.724, 42.0612, 154.561),
|
||||
Vector(168.118, 39.9358, 220.453),
|
||||
Vector(219.94, 42.453, 273.038),
|
||||
Vector(244.23, 44.1136, 289.115),
|
||||
Vector(253.318, 44.4212, 303.567),
|
||||
Vector(256.505, 44.6277, 324.343),
|
||||
Vector(282.637, 45.0222, 371.102),
|
||||
Vector(299.247, 45.3911, 375.493),
|
||||
Vector(393.234, 37.4515, 364.943),
|
||||
});
|
||||
//path = new Entity(scene);
|
||||
//path->attachComponent<Path>(p);
|
||||
//followCam->getPathFollow().path = path;
|
||||
//minecraft = new StaticMeshActor(scene, AssetRegistry::findMesh("minecraft", "minecraft-medieval-city"));
|
||||
//minecraft->getTransform().setScale(Vector(0.01, 0.01, 0.01));
|
||||
}
|
||||
{
|
||||
Path p = Path({
|
||||
Vector(89.3805, 153.648, 270.467),
|
||||
Vector(131.966, 119.247, 116.347),
|
||||
Vector(72.9846, 95.5085, 18.481),
|
||||
Vector(23.1404, 96.2972, 31.0632),
|
||||
Vector(-12.3954, 100.118, -10.2085),
|
||||
Vector(-11.1341, 104.619, -79.1077),
|
||||
Vector(-7.61656, 112.695, -102.459),
|
||||
});
|
||||
//path = new Entity(scene);
|
||||
//path->attachComponent<Path>(p);
|
||||
//followCam->getPathFollow().path = path;
|
||||
//volvo = new StaticMeshActor(scene, AssetRegistry::findMesh("Volvo", "Volvo"));
|
||||
}
|
||||
|
||||
|
||||
test = new StaticMeshActor(scene, AssetRegistry::findMesh("rttest", "rttest"));
|
||||
//test->getTransform().setScale(Vector(0.01, 0.01, 0.01));
|
||||
|
||||
/*for (int32 y = -40; y < 40; ++y)
|
||||
{
|
||||
for (int32 x = -40; x < 40; ++x)
|
||||
{
|
||||
scene->attachComponent<Component::WaterTile>(scene->createEntity(), Component::WaterTile{
|
||||
.location = IVector2(x, y),
|
||||
.height = 0,
|
||||
});
|
||||
}
|
||||
}*/
|
||||
|
||||
center = new PointLightActor(scene, Vector(0, 0, 0), 10, Vector(1, 1, 1), 10);
|
||||
xAxis = new PointLightActor(scene, Vector(10, 0, 0), 10, Vector(1, 0, 0), 10);
|
||||
yAxis = new PointLightActor(scene, Vector(0, 10, 0), 10, Vector(0, 1, 0), 10);
|
||||
zAxis = new PointLightActor(scene, Vector(0, 0, 10), 10, Vector(0, 0, 1), 10);
|
||||
light = new DirectionalLightActor(scene, Vector(1, 1, 1), 1, Vector(0.4, -0.4, 0));
|
||||
graph->addSystem(new FlyCamSystem(scene));
|
||||
graph->addSystem(new SplineCamSystem(scene));
|
||||
}
|
||||
|
||||
Game* createInstance()
|
||||
{
|
||||
return new MeshShadingDemoGame();
|
||||
}
|
||||
|
||||
void destroyInstance(Game* game)
|
||||
{
|
||||
delete game;
|
||||
}
|
||||
+33
-33
@@ -1,34 +1,34 @@
|
||||
#pragma once
|
||||
#include "Actor/FlyCam.h"
|
||||
#include "Actor/PathFollowCam.h"
|
||||
#include "Define.h"
|
||||
#include <Actor/StaticMeshActor.h>
|
||||
#include <Actor/DirectionalLightActor.h>
|
||||
#include <Actor/PointLightActor.h>
|
||||
#include <Game.h>
|
||||
|
||||
class MESHSHADINGDEMO_API MeshShadingDemoGame : public Game {
|
||||
public:
|
||||
MeshShadingDemoGame();
|
||||
virtual ~MeshShadingDemoGame();
|
||||
virtual void setupScene(PScene scene, PSystemGraph graph) override;
|
||||
|
||||
private:
|
||||
Array<OPointLightActor> lights;
|
||||
OStaticMeshActor chapel;
|
||||
OStaticMeshActor test;
|
||||
OStaticMeshActor minecraft;
|
||||
OStaticMeshActor volvo;
|
||||
Array<OStaticMeshActor> suburbs;
|
||||
OEntity path;
|
||||
OFlyCam flyCam;
|
||||
OPathFollowCam followCam;
|
||||
ODirectionalLightActor light;
|
||||
OPointLightActor center;
|
||||
OPointLightActor xAxis;
|
||||
OPointLightActor yAxis;
|
||||
OPointLightActor zAxis;
|
||||
};
|
||||
|
||||
extern "C" MESHSHADINGDEMO_API Game* createInstance();
|
||||
#pragma once
|
||||
#include "Actor/FlyCam.h"
|
||||
#include "Actor/PathFollowCam.h"
|
||||
#include "Define.h"
|
||||
#include <Actor/StaticMeshActor.h>
|
||||
#include <Actor/DirectionalLightActor.h>
|
||||
#include <Actor/PointLightActor.h>
|
||||
#include <Game.h>
|
||||
|
||||
class MESHSHADINGDEMO_API MeshShadingDemoGame : public Game {
|
||||
public:
|
||||
MeshShadingDemoGame();
|
||||
virtual ~MeshShadingDemoGame();
|
||||
virtual void setupScene(PScene scene, PSystemGraph graph) override;
|
||||
|
||||
private:
|
||||
Array<OPointLightActor> lights;
|
||||
OStaticMeshActor chapel;
|
||||
OStaticMeshActor test;
|
||||
OStaticMeshActor minecraft;
|
||||
OStaticMeshActor volvo;
|
||||
Array<OStaticMeshActor> suburbs;
|
||||
OEntity path;
|
||||
OFlyCam flyCam;
|
||||
OPathFollowCam followCam;
|
||||
ODirectionalLightActor light;
|
||||
OPointLightActor center;
|
||||
OPointLightActor xAxis;
|
||||
OPointLightActor yAxis;
|
||||
OPointLightActor zAxis;
|
||||
};
|
||||
|
||||
extern "C" MESHSHADINGDEMO_API Game* createInstance();
|
||||
extern "C" MESHSHADINGDEMO_API void destroyInstance(Game* game);
|
||||
@@ -1,6 +1,6 @@
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
FlyCamSystem.h
|
||||
FlyCamSystem.cpp
|
||||
SplineCamSystem.h
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
FlyCamSystem.h
|
||||
FlyCamSystem.cpp
|
||||
SplineCamSystem.h
|
||||
SplineCamSystem.cpp)
|
||||
+53
-53
@@ -1,54 +1,54 @@
|
||||
#include "FlyCamSystem.h"
|
||||
|
||||
FlyCamSystem::FlyCamSystem(PScene scene)
|
||||
: System::ComponentSystem<Component::KeyboardInput, Component::Camera, Component::Transform, Component::PointLight>(scene) {}
|
||||
|
||||
FlyCamSystem::~FlyCamSystem() {}
|
||||
|
||||
void FlyCamSystem::update(Component::KeyboardInput& input, Component::Camera& camera, Component::Transform& transform, Component::PointLight& light) {
|
||||
float cameraMove = static_cast<float>(deltaTime) * 4;
|
||||
if(input.keys[KeyCode::KEY_LEFT_SHIFT])
|
||||
{
|
||||
cameraMove *= 10;
|
||||
}
|
||||
Vector forward = transform.getForward();
|
||||
Vector side = transform.getRight();
|
||||
Vector moveVector = Vector();
|
||||
|
||||
if (input.keys[KeyCode::KEY_J])
|
||||
{
|
||||
std::cout << transform.getPosition() << std::endl;
|
||||
}
|
||||
|
||||
if(input.keys[KeyCode::KEY_W])
|
||||
{
|
||||
moveVector += forward * cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_S])
|
||||
{
|
||||
moveVector += forward * -cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_A])
|
||||
{
|
||||
moveVector += side * -cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_D])
|
||||
{
|
||||
moveVector += side * cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_E])
|
||||
{
|
||||
moveVector += Vector(0, cameraMove, 0);
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_Q])
|
||||
{
|
||||
moveVector += Vector(0, -cameraMove, 0);
|
||||
}
|
||||
transform.translate(moveVector);
|
||||
if(input.mouse2)
|
||||
{
|
||||
transform.setRotation(glm::rotate(transform.getRotation(), input.deltaX / 500, Vector(0, 1, 0)));
|
||||
transform.setRotation(glm::rotate(transform.getRotation(), input.deltaY / 500, transform.getRight()));
|
||||
}
|
||||
light.attenuation += input.scrollY * 0.1;
|
||||
#include "FlyCamSystem.h"
|
||||
|
||||
FlyCamSystem::FlyCamSystem(PScene scene)
|
||||
: System::ComponentSystem<Component::KeyboardInput, Component::Camera, Component::Transform, Component::PointLight>(scene) {}
|
||||
|
||||
FlyCamSystem::~FlyCamSystem() {}
|
||||
|
||||
void FlyCamSystem::update(Component::KeyboardInput& input, Component::Camera& camera, Component::Transform& transform, Component::PointLight& light) {
|
||||
float cameraMove = static_cast<float>(deltaTime) * 4;
|
||||
if(input.keys[KeyCode::KEY_LEFT_SHIFT])
|
||||
{
|
||||
cameraMove *= 10;
|
||||
}
|
||||
Vector forward = transform.getForward();
|
||||
Vector side = transform.getRight();
|
||||
Vector moveVector = Vector();
|
||||
|
||||
if (input.keys[KeyCode::KEY_J])
|
||||
{
|
||||
std::cout << transform.getPosition() << std::endl;
|
||||
}
|
||||
|
||||
if(input.keys[KeyCode::KEY_W])
|
||||
{
|
||||
moveVector += forward * cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_S])
|
||||
{
|
||||
moveVector += forward * -cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_A])
|
||||
{
|
||||
moveVector += side * -cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_D])
|
||||
{
|
||||
moveVector += side * cameraMove;
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_E])
|
||||
{
|
||||
moveVector += Vector(0, cameraMove, 0);
|
||||
}
|
||||
if(input.keys[KeyCode::KEY_Q])
|
||||
{
|
||||
moveVector += Vector(0, -cameraMove, 0);
|
||||
}
|
||||
transform.translate(moveVector);
|
||||
if(input.mouse2)
|
||||
{
|
||||
transform.setRotation(glm::rotate(transform.getRotation(), input.deltaX / 500, Vector(0, 1, 0)));
|
||||
transform.setRotation(glm::rotate(transform.getRotation(), input.deltaY / 500, transform.getRight()));
|
||||
}
|
||||
light.attenuation += input.scrollY * 0.1;
|
||||
}
|
||||
+22
-22
@@ -1,23 +1,23 @@
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Scene/Scene.h>
|
||||
#include <System/ComponentSystem.h>
|
||||
#include <Component/Camera.h>
|
||||
#include <Component/KeyboardInput.h>
|
||||
|
||||
class FlyCamSystem : public System::ComponentSystem<
|
||||
Component::KeyboardInput,
|
||||
Component::Camera,
|
||||
Component::Transform,
|
||||
Component::PointLight>
|
||||
{
|
||||
public:
|
||||
FlyCamSystem(PScene scene);
|
||||
virtual ~FlyCamSystem();
|
||||
virtual void update(Seele::Component::KeyboardInput& input, Seele::Component::Camera& camera, Seele::Component::Transform& transform, Seele::Component::PointLight& pointLight) override;
|
||||
private:
|
||||
float lastMouseX;
|
||||
float lastMouseY;
|
||||
};
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Scene/Scene.h>
|
||||
#include <System/ComponentSystem.h>
|
||||
#include <Component/Camera.h>
|
||||
#include <Component/KeyboardInput.h>
|
||||
|
||||
class FlyCamSystem : public System::ComponentSystem<
|
||||
Component::KeyboardInput,
|
||||
Component::Camera,
|
||||
Component::Transform,
|
||||
Component::PointLight>
|
||||
{
|
||||
public:
|
||||
FlyCamSystem(PScene scene);
|
||||
virtual ~FlyCamSystem();
|
||||
virtual void update(Seele::Component::KeyboardInput& input, Seele::Component::Camera& camera, Seele::Component::Transform& transform, Seele::Component::PointLight& pointLight) override;
|
||||
private:
|
||||
float lastMouseX;
|
||||
float lastMouseY;
|
||||
};
|
||||
DEFINE_REF(FlyCamSystem)
|
||||
+141
-141
@@ -1,141 +1,141 @@
|
||||
#include "SplineCamSystem.h"
|
||||
|
||||
SplineCamSystem::SplineCamSystem(PScene scene)
|
||||
: System::ComponentSystem<Component::Camera, Component::Transform, PathFollow>(scene)
|
||||
{}
|
||||
|
||||
SplineCamSystem::~SplineCamSystem()
|
||||
{}
|
||||
|
||||
void SplineCamSystem::update(Component::Camera& cam, Component::Transform& transform, PathFollow& follow)
|
||||
{
|
||||
if (follow.path == nullptr)
|
||||
return;
|
||||
Path& path = follow.path->accessComponent<Path>();
|
||||
|
||||
//for (size_t i = 0; i < path.points.size() - 1; ++i)
|
||||
//{
|
||||
// addDebugVertex(DebugVertex{
|
||||
// .position = path.points[i],
|
||||
// .color = Vector(0, 1, 0)
|
||||
// });
|
||||
// addDebugVertex(DebugVertex{
|
||||
// .position = path.points[i + 1],
|
||||
// .color = Vector(0, 1, 0)
|
||||
// });
|
||||
//}
|
||||
|
||||
updateFollowDistance(follow, path.getPathLength());
|
||||
std::tuple<int, float> pt = findP0AndTForDistance(path, follow.distance);
|
||||
auto [p0Index, t] = pt;
|
||||
if (p0Index < 0 || (path.points.size() <= p0Index + 3 && !path.looping))
|
||||
// Not enough points to interpolate...
|
||||
return;
|
||||
|
||||
Vector p0 = path.points[p0Index];
|
||||
Vector p1 = path.points[(p0Index + 1) % path.points.size()];
|
||||
Vector p2 = path.points[(p0Index + 2) % path.points.size()];
|
||||
Vector p3 = path.points[(p0Index + 3) % path.points.size()];
|
||||
|
||||
Vector oldPos = transform.getPosition() - follow.pathOffset;
|
||||
Vector newPos = path.catmullrom(t, p0, p1, p2, p3, path.tension);
|
||||
transform.setPosition(newPos + follow.pathOffset);
|
||||
|
||||
if ((oldPos - follow.lastPos).length() > Path::LAST_POS_EPSILON)
|
||||
{
|
||||
follow.lastPos = oldPos;
|
||||
}
|
||||
Vector tangentVector = glm::normalize(follow.lastPos - newPos);
|
||||
Quaternion newRot = glm::quatLookAt(tangentVector, Vector(0.0f, 1.0f, 0.0f));
|
||||
transform.setRotation(newRot);
|
||||
}
|
||||
|
||||
std::tuple<int, float> SplineCamSystem::findP0AndTForDistance(const Path& path, float distance)
|
||||
{
|
||||
if (path.arcLengthTable.size() == 0)
|
||||
return std::tuple<int, float>(-1, 0.0f);
|
||||
|
||||
int p0 = -1;
|
||||
float t = 0.0f;
|
||||
|
||||
int pIndexToCheck = 1;//path.pointOffset + 1;
|
||||
|
||||
//if (path.looping)
|
||||
//{
|
||||
// // If looping, subtract loop distance until we are in the final "lap"
|
||||
// float lapDistance = path.arcLengthTable[path.arcLengthTable.size() - 1][path.arcLengthTable[path.arcLengthTable.size() - 1].size() - 1];
|
||||
// while (distance >= lapDistance)
|
||||
// {
|
||||
// distance -= lapDistance;
|
||||
// }
|
||||
//
|
||||
// // If we are in a new loop, the path.pointOffset might not be valid anymore
|
||||
// if (path.arcLengthTable[path.pointOffset][0] > distance)
|
||||
// {
|
||||
// pIndexToCheck = 1;
|
||||
// }
|
||||
//}
|
||||
float lapDistance = path.arcLengthTable[path.arcLengthTable.size() - 1][path.arcLengthTable[path.arcLengthTable.size() - 1].size() - 1];
|
||||
if (distance >= lapDistance)
|
||||
{
|
||||
getGlobals().running = false;
|
||||
}
|
||||
|
||||
while (pIndexToCheck < path.arcLengthTable.size()
|
||||
&& path.arcLengthTable[pIndexToCheck][0] < distance)
|
||||
{
|
||||
pIndexToCheck++;
|
||||
}
|
||||
p0 = pIndexToCheck - 1;
|
||||
|
||||
int arcTableIndex = 1;
|
||||
float additionalT = 0.0f;
|
||||
// TODO this could be improved e.g. by using binary search
|
||||
while (arcTableIndex < path.arcLengthTable[p0].size()
|
||||
&& path.arcLengthTable[p0][arcTableIndex] < distance)
|
||||
{
|
||||
arcTableIndex++;
|
||||
}
|
||||
arcTableIndex--;
|
||||
|
||||
// Interpolate between arc length table entries to find additionalT
|
||||
if (arcTableIndex + 1 < path.arcLengthTable[p0].size())
|
||||
{
|
||||
float distanceA = path.arcLengthTable[p0][arcTableIndex];
|
||||
float distanceB = path.arcLengthTable[p0][arcTableIndex + 1];
|
||||
|
||||
float abDistance = distanceB - distanceA;
|
||||
float requiredDistanceAfterA = distance - distanceA;
|
||||
additionalT = Path::ARC_LENGTH_TABLE_DISTANCE * (requiredDistanceAfterA / abDistance);
|
||||
}
|
||||
|
||||
t = (arcTableIndex * Path::ARC_LENGTH_TABLE_DISTANCE) + additionalT;
|
||||
|
||||
assert(p0 < path.points.size());
|
||||
assert(t >= 0.0f && t <= 1.0f);
|
||||
return std::tuple<int, float>(p0, t);
|
||||
}
|
||||
|
||||
void SplineCamSystem::updateFollowDistance(PathFollow& follow, float pathLength)
|
||||
{
|
||||
follow.time = follow.time + deltaTime;
|
||||
switch (follow.speedControl)
|
||||
{
|
||||
case PathFollow::SpeedControl::Linear:
|
||||
// We increase distance instead of setting it based on overall time, because Linear SpeedControl allows for traversalSpeed change
|
||||
follow.distance += (deltaTime * follow.traversalSpeed);
|
||||
break;
|
||||
case PathFollow::SpeedControl::EaseInEaseOut:
|
||||
{
|
||||
float timeNeededForPath = pathLength / follow.traversalSpeed;
|
||||
float t = follow.time / timeNeededForPath;
|
||||
int laps = (int)t;
|
||||
t = t - laps;
|
||||
float s = (glm::sin(t * glm::pi<float>() - glm::pi<float>() / 2.f) + 1) / 2.f;
|
||||
follow.distance = ((laps + s) * pathLength);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false && "Unknown SpeedControl");
|
||||
}
|
||||
}
|
||||
#include "SplineCamSystem.h"
|
||||
|
||||
SplineCamSystem::SplineCamSystem(PScene scene)
|
||||
: System::ComponentSystem<Component::Camera, Component::Transform, PathFollow>(scene)
|
||||
{}
|
||||
|
||||
SplineCamSystem::~SplineCamSystem()
|
||||
{}
|
||||
|
||||
void SplineCamSystem::update(Component::Camera& cam, Component::Transform& transform, PathFollow& follow)
|
||||
{
|
||||
if (follow.path == nullptr)
|
||||
return;
|
||||
Path& path = follow.path->accessComponent<Path>();
|
||||
|
||||
//for (size_t i = 0; i < path.points.size() - 1; ++i)
|
||||
//{
|
||||
// addDebugVertex(DebugVertex{
|
||||
// .position = path.points[i],
|
||||
// .color = Vector(0, 1, 0)
|
||||
// });
|
||||
// addDebugVertex(DebugVertex{
|
||||
// .position = path.points[i + 1],
|
||||
// .color = Vector(0, 1, 0)
|
||||
// });
|
||||
//}
|
||||
|
||||
updateFollowDistance(follow, path.getPathLength());
|
||||
std::tuple<int, float> pt = findP0AndTForDistance(path, follow.distance);
|
||||
auto [p0Index, t] = pt;
|
||||
if (p0Index < 0 || (path.points.size() <= p0Index + 3 && !path.looping))
|
||||
// Not enough points to interpolate...
|
||||
return;
|
||||
|
||||
Vector p0 = path.points[p0Index];
|
||||
Vector p1 = path.points[(p0Index + 1) % path.points.size()];
|
||||
Vector p2 = path.points[(p0Index + 2) % path.points.size()];
|
||||
Vector p3 = path.points[(p0Index + 3) % path.points.size()];
|
||||
|
||||
Vector oldPos = transform.getPosition() - follow.pathOffset;
|
||||
Vector newPos = path.catmullrom(t, p0, p1, p2, p3, path.tension);
|
||||
transform.setPosition(newPos + follow.pathOffset);
|
||||
|
||||
if ((oldPos - follow.lastPos).length() > Path::LAST_POS_EPSILON)
|
||||
{
|
||||
follow.lastPos = oldPos;
|
||||
}
|
||||
Vector tangentVector = glm::normalize(follow.lastPos - newPos);
|
||||
Quaternion newRot = glm::quatLookAt(tangentVector, Vector(0.0f, 1.0f, 0.0f));
|
||||
transform.setRotation(newRot);
|
||||
}
|
||||
|
||||
std::tuple<int, float> SplineCamSystem::findP0AndTForDistance(const Path& path, float distance)
|
||||
{
|
||||
if (path.arcLengthTable.size() == 0)
|
||||
return std::tuple<int, float>(-1, 0.0f);
|
||||
|
||||
int p0 = -1;
|
||||
float t = 0.0f;
|
||||
|
||||
int pIndexToCheck = 1;//path.pointOffset + 1;
|
||||
|
||||
//if (path.looping)
|
||||
//{
|
||||
// // If looping, subtract loop distance until we are in the final "lap"
|
||||
// float lapDistance = path.arcLengthTable[path.arcLengthTable.size() - 1][path.arcLengthTable[path.arcLengthTable.size() - 1].size() - 1];
|
||||
// while (distance >= lapDistance)
|
||||
// {
|
||||
// distance -= lapDistance;
|
||||
// }
|
||||
//
|
||||
// // If we are in a new loop, the path.pointOffset might not be valid anymore
|
||||
// if (path.arcLengthTable[path.pointOffset][0] > distance)
|
||||
// {
|
||||
// pIndexToCheck = 1;
|
||||
// }
|
||||
//}
|
||||
float lapDistance = path.arcLengthTable[path.arcLengthTable.size() - 1][path.arcLengthTable[path.arcLengthTable.size() - 1].size() - 1];
|
||||
if (distance >= lapDistance)
|
||||
{
|
||||
getGlobals().running = false;
|
||||
}
|
||||
|
||||
while (pIndexToCheck < path.arcLengthTable.size()
|
||||
&& path.arcLengthTable[pIndexToCheck][0] < distance)
|
||||
{
|
||||
pIndexToCheck++;
|
||||
}
|
||||
p0 = pIndexToCheck - 1;
|
||||
|
||||
int arcTableIndex = 1;
|
||||
float additionalT = 0.0f;
|
||||
// TODO this could be improved e.g. by using binary search
|
||||
while (arcTableIndex < path.arcLengthTable[p0].size()
|
||||
&& path.arcLengthTable[p0][arcTableIndex] < distance)
|
||||
{
|
||||
arcTableIndex++;
|
||||
}
|
||||
arcTableIndex--;
|
||||
|
||||
// Interpolate between arc length table entries to find additionalT
|
||||
if (arcTableIndex + 1 < path.arcLengthTable[p0].size())
|
||||
{
|
||||
float distanceA = path.arcLengthTable[p0][arcTableIndex];
|
||||
float distanceB = path.arcLengthTable[p0][arcTableIndex + 1];
|
||||
|
||||
float abDistance = distanceB - distanceA;
|
||||
float requiredDistanceAfterA = distance - distanceA;
|
||||
additionalT = Path::ARC_LENGTH_TABLE_DISTANCE * (requiredDistanceAfterA / abDistance);
|
||||
}
|
||||
|
||||
t = (arcTableIndex * Path::ARC_LENGTH_TABLE_DISTANCE) + additionalT;
|
||||
|
||||
assert(p0 < path.points.size());
|
||||
assert(t >= 0.0f && t <= 1.0f);
|
||||
return std::tuple<int, float>(p0, t);
|
||||
}
|
||||
|
||||
void SplineCamSystem::updateFollowDistance(PathFollow& follow, float pathLength)
|
||||
{
|
||||
follow.time = follow.time + deltaTime;
|
||||
switch (follow.speedControl)
|
||||
{
|
||||
case PathFollow::SpeedControl::Linear:
|
||||
// We increase distance instead of setting it based on overall time, because Linear SpeedControl allows for traversalSpeed change
|
||||
follow.distance += (deltaTime * follow.traversalSpeed);
|
||||
break;
|
||||
case PathFollow::SpeedControl::EaseInEaseOut:
|
||||
{
|
||||
float timeNeededForPath = pathLength / follow.traversalSpeed;
|
||||
float t = follow.time / timeNeededForPath;
|
||||
int laps = (int)t;
|
||||
t = t - laps;
|
||||
float s = (glm::sin(t * glm::pi<float>() - glm::pi<float>() / 2.f) + 1) / 2.f;
|
||||
follow.distance = ((laps + s) * pathLength);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false && "Unknown SpeedControl");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Scene/Scene.h>
|
||||
#include <System/ComponentSystem.h>
|
||||
#include <Component/Camera.h>
|
||||
#include <Component/Path.h>
|
||||
#include <Component/PathFollow.h>
|
||||
|
||||
class SplineCamSystem : public System::ComponentSystem<
|
||||
Component::Camera,
|
||||
Component::Transform,
|
||||
PathFollow>
|
||||
{
|
||||
public:
|
||||
SplineCamSystem(PScene scene);
|
||||
virtual ~SplineCamSystem();
|
||||
virtual void update(Component::Camera& camera, Component::Transform& transform, PathFollow& follow);
|
||||
private:
|
||||
std::tuple<int, float> findP0AndTForDistance(const Path& path, float distance);
|
||||
void updateFollowDistance(PathFollow& follow, float pathLength);
|
||||
};
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include <MinimalEngine.h>
|
||||
#include <Scene/Scene.h>
|
||||
#include <System/ComponentSystem.h>
|
||||
#include <Component/Camera.h>
|
||||
#include <Component/Path.h>
|
||||
#include <Component/PathFollow.h>
|
||||
|
||||
class SplineCamSystem : public System::ComponentSystem<
|
||||
Component::Camera,
|
||||
Component::Transform,
|
||||
PathFollow>
|
||||
{
|
||||
public:
|
||||
SplineCamSystem(PScene scene);
|
||||
virtual ~SplineCamSystem();
|
||||
virtual void update(Component::Camera& camera, Component::Transform& transform, PathFollow& follow);
|
||||
private:
|
||||
std::tuple<int, float> findP0AndTForDistance(const Path& path, float distance);
|
||||
void updateFollowDistance(PathFollow& follow, float pathLength);
|
||||
};
|
||||
DEFINE_REF(SplineCamSystem)
|
||||
+20
-20
@@ -1,21 +1,21 @@
|
||||
{
|
||||
"dependencies": [
|
||||
"assimp",
|
||||
"entt",
|
||||
"stb",
|
||||
"entt",
|
||||
"freetype",
|
||||
"glfw3",
|
||||
"glm",
|
||||
"ktx",
|
||||
"nlohmann-json",
|
||||
"fmt",
|
||||
"gtest",
|
||||
"vulkan-memory-allocator",
|
||||
"lunasvg",
|
||||
"harfbuzz",
|
||||
"shader-slang",
|
||||
"metis",
|
||||
"meshoptimizer"
|
||||
]
|
||||
{
|
||||
"dependencies": [
|
||||
"assimp",
|
||||
"entt",
|
||||
"stb",
|
||||
"entt",
|
||||
"freetype",
|
||||
"glfw3",
|
||||
"glm",
|
||||
"ktx",
|
||||
"nlohmann-json",
|
||||
"fmt",
|
||||
"gtest",
|
||||
"vulkan-memory-allocator",
|
||||
"lunasvg",
|
||||
"harfbuzz",
|
||||
"shader-slang",
|
||||
"metis",
|
||||
"meshoptimizer"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user