diff --git a/CMakeLists.txt b/CMakeLists.txt index 0db10d3..a0b01fb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,8 @@ cmake_minimum_required(VERSION 3.0) project(daydream) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/deps/include") - if(MINGW) set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/deps/lib/mingw/x64") elseif(MSVC) @@ -25,6 +23,18 @@ endif() set(BUILD_SHARED_LIBS FALSE) include_directories(${PROJECT_SOURCE_DIR}/include) +option(BUILD_RENDERER_OPENGL "Build with OpenGL 4.4 renderer" ON) +option(BUILD_RENDERER_DIRECTX "Build with DirectX 11 renderer" OFF) +# Compiling for OpenGL target +if(BUILD_RENDERER_OPENGL) + include_directories(${PROJECT_SOURCE_DIR}/include/Rendering/OpenGL) +endif() +# Compiling for DirectX target +if(BUILD_RENDERER_DIRECTX) + add_definitions(-DBUILD_RENDERER_DIRECTX) + include_directories(${PROJECT_SOURCE_DIR}/include/Rendering/DirectX) +endif() + #set(GLEW_INCLUDE_DIR ${daydream_SOURCE_DIR}/libs/glew-1.11.0/include) #set(GLEW_LIBRARY ${daydream_SOURCE_DIR}/libs/glew-1.11.0/lib/Release/glew32.lib) diff --git a/assets/Models/Submarine.mtl b/assets/Models/Submarine.mtl deleted file mode 100644 index 211bb03..0000000 --- a/assets/Models/Submarine.mtl +++ /dev/null @@ -1,12 +0,0 @@ -# Blender MTL File: 'submarine.blend' -# Material Count: 1 - -newmtl Material -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd SubmarineTexture.png diff --git a/assets/Models/Submarine.obj b/assets/Models/Submarine.obj deleted file mode 100755 index 14569fc..0000000 --- a/assets/Models/Submarine.obj +++ /dev/null @@ -1,1881 +0,0 @@ -# Blender v2.75 (sub 0) OBJ File: 'submarine.blend' -# www.blender.org -mtllib Submarine.mtl -o Cube -v -0.378953 -0.002680 -0.065172 -v 0.212611 0.044805 -0.044067 -v -0.378243 -0.049219 -0.040454 -v 0.511655 0.005655 -0.004951 -v 0.511655 0.014323 -0.009928 -v -0.378953 0.044805 -0.045251 -v 0.511655 0.021628 -0.004951 -v 0.296392 0.051346 -0.039065 -v 0.296392 -0.051355 -0.038417 -v 0.212611 -0.058696 -0.039270 -v 0.212611 -0.002680 -0.063988 -v 0.296392 -0.004712 -0.055556 -v -0.470020 0.007247 -0.055901 -v -0.470020 -0.033863 -0.039615 -v -0.470020 0.046066 -0.039615 -v -0.504866 0.007576 -0.027580 -v -0.504866 -0.015092 -0.019565 -v -0.504866 0.026681 -0.019565 -v 0.417794 0.035928 -0.027732 -v 0.417862 0.010074 -0.038703 -v 0.418042 -0.020280 -0.027718 -v -0.103707 0.044805 -0.044659 -v -0.095180 -0.059866 -0.039862 -v -0.145284 0.044805 -0.044778 -v -0.103707 -0.002680 -0.064580 -v -0.220059 -0.056313 -0.040098 -v -0.213663 0.044805 -0.044896 -v -0.213663 -0.002680 -0.064817 -v 0.016182 0.044805 -0.044401 -v 0.016182 -0.002680 -0.064322 -v 0.021156 -0.057734 -0.039604 -v -0.103679 -0.128289 -0.020932 -v -0.169800 -0.124081 -0.021745 -v -0.145284 -0.002680 -0.064699 -v -0.144573 -0.059156 -0.039980 -v -0.145256 -0.128299 -0.021050 -v -0.028130 -0.059156 -0.039733 -v -0.025998 0.044805 -0.044530 -v -0.025998 -0.002680 -0.064451 -v -0.028811 -0.126038 -0.021380 -v -0.101004 -0.090373 -0.028531 -v 0.004471 -0.088964 -0.032639 -v -0.179611 -0.092300 -0.029335 -v -0.147840 -0.092530 -0.029340 -v -0.011421 -0.110450 -0.026194 -v 0.438535 -0.016511 -0.025733 -v 0.439229 0.012885 -0.036411 -v 0.438680 0.033157 -0.025848 -v 0.488551 0.025074 -0.012937 -v 0.497469 0.013062 -0.015893 -v 0.493078 -0.000808 -0.010559 -v 0.457621 -0.052215 -0.000328 -v 0.486007 -0.049835 -0.001062 -v 0.489135 -0.011286 -0.003540 -v 0.449628 -0.021564 -0.002397 -v 0.452490 0.010420 -0.032017 -v 0.450888 0.012577 -0.032017 -v 0.452490 0.014448 -0.032017 -v 0.491993 0.014448 -0.019989 -v 0.493187 0.012577 -0.019989 -v 0.491993 0.010420 -0.019989 -v 0.463244 0.010420 -0.061607 -v 0.461409 0.012577 -0.061607 -v 0.463244 0.014448 -0.061607 -v 0.488480 0.014448 -0.059057 -v 0.489673 0.012577 -0.059057 -v 0.488480 0.010420 -0.059057 -v 0.450386 0.041229 -0.002309 -v 0.486995 0.039392 -0.003342 -v 0.457584 0.071526 -0.000278 -v 0.486002 0.068886 -0.001063 -v 0.372582 0.047066 -0.030989 -v 0.372582 0.004185 -0.046120 -v 0.372582 -0.034449 -0.032051 -v 0.511655 0.005655 -0.004951 -v 0.511655 0.014323 -0.009928 -v 0.511655 0.021628 -0.004951 -v 0.525395 0.008758 -0.002746 -v 0.515740 0.008758 -0.002746 -v 0.515740 0.011890 -0.004273 -v 0.515740 0.014988 -0.002825 -v 0.525395 0.011890 -0.004273 -v 0.525395 0.014988 -0.002825 -v -0.050480 -0.059392 -0.039776 -v -0.072830 -0.059629 -0.039819 -v -0.051873 -0.128594 -0.021423 -v -0.077776 -0.128594 -0.021466 -v -0.077804 0.044805 -0.044616 -v -0.051901 0.044805 -0.044573 -v -0.077804 -0.002680 -0.064537 -v -0.051901 -0.002680 -0.064494 -v -0.041517 -0.093350 -0.026237 -v -0.071378 -0.088718 -0.026280 -v -0.120025 -0.131743 -0.012698 -v -0.089441 -0.131743 -0.012647 -v -0.104733 -0.131743 -0.012672 -v -0.110237 -0.131352 -0.005504 -v -0.104733 -0.131352 -0.007784 -v -0.099229 -0.131352 -0.005504 -v -0.110237 -0.146402 -0.005504 -v -0.104733 -0.146402 -0.007784 -v -0.099229 -0.146402 -0.005504 -v -0.110237 -0.309639 -0.005504 -v -0.104733 -0.309639 -0.007784 -v -0.099229 -0.309639 -0.005504 -v -0.145706 -0.318985 -0.005504 -v -0.145706 -0.324489 -0.007784 -v -0.145706 -0.329993 -0.005504 -v -0.115907 -0.329993 -0.005504 -v -0.115907 -0.324489 -0.007784 -v -0.115907 -0.318985 -0.005504 -v -0.103586 -0.323872 -0.005504 -v -0.107478 -0.319980 -0.007784 -v -0.111369 -0.316088 -0.005504 -v -0.145706 -0.319804 -0.004685 -v -0.145706 -0.324489 -0.006626 -v -0.145706 -0.329175 -0.004685 -v -0.120728 -0.328489 -0.004000 -v -0.120728 -0.324489 -0.005656 -v -0.120728 -0.320490 -0.004000 -v -0.102383 -0.109911 -0.026878 -v -0.146509 -0.110962 -0.026891 -v -0.018918 -0.119800 -0.023713 -v -0.176358 -0.112152 -0.025424 -v -0.074675 -0.109265 -0.023799 -v -0.046854 -0.111511 -0.023756 -v -0.106319 -0.101496 -0.028531 -v -0.141797 -0.100168 -0.029340 -v -0.107087 -0.103696 -0.026878 -v -0.140874 -0.104992 -0.026891 -v -0.179464 -0.101651 -0.027380 -v -0.101694 -0.100142 -0.027239 -v -0.147175 -0.101746 -0.028115 -v -0.015169 -0.115125 -0.024953 -v -0.073027 -0.098992 -0.025039 -v -0.044185 -0.102430 -0.024996 -v -0.105455 -0.102694 -0.027239 -v -0.143547 -0.102580 -0.028115 -v -0.106319 -0.101496 -0.062227 -v -0.125329 -0.100168 -0.062227 -v -0.107087 -0.103696 -0.062227 -v -0.124406 -0.104992 -0.062227 -v -0.105455 -0.102694 -0.062227 -v -0.127079 -0.102580 -0.062227 -v -0.107364 -0.101496 -0.065167 -v -0.121148 -0.100168 -0.065167 -v -0.108133 -0.103696 -0.065167 -v -0.120226 -0.104992 -0.065167 -v -0.106501 -0.102694 -0.065167 -v -0.122898 -0.102580 -0.065167 -v 0.012813 -0.073349 -0.036122 -v -0.196426 -0.071466 -0.034717 -v -0.098092 -0.075120 -0.034196 -v -0.146207 -0.075843 -0.034660 -v -0.019775 -0.084803 -0.032963 -v -0.072104 -0.074173 -0.033049 -v -0.045998 -0.076371 -0.033006 -v -0.424131 -0.046842 -0.040035 -v -0.424487 0.002283 -0.060537 -v -0.424487 0.045435 -0.042433 -v -0.378953 -0.002680 0.065172 -v 0.212611 0.044805 0.044067 -v -0.378243 -0.049219 0.040454 -v 0.511655 0.005655 0.004951 -v 0.511655 0.014323 0.009928 -v -0.378953 0.044805 0.045251 -v 0.511655 0.021628 0.004951 -v 0.296392 0.051346 0.039065 -v 0.296392 -0.051355 0.038417 -v 0.212611 -0.058696 0.039270 -v 0.212611 -0.002680 0.063988 -v 0.296392 -0.004712 0.055556 -v -0.470020 0.007247 0.055901 -v -0.470020 -0.033863 0.039615 -v -0.470020 0.046066 0.039615 -v -0.504866 0.007576 0.027580 -v -0.504866 -0.015092 0.019565 -v -0.504866 0.026681 0.019565 -v 0.417794 0.035928 0.027732 -v 0.417862 0.010074 0.038703 -v 0.418042 -0.020280 0.027718 -v -0.103707 0.044805 0.044659 -v -0.095180 -0.059866 0.039862 -v -0.145284 0.044805 0.044778 -v -0.103707 -0.002680 0.064580 -v -0.220059 -0.056313 0.040098 -v -0.213663 0.044805 0.044896 -v -0.213663 -0.002680 0.064817 -v 0.016182 0.044805 0.044401 -v 0.016182 -0.002680 0.064322 -v 0.021156 -0.057734 0.039604 -v -0.103679 -0.128289 0.020933 -v -0.169800 -0.124081 0.021746 -v -0.145284 -0.002680 0.064699 -v -0.144573 -0.059156 0.039980 -v -0.145256 -0.128299 0.021050 -v -0.028130 -0.059156 0.039733 -v -0.025998 0.044805 0.044530 -v -0.025998 -0.002680 0.064451 -v -0.028811 -0.126038 0.021380 -v -0.101004 -0.090373 0.028531 -v 0.004471 -0.088964 0.032639 -v -0.179611 -0.092300 0.029335 -v -0.147840 -0.092530 0.029340 -v -0.011421 -0.110450 0.026194 -v 0.438535 -0.016511 0.025733 -v 0.439229 0.012885 0.036411 -v 0.438680 0.033157 0.025848 -v 0.488551 0.025074 0.012937 -v 0.497469 0.013062 0.015893 -v 0.493078 -0.000808 0.010559 -v 0.457621 -0.052215 0.000328 -v 0.486007 -0.049835 0.001062 -v 0.489135 -0.011286 0.003540 -v 0.449628 -0.021564 0.002397 -v 0.452490 0.010420 0.032017 -v 0.450888 0.012577 0.032017 -v 0.452490 0.014448 0.032017 -v 0.491993 0.014448 0.019989 -v 0.493187 0.012577 0.019989 -v 0.491993 0.010420 0.019989 -v 0.463244 0.010420 0.061607 -v 0.461409 0.012577 0.061607 -v 0.463244 0.014448 0.061607 -v 0.488480 0.014448 0.059057 -v 0.489673 0.012577 0.059057 -v 0.488480 0.010420 0.059057 -v 0.450386 0.041229 0.002309 -v 0.486995 0.039392 0.003342 -v 0.457584 0.071526 0.000278 -v 0.486002 0.068886 0.001063 -v 0.372582 0.047066 0.030989 -v 0.372582 0.004185 0.046120 -v 0.372582 -0.034449 0.032051 -v 0.511655 0.005655 0.004951 -v 0.511655 0.014323 0.009928 -v 0.511655 0.021628 0.004951 -v 0.525395 0.008758 0.002746 -v 0.515740 0.008758 0.002746 -v 0.515740 0.011890 0.004273 -v 0.515740 0.014988 0.002825 -v 0.525395 0.011890 0.004273 -v 0.525395 0.014988 0.002825 -v -0.050480 -0.059392 0.039776 -v -0.072830 -0.059629 0.039819 -v -0.051873 -0.128594 0.021423 -v -0.077776 -0.128594 0.021466 -v -0.077804 0.044805 0.044616 -v -0.051901 0.044805 0.044573 -v -0.077804 -0.002680 0.064537 -v -0.051901 -0.002680 0.064494 -v -0.041517 -0.093350 0.026237 -v -0.071378 -0.088718 0.026280 -v 0.296392 0.072896 -0.000000 -v 0.212611 0.073334 -0.000000 -v -0.378243 -0.071446 0.000000 -v 0.212611 -0.072397 0.000000 -v 0.296392 -0.066926 0.000000 -v -0.378953 0.073334 -0.000000 -v 0.510470 0.002703 -0.000000 -v 0.510470 0.026017 -0.000000 -v -0.470020 -0.049546 0.000000 -v -0.470020 0.069389 -0.000000 -v -0.503090 -0.022810 0.000000 -v -0.503090 0.038159 0.000000 -v -0.513891 0.007675 0.000000 -v 0.415462 -0.032528 -0.000000 -v 0.414729 0.050184 -0.000000 -v -0.103707 0.073334 -0.000000 -v -0.221664 -0.076517 0.000000 -v -0.213663 0.073334 -0.000000 -v 0.016182 0.073334 -0.000000 -v 0.024709 -0.072856 0.000000 -v -0.169800 -0.129750 0.000000 -v 0.438241 0.045372 -0.000000 -v -0.010750 -0.113834 0.000000 -v -0.145284 0.073334 -0.000000 -v -0.145256 -0.134263 0.000000 -v -0.025998 0.073334 -0.000000 -v -0.028811 -0.131707 0.000000 -v 0.004471 -0.093705 0.000000 -v -0.192182 -0.098774 0.000000 -v 0.438373 -0.025623 -0.000000 -v 0.489175 0.028118 -0.000000 -v 0.493179 -0.005666 -0.000000 -v 0.457343 -0.052215 0.000000 -v 0.487158 -0.049835 0.000000 -v 0.447422 -0.024231 -0.000000 -v 0.489644 -0.010979 -0.000000 -v 0.446970 0.041229 -0.000000 -v 0.488729 0.039392 -0.000000 -v 0.457414 0.071526 -0.000000 -v 0.487056 0.068886 -0.000000 -v 0.372582 0.058885 -0.000000 -v 0.372582 -0.048949 0.000000 -v 0.510470 0.002703 -0.000000 -v 0.510470 0.026017 -0.000000 -v 0.515740 0.008758 -0.000000 -v 0.515225 0.008032 -0.000000 -v 0.515740 0.014988 -0.000000 -v 0.515225 0.015781 -0.000000 -v 0.524880 0.008032 -0.000000 -v 0.524880 0.015781 -0.000000 -v 0.527347 0.011810 -0.000000 -v -0.077804 0.073334 -0.000000 -v -0.051901 0.073334 -0.000000 -v -0.051873 -0.134263 0.000000 -v -0.120025 -0.131743 0.012698 -v -0.089441 -0.131743 0.012647 -v -0.104733 -0.131743 0.012672 -v -0.120025 -0.134116 0.000000 -v -0.089441 -0.134116 0.000000 -v -0.096949 -0.133905 0.000000 -v -0.112517 -0.133905 0.000000 -v -0.110237 -0.131352 0.005504 -v -0.104733 -0.131352 0.007784 -v -0.099229 -0.131352 0.005504 -v -0.096949 -0.146402 0.000000 -v -0.112517 -0.146402 0.000000 -v -0.110237 -0.146402 0.005504 -v -0.104733 -0.146402 0.007784 -v -0.099229 -0.146402 0.005504 -v -0.096949 -0.309639 0.000000 -v -0.112517 -0.309639 0.000000 -v -0.110237 -0.309639 0.005504 -v -0.104733 -0.309639 0.007784 -v -0.099229 -0.309639 0.005504 -v -0.145706 -0.318985 0.005504 -v -0.145706 -0.324489 0.007784 -v -0.145706 -0.329993 0.005504 -v -0.145706 -0.332273 0.000000 -v -0.145706 -0.316706 0.000000 -v -0.115907 -0.316706 0.000000 -v -0.115907 -0.332273 0.000000 -v -0.115907 -0.329993 0.005504 -v -0.115907 -0.324489 0.007784 -v -0.115907 -0.318985 0.005504 -v -0.112981 -0.314476 0.000000 -v -0.101974 -0.325484 0.000000 -v -0.103586 -0.323872 0.005504 -v -0.107478 -0.319980 0.007784 -v -0.111369 -0.316088 0.005504 -v -0.077776 -0.133292 0.000000 -v -0.145706 -0.319804 0.004685 -v -0.145706 -0.324489 0.006626 -v -0.145706 -0.329175 0.004685 -v -0.145706 -0.331115 0.000000 -v -0.145706 -0.317863 0.000000 -v -0.120728 -0.330146 0.000000 -v -0.120728 -0.328489 0.004000 -v -0.120728 -0.324489 0.005656 -v -0.120728 -0.320490 0.004000 -v -0.120728 -0.318833 0.000000 -v -0.120728 -0.324489 0.000000 -v -0.102383 -0.109911 0.026878 -v -0.018593 -0.124361 0.000000 -v -0.146509 -0.110962 0.026891 -v -0.018918 -0.119800 0.023713 -v -0.176358 -0.112152 0.025424 -v -0.182451 -0.118212 0.000000 -v -0.074675 -0.109265 0.023799 -v -0.046854 -0.111511 0.023756 -v -0.106319 -0.101496 0.028531 -v -0.141797 -0.100168 0.029340 -v -0.107087 -0.103696 0.026878 -v -0.140874 -0.104992 0.026891 -v -0.014671 -0.119098 0.000000 -v -0.179464 -0.101651 0.027380 -v -0.187317 -0.109068 0.000000 -v -0.101694 -0.100142 0.027239 -v -0.147175 -0.101746 0.028116 -v -0.015169 -0.115125 0.024953 -v -0.073027 -0.098992 0.025039 -v -0.044185 -0.102430 0.024996 -v -0.105455 -0.102694 0.027239 -v -0.143547 -0.102580 0.028116 -v -0.106319 -0.101496 0.062227 -v -0.125329 -0.100168 0.062227 -v -0.107087 -0.103696 0.062227 -v -0.124406 -0.104992 0.062227 -v -0.105455 -0.102694 0.062227 -v -0.127079 -0.102580 0.062227 -v -0.107364 -0.101496 0.065167 -v -0.121148 -0.100168 0.065167 -v -0.108133 -0.103696 0.065167 -v -0.120226 -0.104992 0.065167 -v -0.106501 -0.102694 0.065167 -v -0.122898 -0.102580 0.065167 -v 0.012813 -0.073349 0.036122 -v -0.196426 -0.071466 0.034717 -v -0.203515 -0.084806 0.000000 -v -0.098092 -0.075120 0.034196 -v 0.014590 -0.083280 0.000000 -v -0.146207 -0.075843 0.034660 -v -0.019775 -0.084803 0.032963 -v -0.072104 -0.074173 0.033049 -v -0.045998 -0.076371 0.033006 -v -0.424131 -0.065797 0.000000 -v -0.424131 -0.046842 0.040035 -v -0.424487 0.002283 0.060537 -v -0.424487 0.045435 0.042433 -v -0.424487 0.071361 -0.000000 -vt 0.956699 0.719683 -vt 0.973082 0.719310 -vt 0.974494 0.728254 -vt 0.949748 0.704509 -vt 0.974991 0.711418 -vt 0.958181 0.693076 -vt 0.977042 0.704159 -vt 0.907825 0.773992 -vt 0.887056 0.783358 -vt 0.880780 0.755188 -vt 0.286455 0.752799 -vt 0.137715 0.743003 -vt 0.138655 0.698133 -vt 0.694869 0.800055 -vt 0.769701 0.787194 -vt 0.776890 0.824753 -vt 0.277870 0.810293 -vt 0.267395 0.851549 -vt 0.123009 0.829069 -vt 0.688444 0.648397 -vt 0.767177 0.648892 -vt 0.765769 0.689809 -vt 0.288114 0.704141 -vt 0.135808 0.648392 -vt 0.689264 0.697552 -vt 0.766204 0.742566 -vt 0.131898 0.789275 -vt 0.690402 0.744884 -vt 0.097617 0.777222 -vt 0.084045 0.812811 -vt 0.045082 0.796553 -vt 0.103543 0.736881 -vt 0.063335 0.765169 -vt 0.101905 0.699179 -vt 0.069372 0.730760 -vt 0.093869 0.656193 -vt 0.065156 0.700224 -vt 0.037224 0.728794 -vt 0.032491 0.746804 -vt 0.033494 0.713118 -vt 0.021201 0.695908 -vt 0.017826 0.760292 -vt 0.010998 0.727527 -vt 0.977171 0.704193 -vt 0.975703 0.734427 -vt 0.974615 0.728233 -vt 0.838588 0.769634 -vt 0.835263 0.690651 -vt 0.839009 0.659916 -vt 0.879313 0.668961 -vt 0.835369 0.732184 -vt 0.877743 0.698691 -vt 0.877323 0.725104 -vt 0.415659 0.754567 -vt 0.419670 0.813267 -vt 0.398655 0.813246 -vt 0.415931 0.705907 -vt 0.391538 0.705777 -vt 0.391906 0.656135 -vt 0.391122 0.754382 -vt 0.351927 0.812827 -vt 0.352421 0.705403 -vt 0.289522 0.654422 -vt 0.468309 0.867106 -vt 0.471717 0.863299 -vt 0.483180 0.882615 -vt 0.351716 0.754025 -vt 0.505857 0.754851 -vt 0.504829 0.705273 -vt 0.699604 0.838311 -vt 0.522669 0.854806 -vt 0.503774 0.655536 -vt 0.511306 0.814964 -vt 0.352497 0.879550 -vt 0.351096 0.899092 -vt 0.324099 0.895900 -vt 0.308155 0.883658 -vt 0.323932 0.864809 -vt 0.329413 0.877829 -vt 0.493037 0.837225 -vt 0.500877 0.868485 -vt 0.353163 0.655720 -vt 0.351389 0.862551 -vt 0.442095 0.863398 -vt 0.464902 0.870842 -vt 0.458778 0.877530 -vt 0.897456 0.701066 -vt 0.896868 0.721761 -vt 0.465002 0.754877 -vt 0.464844 0.705847 -vt 0.464449 0.656145 -vt 0.462247 0.814277 -vt 0.466982 0.838788 -vt 0.447123 0.847503 -vt 0.350750 0.829156 -vt 0.349573 0.845485 -vt 0.317535 0.847624 -vt 0.502172 0.826094 -vt 0.280974 0.860490 -vt 0.297702 0.828959 -vt 0.511773 0.861646 -vt 0.395896 0.828442 -vt 0.393138 0.843639 -vt 0.922858 0.260577 -vt 0.925930 0.259385 -vt 0.935654 0.293772 -vt 0.901593 0.674617 -vt 0.899437 0.749902 -vt 0.960525 0.746115 -vt 0.954794 0.735768 -vt 0.912682 0.680414 -vt 0.950788 0.720117 -vt 0.949700 0.718292 -vt 0.909608 0.719599 -vt 0.918396 0.308253 -vt 0.918484 0.307670 -vt 0.934245 0.293888 -vt 0.890558 0.291134 -vt 0.890558 0.296112 -vt 0.917233 0.766853 -vt 0.953478 0.749118 -vt 0.956504 0.750947 -vt 0.708158 0.132508 -vt 0.704332 0.132234 -vt 0.716412 0.089060 -vt 0.773619 0.132508 -vt 0.746105 0.089377 -vt 0.748250 0.086560 -vt 0.909786 0.723528 -vt 0.908195 0.721502 -vt 0.949739 0.722183 -vt 0.782891 0.117603 -vt 0.808955 0.119545 -vt 0.810904 0.121963 -vt 0.719849 0.091084 -vt 0.835681 0.076855 -vt 0.838224 0.078280 -vt 0.771670 0.076855 -vt 0.779742 0.119304 -vt 0.947052 0.231319 -vt 0.942942 0.232366 -vt 0.937691 0.203709 -vt 0.910529 0.677094 -vt 0.948600 0.686253 -vt 0.915767 0.202873 -vt 0.938912 0.202873 -vt 0.902311 0.229152 -vt 0.916150 0.203292 -vt 0.898615 0.227897 -vt 0.847021 0.801607 -vt 0.973236 0.719313 -vt 0.980624 0.721996 -vt 0.975133 0.711453 -vt 0.981902 0.717750 -vt 0.983569 0.714759 -vt 0.992567 0.719520 -vt 0.980571 0.726412 -vt 0.989793 0.725888 -vt 0.990587 0.728388 -vt 0.981204 0.729516 -vt 0.993796 0.724584 -vt 0.989802 0.723612 -vt 0.990759 0.721624 -vt 0.420067 0.828054 -vt 0.420464 0.842841 -vt 0.443942 0.830522 -vt 0.391734 0.861782 -vt 0.417316 0.861560 -vt 0.414702 0.879465 -vt 0.438011 0.878742 -vt 0.463775 0.895049 -vt 0.439829 0.898990 -vt 0.440295 0.754740 -vt 0.440364 0.705938 -vt 0.440263 0.656268 -vt 0.416082 0.656257 -vt 0.440761 0.813541 -vt 0.403951 0.888257 -vt 0.415290 0.900009 -vt 0.390625 0.879851 -vt 0.374799 0.900133 -vt 0.375264 0.888040 -vt 0.384354 0.894908 -vt 0.389584 0.888211 -vt 0.389551 0.892816 -vt 0.394721 0.894985 -vt 0.404220 0.900399 -vt 0.397123 0.900623 -vt 0.201431 0.018740 -vt 0.204459 0.032820 -vt 0.198901 0.034006 -vt 0.185297 0.024764 -vt 0.190322 0.021174 -vt 0.193388 0.035191 -vt 0.207523 0.019904 -vt 0.210089 0.031604 -vt 0.195868 0.019959 -vt 0.242781 0.183629 -vt 0.237075 0.184535 -vt 0.231698 0.186019 -vt 0.226252 0.187508 -vt 0.220586 0.188371 -vt 0.227975 0.203945 -vt 0.232410 0.196081 -vt 0.237446 0.197744 -vt 0.231540 0.208340 -vt 0.242781 0.199409 -vt 0.213511 0.225097 -vt 0.210377 0.221512 -vt 0.235589 0.212241 -vt 0.215991 0.229265 -vt 0.219927 0.195976 -vt 0.221003 0.192874 -vt 0.226787 0.194301 -vt 0.206719 0.218153 -vt 0.224298 0.199339 -vt 0.202150 0.215354 -vt 0.206074 0.218974 -vt 0.209672 0.222170 -vt 0.215115 0.229392 -vt 0.212790 0.225598 -vt 0.140139 0.057135 -vt 0.157845 0.057141 -vt 0.152655 0.069659 -vt 0.198295 0.243393 -vt 0.152664 0.044619 -vt 0.195828 0.240517 -vt 0.193472 0.238001 -vt 0.190979 0.235622 -vt 0.188364 0.233395 -vt 0.874095 0.050219 -vt 0.875908 0.043938 -vt 0.878762 0.051906 -vt 0.418842 0.852187 -vt 0.444506 0.855530 -vt 0.392448 0.852757 -vt 0.350516 0.854102 -vt 0.301302 0.876545 -vt 0.320771 0.856514 -vt 0.473809 0.889187 -vt 0.920749 0.053099 -vt 0.907153 0.084830 -vt 0.895681 0.081984 -vt 0.922440 0.043939 -vt 0.958282 0.098639 -vt 0.954459 0.092451 -vt 0.956155 0.091536 -vt 0.913736 0.098639 -vt 0.918947 0.092696 -vt 0.923698 0.049927 -vt 0.922612 0.052967 -vt 0.915945 0.090531 -vt 0.933466 0.059802 -vt 0.294553 0.869430 -vt 0.912536 0.090359 -vt 0.478530 0.885930 -vt 0.936616 0.060625 -vt 0.937370 0.056797 -vt 0.908205 0.085437 -vt 0.906287 0.087309 -vt 0.949638 0.059539 -vt 0.893472 0.082637 -vt 0.896349 0.085428 -vt 0.898089 0.084370 -vt 0.905592 0.086379 -vt 0.948228 0.057363 -vt 0.939888 0.058329 -vt 0.949667 0.056538 -vt 0.051929 0.663994 -vt 0.975810 0.734403 -vt 0.916076 0.770760 -vt 0.951627 0.684121 -vt 0.381864 0.900481 -vt 0.187840 0.036396 -vt 0.201962 0.216530 -vt 0.875817 0.052307 -vt 0.951387 0.059099 -vt 0.776477 0.130857 -vt 0.768235 0.077013 -vt 0.140133 0.074841 -vt 0.140145 0.039428 -vt 0.960070 0.090264 -vn 0.551200 0.039400 -0.833400 -vn 0.950700 0.181400 0.251500 -vn 0.478000 -0.752000 0.453900 -vn 0.367000 0.671900 -0.643200 -vn 0.274600 0.846900 0.455200 -vn 0.766600 0.642000 0.000000 -vn 0.064600 0.655500 0.752400 -vn 0.258500 -0.966000 0.000000 -vn 0.318600 -0.947900 0.000000 -vn 0.240900 -0.665100 -0.706800 -vn -0.000700 -0.014900 -0.999900 -vn -0.042200 -0.043000 -0.998200 -vn -0.018500 0.642400 -0.766100 -vn 0.030900 -0.736000 -0.676200 -vn 0.141900 -0.694100 -0.705700 -vn 0.154300 -0.988000 0.000000 -vn -0.095700 -0.641800 -0.760800 -vn -0.248600 -0.968600 0.000000 -vn -0.080900 -0.996700 0.000000 -vn -0.012600 0.999900 0.000000 -vn 0.091000 0.995800 0.000000 -vn 0.069900 0.636500 -0.768100 -vn 0.001200 0.645100 -0.764100 -vn -0.016700 0.999800 0.000000 -vn 0.013600 0.626200 -0.779500 -vn 0.102100 -0.035900 -0.994100 -vn -0.044300 -0.706400 -0.706400 -vn 0.043600 -0.001400 -0.999000 -vn -0.145300 -0.709100 -0.689900 -vn -0.206500 -0.978400 0.000000 -vn -0.457000 -0.889400 0.000000 -vn -0.098200 0.004400 -0.995100 -vn -0.403100 -0.630100 -0.663600 -vn -0.040000 0.649700 -0.759100 -vn -0.355300 0.025400 -0.934400 -vn -0.038500 0.999200 0.000000 -vn -0.335300 0.626100 -0.704000 -vn -0.793800 0.020200 -0.607900 -vn -0.795500 -0.449000 -0.406800 -vn -0.797000 0.417400 -0.436500 -vn -0.788900 0.614500 0.000000 -vn -0.771500 -0.636200 0.000000 -vn -0.999900 0.011200 0.000000 -vn 0.424100 0.197000 0.883900 -vn 0.333300 -0.680300 0.652700 -vn 0.619300 -0.491800 0.612000 -vn 0.243400 -0.662900 -0.708000 -vn 0.154900 0.697800 -0.699300 -vn 0.161400 0.986900 0.000000 -vn 0.225000 0.974300 0.000000 -vn 0.154600 -0.005400 -0.987900 -vn 0.166500 0.672400 -0.721200 -vn 0.132100 0.028700 -0.990800 -vn 0.001900 -0.005700 -1.000000 -vn 0.005800 -0.410100 -0.912000 -vn 0.010400 -0.381400 -0.924300 -vn 0.001200 0.643900 -0.765100 -vn 0.001500 0.644200 -0.764800 -vn 0.000200 1.000000 0.000000 -vn 0.001500 -0.006100 -1.000000 -vn -0.004400 -0.358000 -0.933700 -vn 0.001600 0.644500 -0.764500 -vn 0.000300 1.000000 0.000000 -vn 0.444900 -0.536900 -0.716800 -vn 0.453900 -0.563800 -0.690000 -vn 0.797300 -0.603500 0.000000 -vn 0.002300 -0.007600 -0.999900 -vn 0.003800 -0.010800 -0.999900 -vn 0.001600 0.643200 -0.765600 -vn 0.033600 -0.999400 0.000000 -vn 0.435300 -0.900300 0.000000 -vn 0.000400 1.000000 0.000000 -vn 0.157500 -0.582400 -0.797500 -vn -0.065100 -0.732800 -0.677300 -vn -0.103200 -0.994600 0.000000 -vn -0.423100 -0.906000 0.000000 -vn -0.811000 -0.585000 0.000000 -vn -0.528100 -0.388400 -0.755100 -vn -0.377800 -0.687000 -0.620700 -vn 0.508300 -0.510500 -0.693500 -vn 0.759900 -0.650000 0.000000 -vn -0.002900 -0.215900 -0.976400 -vn -0.015900 -0.138400 -0.990200 -vn 0.402800 -0.612300 -0.680300 -vn 0.204100 -0.722500 -0.660500 -vn 0.210700 0.706700 -0.675400 -vn 0.192100 0.068700 -0.978900 -vn 0.002300 -0.007700 -0.999900 -vn 0.001700 0.643500 -0.765400 -vn -0.011000 -0.346500 -0.938000 -vn -0.076300 -0.285500 -0.955300 -vn -0.081100 -0.263600 -0.961200 -vn 0.001800 -0.303300 -0.952900 -vn -0.013700 -0.201500 -0.979400 -vn -0.394000 -0.364600 -0.843700 -vn 0.501500 -0.456800 -0.734700 -vn -0.604900 -0.796200 0.000000 -vn -0.275900 -0.577100 -0.768600 -vn 0.743800 -0.668400 0.000000 -vn 0.037600 -0.357100 -0.933300 -vn 0.070100 -0.224100 -0.972000 -vn 0.640400 -0.441500 -0.628400 -vn 0.940400 -0.340000 0.000000 -vn 0.796300 -0.604800 0.000000 -vn 0.301100 0.953600 0.000000 -vn 0.261800 -0.681400 -0.683400 -vn 0.721400 -0.692500 0.000000 -vn 0.420600 -0.637800 -0.645100 -vn -0.150900 0.650100 -0.744700 -vn 0.873700 0.014200 -0.486300 -vn 0.534800 0.700100 -0.473000 -vn -0.033600 0.716400 -0.696900 -vn -0.682100 -0.731200 0.000000 -vn -0.233300 -0.723400 -0.649700 -vn 0.286900 -0.622500 -0.728100 -vn 0.078600 -0.670900 -0.737400 -vn -0.427200 -0.904100 0.000000 -vn -0.021400 -0.660700 -0.750400 -vn -0.118800 0.000200 -0.992900 -vn -0.682600 0.029300 -0.730200 -vn 0.556800 -0.672800 -0.487000 -vn 0.412400 -0.699600 -0.583500 -vn 0.789700 0.025000 -0.612900 -vn -0.189600 0.676200 -0.711900 -vn 0.391100 0.710400 -0.585100 -vn -0.212000 -0.674900 -0.706800 -vn 0.998400 0.056000 0.000000 -vn 0.591500 0.244800 -0.768200 -vn 0.323400 0.606300 -0.726400 -vn -0.134800 0.990900 0.000000 -vn -0.682200 0.731100 0.000000 -vn 0.818200 0.574900 0.000000 -vn -0.295800 0.710100 -0.638900 -vn 0.297300 -0.954800 0.000000 -vn 0.668300 0.047000 0.742400 -vn 0.479600 -0.078300 -0.874000 -vn 0.697300 0.326500 0.638100 -vn 0.544300 0.656900 -0.521700 -vn 0.586300 0.810100 0.000000 -vn 0.412900 0.910700 0.000000 -vn 0.383600 -0.731600 -0.563600 -vn 0.496300 -0.690100 -0.526700 -vn 0.404600 -0.914500 0.000000 -vn 0.429300 -0.903100 0.000000 -vn 0.999900 -0.010500 0.000000 -vn 0.482200 -0.006100 -0.876000 -vn 0.501100 0.679900 -0.535300 -vn 0.009900 -0.410200 -0.911900 -vn 0.019500 -0.276200 -0.960900 -vn -0.056800 -0.368300 -0.927900 -vn 0.033000 -0.154300 -0.987500 -vn 0.046800 -0.123400 -0.991200 -vn 0.035700 -0.676900 -0.735200 -vn 0.029300 -0.675000 -0.737200 -vn 0.345600 -0.938400 0.000000 -vn 0.036000 -0.999300 0.000000 -vn 0.002200 -0.006800 -1.000000 -vn 0.001200 0.643800 -0.765200 -vn -0.000800 -0.391100 -0.920300 -vn 0.000600 -0.970800 -0.239800 -vn 0.035200 -0.999400 0.000000 -vn -0.005800 -0.680300 -0.732900 -vn 0.065700 -0.997800 0.000000 -vn 0.022600 -0.964400 -0.263300 -vn -0.310500 -0.819400 -0.481800 -vn 0.000300 -0.986300 -0.164700 -vn 0.000000 -0.833700 -0.552200 -vn 0.310600 -0.819400 -0.481800 -vn -0.027400 -0.999600 0.000000 -vn 0.708400 -0.705800 0.000000 -vn 0.707100 0.000000 -0.707100 -vn 0.000000 0.000000 -1.000000 -vn -0.708400 -0.705800 0.000000 -vn -0.707100 0.000000 -0.707100 -vn 1.000000 0.000000 0.000000 -vn 0.989500 -0.144100 0.000000 -vn 0.720100 -0.106400 -0.685600 -vn 0.027600 -0.011700 -0.999500 -vn -0.700800 0.053300 -0.711400 -vn -0.998800 0.048400 0.000000 -vn 0.026600 -0.056900 -0.998000 -vn 0.077600 -0.054200 -0.995500 -vn 0.573400 -0.484400 -0.660700 -vn 0.169300 -0.718400 -0.674700 -vn 0.754500 -0.656200 0.000000 -vn -0.630200 -0.549000 -0.549000 -vn -0.630200 0.000000 -0.776400 -vn 0.213600 -0.976900 0.000000 -vn -0.630200 -0.776400 0.000000 -vn -0.324100 0.946000 0.000000 -vn -0.876400 0.481600 0.000000 -vn -0.548000 0.361400 -0.754300 -vn -0.630200 0.549000 -0.549000 -vn -0.187000 0.650000 -0.736600 -vn -0.630200 0.776400 0.000000 -vn -0.814800 -0.409900 0.409900 -vn -0.814800 0.000000 0.579700 -vn -0.814800 0.579700 0.000000 -vn -0.814800 0.409900 0.409900 -vn -1.000000 0.000000 0.000000 -vn -0.644800 0.000000 0.764400 -vn -0.644800 0.540500 0.540500 -vn -0.644800 0.764400 0.000000 -vn -0.644800 -0.540500 0.540500 -vn -0.644800 -0.764400 0.000000 -vn -0.068200 -0.162600 -0.984300 -vn -0.362500 0.291100 -0.885300 -vn 0.035400 -0.126300 -0.991300 -vn -0.031500 -0.127900 -0.991300 -vn 0.167000 -0.134100 -0.976800 -vn -0.900300 -0.435100 0.000000 -vn -0.570800 -0.245100 -0.783600 -vn 0.681800 -0.731600 0.000000 -vn 0.535100 0.423900 -0.730800 -vn 0.519400 0.849600 -0.091400 -vn -0.386500 0.832800 -0.396300 -vn 0.124700 -0.623100 -0.772100 -vn 0.388300 -0.399500 -0.830400 -vn -0.098800 -0.532300 -0.840800 -vn -0.283300 -0.355800 -0.890500 -vn -0.796700 -0.099400 -0.596100 -vn -0.861300 -0.508000 0.000000 -vn 0.799100 -0.601200 0.000000 -vn -0.322400 -0.882300 -0.343000 -vn -0.413900 -0.075400 -0.907200 -vn 0.970600 -0.183300 -0.156000 -vn 0.698000 -0.169200 -0.695800 -vn 0.334100 -0.940700 -0.058700 -vn -0.097300 0.732200 -0.674100 -vn 0.311500 0.663800 -0.679900 -vn 0.200000 -0.689000 -0.696600 -vn -0.062100 -0.741600 -0.668000 -vn 0.223600 -0.351800 0.909000 -vn 0.192200 0.036700 0.980700 -vn 0.551200 0.039400 0.833400 -vn 0.120200 0.370700 0.920900 -vn 0.261800 -0.681400 0.683400 -vn 0.240900 -0.665100 0.706800 -vn -0.018500 0.642400 0.766100 -vn -0.042200 -0.043000 0.998200 -vn -0.000700 -0.014900 0.999900 -vn 0.141900 -0.694100 0.705700 -vn 0.030900 -0.736000 0.676200 -vn -0.095700 -0.641800 0.760800 -vn -0.044300 -0.706400 0.706400 -vn 0.069900 0.636500 0.768100 -vn 0.001200 0.645100 0.764100 -vn 0.102100 -0.035900 0.994100 -vn 0.013600 0.626200 0.779500 -vn 0.043600 -0.001400 0.999000 -vn -0.145300 -0.709100 0.689900 -vn -0.403100 -0.630100 0.663600 -vn -0.098200 0.004400 0.995100 -vn -0.355300 0.025400 0.934400 -vn -0.040000 0.649700 0.759100 -vn -0.335300 0.626100 0.704000 -vn -0.353900 0.935300 0.000000 -vn -0.797000 0.417400 0.436500 -vn -0.793800 0.020200 0.607900 -vn -0.795500 -0.449000 0.406800 -vn 0.538700 0.252200 0.803900 -vn 0.404600 -0.361000 0.840200 -vn 0.403300 -0.320300 0.857100 -vn 0.243400 -0.662900 0.708000 -vn 0.154900 0.697800 0.699300 -vn 0.166500 0.672400 0.721200 -vn 0.154600 -0.005400 0.987900 -vn 0.132100 0.028700 0.990800 -vn 0.001900 -0.005700 1.000000 -vn 0.001500 -0.006100 1.000000 -vn 0.010400 -0.381400 0.924300 -vn 0.001500 0.644200 0.764800 -vn 0.001200 0.643900 0.765100 -vn -0.004400 -0.358000 0.933700 -vn 0.001600 0.644500 0.764500 -vn 0.453900 -0.563800 0.690000 -vn 0.444900 -0.536900 0.716800 -vn 0.002300 -0.007600 0.999900 -vn 0.001600 0.643200 0.765600 -vn 0.003800 -0.010800 0.999900 -vn 0.157500 -0.582400 0.797500 -vn -0.065100 -0.732800 0.677300 -vn -0.377800 -0.687000 0.620700 -vn 0.508300 -0.510500 0.693500 -vn -0.002900 -0.215900 0.976400 -vn -0.015900 -0.138400 0.990200 -vn 0.029300 -0.675000 0.737200 -vn 0.204100 -0.722500 0.660500 -vn 0.192100 0.068700 0.978900 -vn 0.210700 0.706700 0.675400 -vn 0.001700 0.643500 0.765400 -vn 0.002300 -0.007700 0.999900 -vn -0.011000 -0.346500 0.938000 -vn -0.081100 -0.263600 0.961200 -vn -0.076300 -0.285500 0.955300 -vn -0.394000 -0.364600 0.843700 -vn -0.013700 -0.201500 0.979400 -vn 0.001800 -0.303300 0.952900 -vn 0.070100 -0.224100 0.972000 -vn 0.640400 -0.441500 0.628400 -vn 0.286900 -0.622500 0.728100 -vn 0.420600 -0.637800 0.645100 -vn 0.367000 0.671900 0.643200 -vn 0.591500 0.244800 0.768200 -vn -0.150900 0.650100 0.744700 -vn 0.534800 0.700100 0.473000 -vn 0.873700 0.014200 0.486300 -vn -0.118800 0.000200 0.992900 -vn -0.033600 0.716400 0.696900 -vn -0.233300 -0.723400 0.649700 -vn 0.078600 -0.670900 0.737400 -vn -0.021400 -0.660700 0.750400 -vn -0.212000 -0.674900 0.706800 -vn -0.682600 0.029300 0.730200 -vn 0.789700 0.025000 0.612900 -vn 0.412400 -0.699600 0.583500 -vn 0.556800 -0.672800 0.487000 -vn 0.391100 0.710400 0.585100 -vn -0.189600 0.676200 0.711900 -vn 0.323400 0.606300 0.726500 -vn -0.295800 0.710100 0.638900 -vn 0.383600 -0.731600 0.563600 -vn 0.479600 -0.078300 0.874000 -vn 0.363500 0.025600 0.931200 -vn 0.544300 0.656900 0.521700 -vn 0.501100 0.679900 0.535300 -vn 0.496300 -0.690100 0.526700 -vn 0.482200 -0.006100 0.876000 -vn 0.037600 -0.357100 0.933300 -vn 0.019500 -0.276200 0.960900 -vn -0.056800 -0.368300 0.927900 -vn 0.033000 -0.154300 0.987500 -vn -0.005800 -0.680300 0.732900 -vn 0.035700 -0.676900 0.735200 -vn 0.046800 -0.123400 0.991200 -vn 0.001200 0.643800 0.765200 -vn 0.002200 -0.006800 1.000000 -vn -0.000800 -0.391100 0.920300 -vn 0.005800 -0.410100 0.912000 -vn 0.000600 -0.970800 0.239800 -vn 0.000300 -0.986300 0.164700 -vn -0.310500 -0.819400 0.481800 -vn 0.000000 -0.833700 0.552200 -vn 0.310600 -0.819400 0.481800 -vn 0.000000 0.000000 1.000000 -vn 0.707100 0.000000 0.707100 -vn -0.707100 0.000000 0.707100 -vn 0.720100 -0.106400 0.685600 -vn -0.700800 0.053300 0.711400 -vn 0.027600 -0.011700 0.999500 -vn 0.573400 -0.484400 0.660700 -vn 0.077600 -0.054200 0.995500 -vn 0.026600 -0.056900 0.998000 -vn 0.169300 -0.718400 0.674700 -vn -0.630200 0.000000 0.776400 -vn -0.630200 -0.549000 0.549000 -vn -0.548000 0.361400 0.754300 -vn -0.630200 0.549000 0.549000 -vn -0.187000 0.650000 0.736600 -vn 0.022600 -0.964400 0.263300 -vn -0.814800 -0.579700 0.000000 -vn -0.814800 -0.409900 -0.409900 -vn -0.814800 0.000000 -0.579700 -vn -0.814800 0.409900 -0.409900 -vn -0.644800 0.540500 -0.540500 -vn -0.644800 0.000000 -0.764400 -vn -0.644800 -0.540500 -0.540500 -vn -0.068200 -0.162600 0.984300 -vn -0.283300 -0.355800 0.890500 -vn -0.362500 0.291100 0.885300 -vn 0.035400 -0.126300 0.991300 -vn 0.167000 -0.134100 0.976800 -vn -0.031500 -0.127900 0.991300 -vn 0.402800 -0.612300 0.680300 -vn -0.528100 -0.388400 0.755100 -vn -0.386500 0.832800 0.396300 -vn 0.519400 0.849600 0.091400 -vn 0.535100 0.423900 0.730800 -vn 0.388300 -0.399500 0.830400 -vn 0.124700 -0.623100 0.772100 -vn -0.098800 -0.532300 0.840800 -vn -0.322400 -0.882300 0.343000 -vn -0.796700 -0.099400 0.596100 -vn -0.570800 -0.245100 0.783600 -vn -0.062100 -0.741600 0.668000 -vn -0.413900 -0.075400 0.907200 -vn 0.311500 0.663800 0.679900 -vn 0.698000 -0.169200 0.695800 -vn 0.970600 -0.183300 0.156000 -vn 0.334100 -0.940700 0.058700 -vn -0.097300 0.732200 0.674100 -vn 0.200000 -0.689000 0.696600 -vn 0.009900 -0.410200 0.911900 -vn 0.501500 -0.456800 0.734700 -vn -0.275900 -0.577100 0.768600 -usemtl Material -s 1 -f 50/1/1 5/2/2 4/3/3 -f 50/1/1 49/4/4 7/5/5 -f 284/6/6 261/7/7 7/5/5 -f 283/8/8 267/9/9 21/10/10 -f 28/11/11 1/12/12 6/13/13 -f 10/14/14 9/15/15 258/16/16 -f 26/17/17 270/18/18 256/19/19 -f 255/20/20 254/21/21 8/22/22 -f 27/23/23 6/13/13 259/24/24 -f 2/25/25 8/22/22 12/26/26 -f 26/17/17 3/27/27 1/12/12 -f 11/28/28 12/26/26 9/15/15 -f 158/29/29 398/30/30 262/31/31 -f 159/32/32 158/29/29 14/33/33 -f 160/34/34 159/32/32 13/35/35 -f 402/36/36 160/34/34 15/37/37 -f 15/37/37 13/35/35 16/38/38 -f 13/35/35 14/33/33 17/39/39 -f 15/37/37 18/40/40 265/41/41 -f 14/33/33 262/31/31 264/42/42 -f 18/40/40 16/38/38 266/43/43 -f 17/39/39 264/42/42 266/43/43 -f 7/5/5 261/7/7 297/44/44 -f 260/45/45 4/3/3 75/46/46 -f 74/47/47 21/10/10 267/9/9 -f 72/48/48 294/49/49 268/50/50 -f 73/51/51 72/48/48 19/52/52 -f 73/51/51 20/53/53 21/10/10 -f 90/54/54 85/55/55 23/56/56 -f 88/57/57 22/58/58 269/59/59 -f 90/54/54 25/60/60 22/58/58 -f 35/61/61 26/17/17 28/11/11 -f 24/62/62 27/23/23 271/63/63 -f 134/64/64 45/65/65 276/66/66 -f 34/67/67 28/11/11 27/23/23 -f 11/28/28 30/68/68 29/69/69 -f 10/14/14 257/70/70 273/71/71 -f 2/25/25 29/69/69 272/72/72 -f 11/28/28 10/14/14 31/73/73 -f 36/74/74 278/75/75 274/76/76 -f 360/77/77 124/78/78 33/79/79 -f 45/65/65 42/80/80 281/81/81 -f 25/60/60 34/67/67 24/62/62 -f 22/58/58 24/62/62 277/82/72 -f 25/60/60 23/56/56 35/61/61 -f 122/83/82 36/74/74 33/79/79 -f 126/84/83 123/85/84 40/86/85 -f 19/52/52 48/87/86 47/88/87 -f 30/68/68 39/89/88 38/90/89 -f 29/69/69 38/90/89 279/91/72 -f 30/68/68 31/73/73 37/92/90 -f 155/93/91 45/65/65 92/94/92 -f 154/95/93 44/96/94 43/97/95 -f 155/93/91 151/98/96 42/80/80 -f 391/99/97 152/100/98 43/97/95 -f 393/101/99 281/81/81 42/80/80 -f 154/95/93 153/102/100 41/103/101 -f 54/104/102 289/105/103 287/106/104 -f 19/52/52 268/50/50 275/107/105 -f 20/53/53 47/88/87 46/108/106 -f 260/45/45 285/109/107 51/110/108 -f 49/4/4 48/87/86 68/111/109 -f 50/1/1 60/112/110 59/113/111 -f 47/88/87 48/87/86 58/114/112 -f 286/115/113 52/116/114 53/117/115 -f 55/118/116 54/104/102 53/117/115 -f 288/119/117 55/118/116 52/116/114 -f 283/8/8 46/108/106 55/120/116 -f 51/110/108 54/121/102 55/120/116 -f 285/109/107 289/122/103 54/121/102 -f 56/123/118 57/124/119 63/125/120 -f 61/126/121 67/127/122 66/128/123 -f 51/110/108 46/108/106 56/129/118 -f 49/4/4 59/113/111 58/114/112 -f 47/88/87 57/130/119 56/129/118 -f 50/1/1 51/110/108 61/131/121 -f 64/132/124 65/133/125 66/134/123 -f 62/135/126 63/125/120 66/128/123 -f 56/123/118 62/135/126 67/127/122 -f 59/136/111 60/137/110 66/134/123 -f 58/138/112 59/136/111 65/133/125 -f 58/138/112 64/132/124 63/139/120 -f 291/140/127 69/141/128 71/142/129 -f 48/87/86 275/107/105 290/143/130 -f 284/6/6 49/4/4 69/144/128 -f 292/145/131 293/146/132 71/142/129 -f 69/141/128 68/147/109 70/148/133 -f 68/147/109 290/149/130 292/145/131 -f 9/15/15 74/47/47 295/150/134 -f 8/22/22 72/48/48 73/51/51 -f 12/26/26 73/51/51 74/47/47 -f 294/49/49 72/48/48 8/22/22 -f 75/46/46 76/151/135 80/152/136 -f 76/151/135 77/153/137 81/154/138 -f 5/2/2 7/5/5 77/153/137 -f 4/3/3 5/2/2 76/151/135 -f 81/154/138 301/155/139 303/156/140 -f 79/157/141 78/158/142 302/159/143 -f 75/46/46 79/157/141 299/160/144 -f 77/153/137 297/44/44 301/155/139 -f 304/161/145 302/159/143 78/158/142 -f 304/161/145 82/162/146 83/163/147 -f 80/152/136 81/154/138 83/163/147 -f 79/157/141 80/152/136 82/162/146 -f 153/102/100 156/164/148 93/165/149 -f 157/166/150 92/94/92 93/165/149 -f 121/167/151 125/168/152 87/169/153 -f 125/168/152 126/84/83 86/170/154 -f 280/171/155 307/172/156 86/170/154 -f 39/89/88 91/173/157 89/174/158 -f 91/173/157 90/54/54 88/57/57 -f 38/90/89 89/174/158 306/175/59 -f 89/174/158 88/57/57 305/176/59 -f 37/92/90 84/177/159 91/173/157 -f 91/173/157 84/177/159 85/55/55 -f 95/178/160 87/169/153 343/179/161 -f 32/180/162 87/169/153 95/178/160 -f 86/170/154 307/172/156 343/179/161 -f 311/181/163 94/182/164 97/183/165 -f 96/184/166 98/185/167 97/183/165 -f 96/184/166 95/178/160 99/186/168 -f 312/187/169 313/188/170 99/186/168 -f 99/189/168 102/190/171 101/191/172 -f 314/192/173 97/193/165 100/194/174 -f 313/195/170 318/196/175 102/190/171 -f 98/197/167 101/191/172 100/194/174 -f 318/196/175 323/198/176 105/199/177 -f 101/191/172 104/200/178 103/201/179 -f 101/191/172 102/190/171 105/199/177 -f 100/194/174 103/201/179 324/202/180 -f 110/203/181 113/204/182 112/205/183 -f 109/206/184 112/205/183 339/207/185 -f 109/206/184 108/208/186 107/209/187 -f 334/210/188 331/211/189 108/208/186 -f 333/212/190 338/213/191 114/214/192 -f 110/203/181 107/209/187 106/215/193 -f 111/216/194 106/215/193 332/217/195 -f 111/216/194 114/214/192 113/204/182 -f 103/201/179 114/214/192 338/213/191 -f 104/200/178 113/204/182 114/214/192 -f 105/199/177 112/205/183 113/204/182 -f 323/198/176 339/207/185 112/205/183 -f 94/182/164 311/181/163 278/75/75 -f 32/180/162 96/184/166 94/182/164 -f 332/217/195 106/215/193 115/218/196 -f 106/215/193 107/209/187 116/219/197 -f 331/211/189 347/220/198 117/221/199 -f 108/208/186 117/221/199 116/219/197 -f 354/222/200 119/223/201 118/224/202 -f 117/221/199 347/220/198 349/225/203 -f 120/226/204 119/223/201 354/222/200 -f 117/221/199 118/227/202 119/228/201 -f 116/219/197 119/228/201 120/229/204 -f 115/218/196 120/229/204 353/230/205 -f 133/231/206 44/232/94 128/233/207 -f 32/180/162 36/74/74 122/83/82 -f 135/234/208 136/235/209 126/84/83 -f 132/236/210 135/234/208 125/168/152 -f 136/235/209 134/64/64 123/85/84 -f 133/237/206 122/83/82 124/78/78 -f 369/238/211 131/239/212 124/78/78 -f 40/86/85 123/85/84 356/240/213 -f 127/241/214 139/242/215 140/243/216 -f 41/244/101 127/241/214 128/233/207 -f 121/245/151 129/246/217 137/247/218 -f 121/245/151 122/248/82 130/249/219 -f 132/250/210 137/251/218 127/241/214 -f 130/249/219 138/252/220 144/253/221 -f 282/254/222 43/97/95 131/239/212 -f 44/96/94 133/237/206 131/239/212 -f 92/94/92 45/65/65 134/64/64 -f 41/103/101 93/165/149 135/234/208 -f 93/165/149 92/94/92 136/235/209 -f 122/248/82 133/255/206 138/252/220 -f 123/85/84 134/64/64 367/256/223 -f 142/257/224 144/253/221 150/258/225 -f 139/242/215 143/259/226 149/260/227 -f 127/241/214 137/251/218 143/259/226 -f 129/246/217 130/249/219 142/257/224 -f 137/247/218 129/246/217 141/261/228 -f 128/233/207 140/243/216 144/262/221 -f 150/263/225 146/264/229 145/265/230 -f 147/266/231 148/267/232 150/258/225 -f 139/242/215 145/265/230 146/264/229 -f 140/243/216 146/264/229 150/263/225 -f 141/261/228 142/257/224 148/267/232 -f 141/261/228 147/266/231 149/268/227 -f 84/177/159 157/166/150 156/164/148 -f 23/56/56 85/55/55 156/164/148 -f 35/61/61 23/56/56 153/102/100 -f 273/71/71 393/101/99 151/98/96 -f 270/18/18 26/17/17 152/100/98 -f 37/92/90 31/73/73 151/98/96 -f 35/61/61 154/95/93 152/100/98 -f 37/92/90 155/93/91 157/166/150 -f 259/24/24 6/13/13 160/34/34 -f 6/13/13 1/12/12 159/32/32 -f 1/12/12 3/27/27 158/29/29 -f 3/27/27 256/19/19 398/30/30 -f 164/3/233 165/2/234 210/1/235 -f 210/1/235 165/2/234 167/5/236 -f 167/5/236 261/7/7 284/6/6 -f 283/8/8 206/108/237 181/10/238 -f 166/13/239 161/12/240 188/11/241 -f 258/16/16 169/15/242 170/14/243 -f 186/17/244 163/27/245 256/19/19 -f 168/22/246 254/21/21 255/20/20 -f 259/24/24 166/13/239 187/23/247 -f 172/26/248 168/22/246 162/25/249 -f 161/12/240 163/27/245 186/17/244 -f 169/15/242 172/26/248 171/28/250 -f 399/29/251 174/33/252 262/31/31 -f 400/32/253 173/35/254 174/33/252 -f 401/34/255 175/37/256 173/35/254 -f 402/36/36 263/269/257 175/37/256 -f 175/37/256 178/40/258 176/38/259 -f 173/35/254 176/38/259 177/39/260 -f 265/41/41 178/40/258 175/37/256 -f 174/33/252 177/39/260 264/42/42 -f 178/40/258 265/41/41 266/43/43 -f 266/43/43 264/42/42 177/39/260 -f 167/5/236 237/153/261 297/44/44 -f 260/45/45 296/270/262 235/46/263 -f 267/9/9 181/10/238 234/47/264 -f 232/48/265 179/52/266 268/50/50 -f 233/51/267 180/53/268 179/52/266 -f 181/10/238 180/53/268 233/51/267 -f 250/54/269 185/60/270 183/56/271 -f 269/59/59 182/58/272 248/57/273 -f 182/58/272 185/60/270 250/54/269 -f 188/11/241 186/17/244 195/61/274 -f 271/63/63 187/23/247 184/62/275 -f 276/66/66 205/65/276 372/64/277 -f 187/23/247 188/11/241 194/67/278 -f 189/69/279 190/68/280 171/28/250 -f 170/14/243 191/73/281 273/71/71 -f 272/72/72 189/69/279 162/25/249 -f 171/28/250 190/68/280 191/73/281 -f 196/74/282 193/79/283 274/76/76 -f 360/77/77 274/76/76 193/79/283 -f 281/81/81 202/80/284 205/65/276 -f 184/62/275 194/67/278 185/60/270 -f 277/82/72 184/62/275 182/58/272 -f 185/60/270 194/67/278 195/61/274 -f 193/79/283 196/74/282 357/83/285 -f 362/84/286 246/170/287 200/86/288 -f 207/88/289 208/87/290 179/52/266 -f 198/90/291 199/89/292 190/68/280 -f 279/91/72 198/90/291 189/69/279 -f 190/68/280 199/89/292 197/92/293 -f 252/94/294 205/65/276 395/93/295 -f 203/97/296 204/96/297 394/95/298 -f 395/93/295 205/65/276 202/80/284 -f 391/99/97 282/254/222 203/97/296 -f 202/80/284 281/81/81 393/101/99 -f 394/95/298 204/96/297 201/103/299 -f 214/104/300 213/117/301 287/106/104 -f 179/52/266 208/87/290 275/107/105 -f 206/108/237 207/88/289 180/53/268 -f 260/45/45 164/3/233 211/110/302 -f 209/4/303 229/144/304 228/111/305 -f 219/113/306 220/112/307 210/1/235 -f 207/88/289 217/130/308 218/114/309 -f 213/117/301 212/116/310 286/115/113 -f 215/118/311 212/116/310 213/117/301 -f 288/119/117 286/115/113 212/116/310 -f 283/8/8 288/271/117 215/120/311 -f 215/120/311 214/121/300 211/110/302 -f 214/121/300 289/122/103 285/109/107 -f 216/123/312 222/135/313 223/125/314 -f 226/128/315 227/127/316 221/126/317 -f 211/110/302 221/131/317 216/129/312 -f 218/114/309 219/113/306 209/4/303 -f 216/129/312 217/130/308 207/88/289 -f 210/1/235 220/112/307 221/131/317 -f 226/134/315 225/133/318 224/132/319 -f 222/135/313 227/127/316 226/128/315 -f 227/127/316 222/135/313 216/123/312 -f 219/136/306 225/133/318 226/134/315 -f 218/138/309 224/132/319 225/133/318 -f 223/139/314 224/132/319 218/138/309 -f 291/140/127 293/146/132 231/142/320 -f 208/87/290 228/111/305 290/143/130 -f 284/6/6 291/272/127 229/144/304 -f 231/142/320 293/146/132 292/145/131 -f 229/141/304 231/142/320 230/148/321 -f 228/147/305 230/148/321 292/145/131 -f 169/15/242 258/16/16 295/150/134 -f 168/22/246 172/26/248 233/51/267 -f 172/26/248 169/15/242 234/47/264 -f 168/22/246 232/48/265 294/49/49 -f 235/46/263 239/157/322 240/152/323 -f 236/151/324 240/152/323 241/154/325 -f 165/2/234 236/151/324 237/153/261 -f 164/3/233 235/46/263 236/151/324 -f 241/154/325 243/163/326 303/156/140 -f 302/159/143 238/158/327 239/157/322 -f 299/160/144 239/157/322 235/46/263 -f 237/153/261 241/154/325 301/155/139 -f 238/158/327 302/159/143 304/161/145 -f 243/163/326 242/162/328 304/161/145 -f 242/162/328 243/163/326 241/154/325 -f 239/157/322 238/158/327 242/162/328 -f 392/102/329 201/103/299 253/165/330 -f 253/165/330 252/94/294 397/166/331 -f 355/167/332 192/180/333 247/169/334 -f 361/168/335 247/169/334 246/170/287 -f 246/170/287 307/172/156 280/171/155 -f 249/174/336 251/173/337 199/89/292 -f 248/57/273 250/54/269 251/173/337 -f 306/175/59 249/174/336 198/90/291 -f 305/176/59 248/57/273 249/174/336 -f 251/173/337 244/177/338 197/92/293 -f 251/173/337 250/54/269 245/55/339 -f 343/179/161 247/169/334 309/178/340 -f 192/180/333 310/184/341 309/178/340 -f 343/179/161 307/172/156 246/170/287 -f 311/181/163 314/273/173 315/183/342 -f 315/183/342 316/185/343 310/184/341 -f 310/184/341 316/185/343 317/186/344 -f 317/186/344 313/188/170 312/187/169 -f 321/191/345 322/190/346 317/189/344 -f 314/192/173 319/274/200 320/194/347 -f 322/190/346 318/196/175 313/195/170 -f 320/194/347 321/191/345 316/197/343 -f 327/199/348 323/198/176 318/196/175 -f 325/201/349 326/200/350 321/191/345 -f 326/200/350 327/199/348 322/190/346 -f 324/202/180 325/201/349 320/194/347 -f 340/205/351 341/204/352 336/203/353 -f 339/207/185 340/205/351 335/206/354 -f 329/209/355 330/208/356 335/206/354 -f 330/208/356 331/211/189 334/210/188 -f 342/214/357 338/213/191 333/212/190 -f 328/215/358 329/209/355 336/203/353 -f 332/217/195 328/215/358 337/216/359 -f 341/204/352 342/214/357 337/216/359 -f 325/201/349 324/202/180 338/213/191 -f 326/200/350 325/201/349 342/214/357 -f 327/199/348 326/200/350 341/204/352 -f 323/198/176 327/199/348 340/205/351 -f 278/75/75 311/181/163 308/182/360 -f 308/182/360 310/184/341 192/180/333 -f 332/217/195 348/275/361 344/218/362 -f 328/215/358 344/218/362 345/219/363 -f 346/221/364 347/220/198 331/211/189 -f 345/219/363 346/221/364 330/208/356 -f 350/224/365 351/223/366 354/222/200 -f 350/227/365 349/225/203 347/220/198 -f 354/222/200 351/223/366 352/226/367 -f 345/219/363 351/228/366 350/227/365 -f 344/218/362 352/229/367 351/228/366 -f 353/230/205 352/229/367 344/218/362 -f 371/231/368 376/276/369 364/233/370 -f 192/180/333 355/167/332 357/83/285 -f 373/234/371 361/168/335 362/84/286 -f 370/236/372 355/167/332 361/168/335 -f 374/235/373 362/84/286 358/85/374 -f 359/78/375 357/83/285 371/237/368 -f 369/238/211 360/77/77 359/78/375 -f 356/240/213 358/85/374 200/86/288 -f 378/243/376 377/242/377 363/241/378 -f 364/233/370 363/241/378 201/244/299 -f 375/247/379 365/246/380 355/245/332 -f 355/245/332 365/246/380 366/249/381 -f 363/241/378 375/251/379 370/250/372 -f 366/249/381 380/257/382 382/253/383 -f 282/254/222 369/238/211 368/239/384 -f 368/239/384 371/237/368 204/96/297 -f 252/94/294 374/235/373 372/64/277 -f 201/103/299 370/236/372 373/234/371 -f 253/165/330 373/234/371 374/235/373 -f 357/248/285 366/249/381 376/252/369 -f 367/256/223 372/64/277 358/85/374 -f 380/257/382 386/267/385 388/258/386 -f 377/242/377 383/265/387 387/260/388 -f 363/241/378 377/242/377 381/259/389 -f 365/246/380 379/261/390 380/257/382 -f 375/247/379 381/277/389 379/261/390 -f 382/262/383 378/243/376 364/233/370 -f 383/265/387 384/264/391 388/263/386 -f 385/266/392 387/268/388 388/258/386 -f 384/264/391 383/265/387 377/242/377 -f 388/263/386 384/264/391 378/243/376 -f 379/261/390 385/266/392 386/267/385 -f 387/268/388 385/266/392 379/261/390 -f 396/164/393 397/166/331 244/177/338 -f 183/56/271 392/102/329 396/164/393 -f 195/61/274 394/95/298 392/102/329 -f 389/98/394 393/101/99 273/71/71 -f 270/18/18 391/99/97 390/100/395 -f 197/92/293 395/93/295 389/98/394 -f 390/100/395 394/95/298 195/61/274 -f 397/166/331 395/93/295 197/92/293 -f 259/24/24 402/36/36 401/34/255 -f 166/13/239 401/34/255 400/32/253 -f 161/12/240 400/32/253 399/29/251 -f 163/27/245 399/29/251 398/30/30 -f 51/110/108 50/1/1 4/3/3 -f 5/2/2 50/1/1 7/5/5 -f 49/4/4 284/6/6 7/5/5 -f 46/108/106 283/8/8 21/10/10 -f 27/23/23 28/11/11 6/13/13 -f 257/70/70 10/14/14 258/16/16 -f 3/27/27 26/17/17 256/19/19 -f 2/25/25 255/20/20 8/22/22 -f 271/63/63 27/23/23 259/24/24 -f 11/28/28 2/25/25 12/26/26 -f 28/11/11 26/17/17 1/12/12 -f 10/14/14 11/28/28 9/15/15 -f 14/33/33 158/29/29 262/31/31 -f 13/35/35 159/32/32 14/33/33 -f 15/37/37 160/34/34 13/35/35 -f 263/269/257 402/36/36 15/37/37 -f 18/40/40 15/37/37 16/38/38 -f 16/38/38 13/35/35 17/39/39 -f 263/269/257 15/37/37 265/41/41 -f 17/39/39 14/33/33 264/42/42 -f 265/41/41 18/40/40 266/43/43 -f 16/38/38 17/39/39 266/43/43 -f 77/153/137 7/5/5 297/44/44 -f 296/270/262 260/45/45 75/46/46 -f 295/150/134 74/47/47 267/9/9 -f 19/52/52 72/48/48 268/50/50 -f 20/53/53 73/51/51 19/52/52 -f 74/47/47 73/51/51 21/10/10 -f 25/60/60 90/54/54 23/56/56 -f 305/176/59 88/57/57 269/59/59 -f 88/57/57 90/54/54 22/58/58 -f 34/67/67 35/61/61 28/11/11 -f 277/82/72 24/62/62 271/63/63 -f 367/256/223 134/64/64 276/66/66 -f 24/62/62 34/67/67 27/23/23 -f 2/25/25 11/28/28 29/69/69 -f 31/73/73 10/14/14 273/71/71 -f 255/20/20 2/25/25 272/72/72 -f 30/68/68 11/28/28 31/73/73 -f 33/79/79 36/74/74 274/76/76 -f 274/76/76 360/77/77 33/79/79 -f 276/66/66 45/65/65 281/81/81 -f 22/58/58 25/60/60 24/62/62 -f 269/59/59 22/58/58 277/82/72 -f 34/67/67 25/60/60 35/61/61 -f 124/78/78 122/83/82 33/79/79 -f 86/170/154 126/84/83 40/86/85 -f 20/53/53 19/52/52 47/88/87 -f 29/69/69 30/68/68 38/90/89 -f 272/72/72 29/69/69 279/91/72 -f 39/89/88 30/68/68 37/92/90 -f 157/166/150 155/93/91 92/94/92 -f 152/100/98 154/95/93 43/97/95 -f 45/65/65 155/93/91 42/80/80 -f 282/254/222 391/99/97 43/97/95 -f 151/98/96 393/101/99 42/80/80 -f 44/96/94 154/95/93 41/103/101 -f 53/117/115 54/104/102 287/106/104 -f 48/87/86 19/52/52 275/107/105 -f 21/10/10 20/53/53 46/108/106 -f 4/3/3 260/45/45 51/110/108 -f 69/144/128 49/4/4 68/111/109 -f 49/4/4 50/1/1 59/113/111 -f 57/130/119 47/88/87 58/114/112 -f 287/106/104 286/115/113 53/117/115 -f 52/116/114 55/118/116 53/117/115 -f 286/115/113 288/119/117 52/116/114 -f 288/271/117 283/8/8 55/120/116 -f 46/108/106 51/110/108 55/120/116 -f 51/110/108 285/109/107 54/121/102 -f 62/135/126 56/123/118 63/125/120 -f 60/278/110 61/126/121 66/128/123 -f 61/131/121 51/110/108 56/129/118 -f 48/87/86 49/4/4 58/114/112 -f 46/108/106 47/88/87 56/129/118 -f 60/112/110 50/1/1 61/131/121 -f 63/139/120 64/132/124 66/134/123 -f 67/127/122 62/135/126 66/128/123 -f 61/126/121 56/123/118 67/127/122 -f 65/133/125 59/136/111 66/134/123 -f 64/132/124 58/138/112 65/133/125 -f 57/279/119 58/138/112 63/139/120 -f 293/146/132 291/140/127 71/142/129 -f 68/111/109 48/87/86 290/143/130 -f 291/272/127 284/6/6 69/144/128 -f 70/148/133 292/145/131 71/142/129 -f 71/142/129 69/141/128 70/148/133 -f 70/148/133 68/147/109 292/145/131 -f 258/16/16 9/15/15 295/150/134 -f 12/26/26 8/22/22 73/51/51 -f 9/15/15 12/26/26 74/47/47 -f 254/21/21 294/49/49 8/22/22 -f 79/157/141 75/46/46 80/152/136 -f 80/152/136 76/151/135 81/154/138 -f 76/151/135 5/2/2 77/153/137 -f 75/46/46 4/3/3 76/151/135 -f 83/163/147 81/154/138 303/156/140 -f 299/160/144 79/157/141 302/159/143 -f 296/270/262 75/46/46 299/160/144 -f 81/154/138 77/153/137 301/155/139 -f 82/162/146 304/161/145 78/158/142 -f 303/156/140 304/161/145 83/163/147 -f 82/162/146 80/152/136 83/163/147 -f 78/158/142 79/157/141 82/162/146 -f 41/103/101 153/102/100 93/165/149 -f 156/164/148 157/166/150 93/165/149 -f 32/180/162 121/167/151 87/169/153 -f 87/169/153 125/168/152 86/170/154 -f 40/86/85 280/171/155 86/170/154 -f 38/90/89 39/89/88 89/174/158 -f 89/174/158 91/173/157 88/57/57 -f 279/91/72 38/90/89 306/175/59 -f 306/175/59 89/174/158 305/176/59 -f 39/89/88 37/92/90 91/173/157 -f 90/54/54 91/173/157 85/55/55 -f 312/187/169 95/178/160 343/179/161 -f 96/184/166 32/180/162 95/178/160 -f 87/169/153 86/170/154 343/179/161 -f 314/273/173 311/181/163 97/183/165 -f 94/182/164 96/184/166 97/183/165 -f 98/185/167 96/184/166 99/186/168 -f 95/178/160 312/187/169 99/186/168 -f 98/197/167 99/189/168 101/191/172 -f 319/274/200 314/192/173 100/194/174 -f 99/189/168 313/195/170 102/190/171 -f 97/193/165 98/197/167 100/194/174 -f 102/190/171 318/196/175 105/199/177 -f 100/194/174 101/191/172 103/201/179 -f 104/200/178 101/191/172 105/199/177 -f 319/274/200 100/194/174 324/202/180 -f 109/206/184 110/203/181 112/205/183 -f 334/210/188 109/206/184 339/207/185 -f 110/203/181 109/206/184 107/209/187 -f 109/206/184 334/210/188 108/208/186 -f 111/216/194 333/212/190 114/214/192 -f 111/216/194 110/203/181 106/215/193 -f 333/212/190 111/216/194 332/217/195 -f 110/203/181 111/216/194 113/204/182 -f 324/202/180 103/201/179 338/213/191 -f 103/201/179 104/200/178 114/214/192 -f 104/200/178 105/199/177 113/204/182 -f 105/199/177 323/198/176 112/205/183 -f 36/74/74 94/182/164 278/75/75 -f 36/74/74 32/180/162 94/182/164 -f 348/275/361 332/217/195 115/218/196 -f 115/218/196 106/215/193 116/219/197 -f 108/208/186 331/211/189 117/221/199 -f 107/209/187 108/208/186 116/219/197 -f 349/280/203 354/222/200 118/224/202 -f 118/227/202 117/221/199 349/225/203 -f 353/281/205 120/226/204 354/222/200 -f 116/219/197 117/221/199 119/228/201 -f 115/218/196 116/219/197 120/229/204 -f 348/275/361 115/218/196 353/230/205 -f 138/276/220 133/231/206 128/233/207 -f 121/167/151 32/180/162 122/83/82 -f 125/168/152 135/234/208 126/84/83 -f 121/167/151 132/236/210 125/168/152 -f 126/84/83 136/235/209 123/85/84 -f 131/239/212 133/237/206 124/78/78 -f 360/77/77 369/238/211 124/78/78 -f 280/171/155 40/86/85 356/240/213 -f 128/233/207 127/241/214 140/243/216 -f 44/232/94 41/244/101 128/233/207 -f 132/282/210 121/245/151 137/247/218 -f 129/246/217 121/245/151 130/249/219 -f 41/244/101 132/250/210 127/241/214 -f 142/257/224 130/249/219 144/253/221 -f 369/238/211 282/254/222 131/239/212 -f 43/97/95 44/96/94 131/239/212 -f 136/235/209 92/94/92 134/64/64 -f 132/236/210 41/103/101 135/234/208 -f 135/234/208 93/165/149 136/235/209 -f 130/249/219 122/248/82 138/252/220 -f 356/240/213 123/85/84 367/256/223 -f 148/267/232 142/257/224 150/258/225 -f 145/265/230 139/242/215 149/260/227 -f 139/242/215 127/241/214 143/259/226 -f 141/261/228 129/246/217 142/257/224 -f 143/277/226 137/247/218 141/261/228 -f 138/276/220 128/233/207 144/262/221 -f 149/260/227 150/263/225 145/265/230 -f 149/268/227 147/266/231 150/258/225 -f 140/243/216 139/242/215 146/264/229 -f 144/262/221 140/243/216 150/263/225 -f 147/266/231 141/261/228 148/267/232 -f 143/277/226 141/261/228 149/268/227 -f 85/55/55 84/177/159 156/164/148 -f 153/102/100 23/56/56 156/164/148 -f 154/95/93 35/61/61 153/102/100 -f 31/73/73 273/71/71 151/98/96 -f 391/99/97 270/18/18 152/100/98 -f 155/93/91 37/92/90 151/98/96 -f 26/17/17 35/61/61 152/100/98 -f 84/177/159 37/92/90 157/166/150 -f 402/36/36 259/24/24 160/34/34 -f 160/34/34 6/13/13 159/32/32 -f 159/32/32 1/12/12 158/29/29 -f 158/29/29 3/27/27 398/30/30 -f 211/110/302 164/3/233 210/1/235 -f 209/4/303 210/1/235 167/5/236 -f 209/4/303 167/5/236 284/6/6 -f 267/9/9 283/8/8 181/10/238 -f 187/23/247 166/13/239 188/11/241 -f 257/70/70 258/16/16 170/14/243 -f 270/18/18 186/17/244 256/19/19 -f 162/25/249 168/22/246 255/20/20 -f 271/63/63 259/24/24 187/23/247 -f 171/28/250 172/26/248 162/25/249 -f 188/11/241 161/12/240 186/17/244 -f 170/14/243 169/15/242 171/28/250 -f 398/30/30 399/29/251 262/31/31 -f 399/29/251 400/32/253 174/33/252 -f 400/32/253 401/34/255 173/35/254 -f 401/34/255 402/36/36 175/37/256 -f 173/35/254 175/37/256 176/38/259 -f 174/33/252 173/35/254 177/39/260 -f 263/269/257 265/41/41 175/37/256 -f 262/31/31 174/33/252 264/42/42 -f 176/38/259 178/40/258 266/43/43 -f 176/38/259 266/43/43 177/39/260 -f 261/7/7 167/5/236 297/44/44 -f 164/3/233 260/45/45 235/46/263 -f 295/150/134 267/9/9 234/47/264 -f 294/49/49 232/48/265 268/50/50 -f 232/48/265 233/51/267 179/52/266 -f 234/47/264 181/10/238 233/51/267 -f 245/55/339 250/54/269 183/56/271 -f 305/176/59 269/59/59 248/57/273 -f 248/57/273 182/58/272 250/54/269 -f 194/67/278 188/11/241 195/61/274 -f 277/82/72 271/63/63 184/62/275 -f 367/256/223 276/66/66 372/64/277 -f 184/62/275 187/23/247 194/67/278 -f 162/25/249 189/69/279 171/28/250 -f 257/70/70 170/14/243 273/71/71 -f 255/20/20 272/72/72 162/25/249 -f 170/14/243 171/28/250 191/73/281 -f 278/75/75 196/74/282 274/76/76 -f 359/78/375 360/77/77 193/79/283 -f 276/66/66 281/81/81 205/65/276 -f 182/58/272 184/62/275 185/60/270 -f 269/59/59 277/82/72 182/58/272 -f 183/56/271 185/60/270 195/61/274 -f 359/78/375 193/79/283 357/83/285 -f 358/85/374 362/84/286 200/86/288 -f 180/53/268 207/88/289 179/52/266 -f 189/69/279 198/90/291 190/68/280 -f 272/72/72 279/91/72 189/69/279 -f 191/73/281 190/68/280 197/92/293 -f 397/166/331 252/94/294 395/93/295 -f 390/100/395 203/97/296 394/95/298 -f 389/98/394 395/93/295 202/80/284 -f 390/100/395 391/99/97 203/97/296 -f 389/98/394 202/80/284 393/101/99 -f 392/102/329 394/95/298 201/103/299 -f 289/105/103 214/104/300 287/106/104 -f 268/50/50 179/52/266 275/107/105 -f 181/10/238 206/108/237 180/53/268 -f 285/109/107 260/45/45 211/110/302 -f 208/87/290 209/4/303 228/111/305 -f 209/4/303 219/113/306 210/1/235 -f 208/87/290 207/88/289 218/114/309 -f 287/106/104 213/117/301 286/115/113 -f 214/104/300 215/118/311 213/117/301 -f 215/118/311 288/119/117 212/116/310 -f 206/108/237 283/8/8 215/120/311 -f 206/108/237 215/120/311 211/110/302 -f 211/110/302 214/121/300 285/109/107 -f 217/124/308 216/123/312 223/125/314 -f 220/278/307 226/128/315 221/126/317 -f 206/108/237 211/110/302 216/129/312 -f 208/87/290 218/114/309 209/4/303 -f 206/108/237 216/129/312 207/88/289 -f 211/110/302 210/1/235 221/131/317 -f 223/139/314 226/134/315 224/132/319 -f 223/125/314 222/135/313 226/128/315 -f 221/126/317 227/127/316 216/123/312 -f 220/137/307 219/136/306 226/134/315 -f 219/136/306 218/138/309 225/133/318 -f 217/279/308 223/139/314 218/138/309 -f 229/141/304 291/140/127 231/142/320 -f 275/107/105 208/87/290 290/143/130 -f 209/4/303 284/6/6 229/144/304 -f 230/148/321 231/142/320 292/145/131 -f 228/147/305 229/141/304 230/148/321 -f 290/149/130 228/147/305 292/145/131 -f 234/47/264 169/15/242 295/150/134 -f 232/48/265 168/22/246 233/51/267 -f 233/51/267 172/26/248 234/47/264 -f 254/21/21 168/22/246 294/49/49 -f 236/151/324 235/46/263 240/152/323 -f 237/153/261 236/151/324 241/154/325 -f 167/5/236 165/2/234 237/153/261 -f 165/2/234 164/3/233 236/151/324 -f 301/155/139 241/154/325 303/156/140 -f 299/160/144 302/159/143 239/157/322 -f 296/270/262 299/160/144 235/46/263 -f 297/44/44 237/153/261 301/155/139 -f 242/162/328 238/158/327 304/161/145 -f 303/156/140 243/163/326 304/161/145 -f 240/152/323 242/162/328 241/154/325 -f 240/152/323 239/157/322 242/162/328 -f 396/164/393 392/102/329 253/165/330 -f 396/164/393 253/165/330 397/166/331 -f 361/168/335 355/167/332 247/169/334 -f 362/84/286 361/168/335 246/170/287 -f 200/86/288 246/170/287 280/171/155 -f 198/90/291 249/174/336 199/89/292 -f 249/174/336 248/57/273 251/173/337 -f 279/91/72 306/175/59 198/90/291 -f 306/175/59 305/176/59 249/174/336 -f 199/89/292 251/173/337 197/92/293 -f 244/177/338 251/173/337 245/55/339 -f 312/187/169 343/179/161 309/178/340 -f 247/169/334 192/180/333 309/178/340 -f 247/169/334 343/179/161 246/170/287 -f 308/182/360 311/181/163 315/183/342 -f 308/182/360 315/183/342 310/184/341 -f 309/178/340 310/184/341 317/186/344 -f 309/178/340 317/186/344 312/187/169 -f 316/197/343 321/191/345 317/189/344 -f 315/193/342 314/192/173 320/194/347 -f 317/189/344 322/190/346 313/195/170 -f 315/193/342 320/194/347 316/197/343 -f 322/190/346 327/199/348 318/196/175 -f 320/194/347 325/201/349 321/191/345 -f 321/191/345 326/200/350 322/190/346 -f 319/274/200 324/202/180 320/194/347 -f 335/206/354 340/205/351 336/203/353 -f 334/210/188 339/207/185 335/206/354 -f 336/203/353 329/209/355 335/206/354 -f 335/206/354 330/208/356 334/210/188 -f 337/216/359 342/214/357 333/212/190 -f 337/216/359 328/215/358 336/203/353 -f 333/212/190 332/217/195 337/216/359 -f 336/203/353 341/204/352 337/216/359 -f 342/214/357 325/201/349 338/213/191 -f 341/204/352 326/200/350 342/214/357 -f 340/205/351 327/199/348 341/204/352 -f 339/207/185 323/198/176 340/205/351 -f 196/74/282 278/75/75 308/182/360 -f 196/74/282 308/182/360 192/180/333 -f 328/215/358 332/217/195 344/218/362 -f 329/209/355 328/215/358 345/219/363 -f 330/208/356 346/221/364 331/211/189 -f 329/209/355 345/219/363 330/208/356 -f 349/280/203 350/224/365 354/222/200 -f 346/221/364 350/227/365 347/220/198 -f 353/281/205 354/222/200 352/226/367 -f 346/221/364 345/219/363 350/227/365 -f 345/219/363 344/218/362 351/228/366 -f 348/275/361 353/230/205 344/218/362 -f 204/232/297 371/231/368 364/233/370 -f 196/74/282 192/180/333 357/83/285 -f 374/235/373 373/234/371 362/84/286 -f 373/234/371 370/236/372 361/168/335 -f 372/64/277 374/235/373 358/85/374 -f 368/239/384 359/78/375 371/237/368 -f 368/239/384 369/238/211 359/78/375 -f 280/171/155 356/240/213 200/86/288 -f 364/233/370 378/243/376 363/241/378 -f 204/232/297 364/233/370 201/244/299 -f 370/282/372 375/247/379 355/245/332 -f 357/248/285 355/245/332 366/249/381 -f 201/244/299 363/241/378 370/250/372 -f 376/252/369 366/249/381 382/253/383 -f 203/97/296 282/254/222 368/239/384 -f 203/97/296 368/239/384 204/96/297 -f 205/65/276 252/94/294 372/64/277 -f 253/165/330 201/103/299 373/234/371 -f 252/94/294 253/165/330 374/235/373 -f 371/255/368 357/248/285 376/252/369 -f 356/240/213 367/256/223 358/85/374 -f 382/253/383 380/257/382 388/258/386 -f 381/259/389 377/242/377 387/260/388 -f 375/251/379 363/241/378 381/259/389 -f 366/249/381 365/246/380 380/257/382 -f 365/246/380 375/247/379 379/261/390 -f 376/276/369 382/262/383 364/233/370 -f 387/260/388 383/265/387 388/263/386 -f 386/267/385 385/266/392 388/258/386 -f 378/243/376 384/264/391 377/242/377 -f 382/262/383 388/263/386 378/243/376 -f 380/257/382 379/261/390 386/267/385 -f 381/277/389 387/268/388 379/261/390 -f 245/55/339 396/164/393 244/177/338 -f 245/55/339 183/56/271 396/164/393 -f 183/56/271 195/61/274 392/102/329 -f 191/73/281 389/98/394 273/71/71 -f 186/17/244 270/18/18 390/100/395 -f 191/73/281 197/92/293 389/98/394 -f 186/17/244 390/100/395 195/61/274 -f 244/177/338 397/166/331 197/92/293 -f 166/13/239 259/24/24 401/34/255 -f 161/12/240 166/13/239 400/32/253 -f 163/27/245 161/12/240 399/29/251 -f 256/19/19 163/27/245 398/30/30 diff --git a/assets/Models/Submarine2.mtl b/assets/Models/Submarine2.mtl deleted file mode 100644 index 211bb03..0000000 --- a/assets/Models/Submarine2.mtl +++ /dev/null @@ -1,12 +0,0 @@ -# Blender MTL File: 'submarine.blend' -# Material Count: 1 - -newmtl Material -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd SubmarineTexture.png diff --git a/assets/Models/Submarine2.obj b/assets/Models/Submarine2.obj deleted file mode 100644 index 144e0ad..0000000 --- a/assets/Models/Submarine2.obj +++ /dev/null @@ -1,1881 +0,0 @@ -# Blender v2.75 (sub 0) OBJ File: 'submarine.blend' -# www.blender.org -mtllib Submarine2.mtl -o Cube -v -0.378953 -0.002680 -0.065172 -v 0.212611 0.044805 -0.044067 -v -0.378243 -0.049219 -0.040454 -v 0.511655 0.005655 -0.004951 -v 0.511655 0.014323 -0.009928 -v -0.378953 0.044805 -0.045251 -v 0.511655 0.021628 -0.004951 -v 0.296392 0.051346 -0.039065 -v 0.296392 -0.051355 -0.038417 -v 0.212611 -0.058696 -0.039270 -v 0.212611 -0.002680 -0.063988 -v 0.296392 -0.004712 -0.055556 -v -0.470020 0.007247 -0.055901 -v -0.470020 -0.033863 -0.039615 -v -0.470020 0.046066 -0.039615 -v -0.504866 0.007576 -0.027580 -v -0.504866 -0.015092 -0.019565 -v -0.504866 0.026681 -0.019565 -v 0.417794 0.035928 -0.027732 -v 0.417862 0.010074 -0.038703 -v 0.418042 -0.020280 -0.027718 -v -0.103707 0.044805 -0.044659 -v -0.095180 -0.059866 -0.039862 -v -0.145284 0.044805 -0.044778 -v -0.103707 -0.002680 -0.064580 -v -0.220059 -0.056313 -0.040098 -v -0.213663 0.044805 -0.044896 -v -0.213663 -0.002680 -0.064817 -v 0.016182 0.044805 -0.044401 -v 0.016182 -0.002680 -0.064322 -v 0.021156 -0.057734 -0.039604 -v -0.103679 -0.128289 -0.020932 -v -0.169800 -0.124081 -0.021745 -v -0.145284 -0.002680 -0.064699 -v -0.144573 -0.059156 -0.039980 -v -0.145256 -0.128299 -0.021050 -v -0.028130 -0.059156 -0.039733 -v -0.025998 0.044805 -0.044530 -v -0.025998 -0.002680 -0.064451 -v -0.028811 -0.126038 -0.021380 -v -0.101004 -0.090373 -0.028531 -v 0.004471 -0.088964 -0.032639 -v -0.179611 -0.092300 -0.029335 -v -0.147840 -0.092530 -0.029340 -v -0.011421 -0.110450 -0.026194 -v 0.438535 -0.016511 -0.025733 -v 0.439229 0.012885 -0.036411 -v 0.438680 0.033157 -0.025848 -v 0.488551 0.025074 -0.012937 -v 0.497469 0.013062 -0.015893 -v 0.493078 -0.000808 -0.010559 -v 0.457621 -0.052215 -0.000328 -v 0.486007 -0.049835 -0.001062 -v 0.489135 -0.011286 -0.003540 -v 0.449628 -0.021564 -0.002397 -v 0.452490 0.010420 -0.032017 -v 0.450888 0.012577 -0.032017 -v 0.452490 0.014448 -0.032017 -v 0.491993 0.014448 -0.019989 -v 0.493187 0.012577 -0.019989 -v 0.491993 0.010420 -0.019989 -v 0.463244 0.010420 -0.061607 -v 0.461409 0.012577 -0.061607 -v 0.463244 0.014448 -0.061607 -v 0.488480 0.014448 -0.059057 -v 0.489673 0.012577 -0.059057 -v 0.488480 0.010420 -0.059057 -v 0.450386 0.041229 -0.002309 -v 0.486995 0.039392 -0.003342 -v 0.457584 0.071526 -0.000278 -v 0.486002 0.068886 -0.001063 -v 0.372582 0.047066 -0.030989 -v 0.372582 0.004185 -0.046120 -v 0.372582 -0.034449 -0.032051 -v 0.511655 0.005655 -0.004951 -v 0.511655 0.014323 -0.009928 -v 0.511655 0.021628 -0.004951 -v 0.525395 0.008758 -0.002746 -v 0.515740 0.008758 -0.002746 -v 0.515740 0.011890 -0.004273 -v 0.515740 0.014988 -0.002825 -v 0.525395 0.011890 -0.004273 -v 0.525395 0.014988 -0.002825 -v -0.050480 -0.059392 -0.039776 -v -0.072830 -0.059629 -0.039819 -v -0.051873 -0.128594 -0.021423 -v -0.077776 -0.128594 -0.021466 -v -0.077804 0.044805 -0.044616 -v -0.051901 0.044805 -0.044573 -v -0.077804 -0.002680 -0.064537 -v -0.051901 -0.002680 -0.064494 -v -0.041517 -0.093350 -0.026237 -v -0.071378 -0.088718 -0.026280 -v -0.120025 -0.131743 -0.012698 -v -0.089441 -0.131743 -0.012647 -v -0.104733 -0.131743 -0.012672 -v -0.110237 -0.131352 -0.005504 -v -0.104733 -0.131352 -0.007784 -v -0.099229 -0.131352 -0.005504 -v -0.110237 -0.146402 -0.005504 -v -0.104733 -0.146402 -0.007784 -v -0.099229 -0.146402 -0.005504 -v -0.110237 -0.309639 -0.005504 -v -0.104733 -0.309639 -0.007784 -v -0.099229 -0.309639 -0.005504 -v -0.145706 -0.318985 -0.005504 -v -0.145706 -0.324489 -0.007784 -v -0.145706 -0.329993 -0.005504 -v -0.115907 -0.329993 -0.005504 -v -0.115907 -0.324489 -0.007784 -v -0.115907 -0.318985 -0.005504 -v -0.103586 -0.323872 -0.005504 -v -0.107478 -0.319980 -0.007784 -v -0.111369 -0.316088 -0.005504 -v -0.145706 -0.319804 -0.004685 -v -0.145706 -0.324489 -0.006626 -v -0.145706 -0.329175 -0.004685 -v -0.120728 -0.328489 -0.004000 -v -0.120728 -0.324489 -0.005656 -v -0.120728 -0.320490 -0.004000 -v -0.102383 -0.109911 -0.026878 -v -0.146509 -0.110962 -0.026891 -v -0.018918 -0.119800 -0.023713 -v -0.176358 -0.112152 -0.025424 -v -0.074675 -0.109265 -0.023799 -v -0.046854 -0.111511 -0.023756 -v -0.106319 -0.101496 -0.028531 -v -0.141797 -0.100168 -0.029340 -v -0.107087 -0.103696 -0.026878 -v -0.140874 -0.104992 -0.026891 -v -0.179464 -0.101651 -0.027380 -v -0.101694 -0.100142 -0.027239 -v -0.147175 -0.101746 -0.028115 -v -0.015169 -0.115125 -0.024953 -v -0.073027 -0.098992 -0.025039 -v -0.044185 -0.102430 -0.024996 -v -0.105455 -0.102694 -0.027239 -v -0.143547 -0.102580 -0.028115 -v -0.106319 -0.101496 -0.062227 -v -0.125329 -0.100168 -0.062227 -v -0.107087 -0.103696 -0.062227 -v -0.124406 -0.104992 -0.062227 -v -0.105455 -0.102694 -0.062227 -v -0.127079 -0.102580 -0.062227 -v -0.107364 -0.101496 -0.065167 -v -0.121148 -0.100168 -0.065167 -v -0.108133 -0.103696 -0.065167 -v -0.120226 -0.104992 -0.065167 -v -0.106501 -0.102694 -0.065167 -v -0.122898 -0.102580 -0.065167 -v 0.012813 -0.073349 -0.036122 -v -0.196426 -0.071466 -0.034717 -v -0.098092 -0.075120 -0.034196 -v -0.146207 -0.075843 -0.034660 -v -0.019775 -0.084803 -0.032963 -v -0.072104 -0.074173 -0.033049 -v -0.045998 -0.076371 -0.033006 -v -0.424131 -0.046842 -0.040035 -v -0.424487 0.002283 -0.060537 -v -0.424487 0.045435 -0.042433 -v -0.378953 -0.002680 0.065172 -v 0.212611 0.044805 0.044067 -v -0.378243 -0.049219 0.040454 -v 0.511655 0.005655 0.004951 -v 0.511655 0.014323 0.009928 -v -0.378953 0.044805 0.045251 -v 0.511655 0.021628 0.004951 -v 0.296392 0.051346 0.039065 -v 0.296392 -0.051355 0.038417 -v 0.212611 -0.058696 0.039270 -v 0.212611 -0.002680 0.063988 -v 0.296392 -0.004712 0.055556 -v -0.470020 0.007247 0.055901 -v -0.470020 -0.033863 0.039615 -v -0.470020 0.046066 0.039615 -v -0.504866 0.007576 0.027580 -v -0.504866 -0.015092 0.019565 -v -0.504866 0.026681 0.019565 -v 0.417794 0.035928 0.027732 -v 0.417862 0.010074 0.038703 -v 0.418042 -0.020280 0.027718 -v -0.103707 0.044805 0.044659 -v -0.095180 -0.059866 0.039862 -v -0.145284 0.044805 0.044778 -v -0.103707 -0.002680 0.064580 -v -0.220059 -0.056313 0.040098 -v -0.213663 0.044805 0.044896 -v -0.213663 -0.002680 0.064817 -v 0.016182 0.044805 0.044401 -v 0.016182 -0.002680 0.064322 -v 0.021156 -0.057734 0.039604 -v -0.103679 -0.128289 0.020933 -v -0.169800 -0.124081 0.021746 -v -0.145284 -0.002680 0.064699 -v -0.144573 -0.059156 0.039980 -v -0.145256 -0.128299 0.021050 -v -0.028130 -0.059156 0.039733 -v -0.025998 0.044805 0.044530 -v -0.025998 -0.002680 0.064451 -v -0.028811 -0.126038 0.021380 -v -0.101004 -0.090373 0.028531 -v 0.004471 -0.088964 0.032639 -v -0.179611 -0.092300 0.029335 -v -0.147840 -0.092530 0.029340 -v -0.011421 -0.110450 0.026194 -v 0.438535 -0.016511 0.025733 -v 0.439229 0.012885 0.036411 -v 0.438680 0.033157 0.025848 -v 0.488551 0.025074 0.012937 -v 0.497469 0.013062 0.015893 -v 0.493078 -0.000808 0.010559 -v 0.457621 -0.052215 0.000328 -v 0.486007 -0.049835 0.001062 -v 0.489135 -0.011286 0.003540 -v 0.449628 -0.021564 0.002397 -v 0.452490 0.010420 0.032017 -v 0.450888 0.012577 0.032017 -v 0.452490 0.014448 0.032017 -v 0.491993 0.014448 0.019989 -v 0.493187 0.012577 0.019989 -v 0.491993 0.010420 0.019989 -v 0.463244 0.010420 0.061607 -v 0.461409 0.012577 0.061607 -v 0.463244 0.014448 0.061607 -v 0.488480 0.014448 0.059057 -v 0.489673 0.012577 0.059057 -v 0.488480 0.010420 0.059057 -v 0.450386 0.041229 0.002309 -v 0.486995 0.039392 0.003342 -v 0.457584 0.071526 0.000278 -v 0.486002 0.068886 0.001063 -v 0.372582 0.047066 0.030989 -v 0.372582 0.004185 0.046120 -v 0.372582 -0.034449 0.032051 -v 0.511655 0.005655 0.004951 -v 0.511655 0.014323 0.009928 -v 0.511655 0.021628 0.004951 -v 0.525395 0.008758 0.002746 -v 0.515740 0.008758 0.002746 -v 0.515740 0.011890 0.004273 -v 0.515740 0.014988 0.002825 -v 0.525395 0.011890 0.004273 -v 0.525395 0.014988 0.002825 -v -0.050480 -0.059392 0.039776 -v -0.072830 -0.059629 0.039819 -v -0.051873 -0.128594 0.021423 -v -0.077776 -0.128594 0.021466 -v -0.077804 0.044805 0.044616 -v -0.051901 0.044805 0.044573 -v -0.077804 -0.002680 0.064537 -v -0.051901 -0.002680 0.064494 -v -0.041517 -0.093350 0.026237 -v -0.071378 -0.088718 0.026280 -v 0.296392 0.072896 -0.000000 -v 0.212611 0.073334 -0.000000 -v -0.378243 -0.071446 0.000000 -v 0.212611 -0.072397 0.000000 -v 0.296392 -0.066926 0.000000 -v -0.378953 0.073334 -0.000000 -v 0.510470 0.002703 -0.000000 -v 0.510470 0.026017 -0.000000 -v -0.470020 -0.049546 0.000000 -v -0.470020 0.069389 -0.000000 -v -0.503090 -0.022810 0.000000 -v -0.503090 0.038159 0.000000 -v -0.513891 0.007675 0.000000 -v 0.415462 -0.032528 -0.000000 -v 0.414729 0.050184 -0.000000 -v -0.103707 0.073334 -0.000000 -v -0.221664 -0.076517 0.000000 -v -0.213663 0.073334 -0.000000 -v 0.016182 0.073334 -0.000000 -v 0.024709 -0.072856 0.000000 -v -0.169800 -0.129750 0.000000 -v 0.438241 0.045372 -0.000000 -v -0.010750 -0.113834 0.000000 -v -0.145284 0.073334 -0.000000 -v -0.145256 -0.134263 0.000000 -v -0.025998 0.073334 -0.000000 -v -0.028811 -0.131707 0.000000 -v 0.004471 -0.093705 0.000000 -v -0.192182 -0.098774 0.000000 -v 0.438373 -0.025623 -0.000000 -v 0.489175 0.028118 -0.000000 -v 0.493179 -0.005666 -0.000000 -v 0.457343 -0.052215 0.000000 -v 0.487158 -0.049835 0.000000 -v 0.447422 -0.024231 -0.000000 -v 0.489644 -0.010979 -0.000000 -v 0.446970 0.041229 -0.000000 -v 0.488729 0.039392 -0.000000 -v 0.457414 0.071526 -0.000000 -v 0.487056 0.068886 -0.000000 -v 0.372582 0.058885 -0.000000 -v 0.372582 -0.048949 0.000000 -v 0.510470 0.002703 -0.000000 -v 0.510470 0.026017 -0.000000 -v 0.515740 0.008758 -0.000000 -v 0.515225 0.008032 -0.000000 -v 0.515740 0.014988 -0.000000 -v 0.515225 0.015781 -0.000000 -v 0.524880 0.008032 -0.000000 -v 0.524880 0.015781 -0.000000 -v 0.527347 0.011810 -0.000000 -v -0.077804 0.073334 -0.000000 -v -0.051901 0.073334 -0.000000 -v -0.051873 -0.134263 0.000000 -v -0.120025 -0.131743 0.012698 -v -0.089441 -0.131743 0.012647 -v -0.104733 -0.131743 0.012672 -v -0.120025 -0.134116 0.000000 -v -0.089441 -0.134116 0.000000 -v -0.096949 -0.133905 0.000000 -v -0.112517 -0.133905 0.000000 -v -0.110237 -0.131352 0.005504 -v -0.104733 -0.131352 0.007784 -v -0.099229 -0.131352 0.005504 -v -0.096949 -0.146402 0.000000 -v -0.112517 -0.146402 0.000000 -v -0.110237 -0.146402 0.005504 -v -0.104733 -0.146402 0.007784 -v -0.099229 -0.146402 0.005504 -v -0.096949 -0.309639 0.000000 -v -0.112517 -0.309639 0.000000 -v -0.110237 -0.309639 0.005504 -v -0.104733 -0.309639 0.007784 -v -0.099229 -0.309639 0.005504 -v -0.145706 -0.318985 0.005504 -v -0.145706 -0.324489 0.007784 -v -0.145706 -0.329993 0.005504 -v -0.145706 -0.332273 0.000000 -v -0.145706 -0.316706 0.000000 -v -0.115907 -0.316706 0.000000 -v -0.115907 -0.332273 0.000000 -v -0.115907 -0.329993 0.005504 -v -0.115907 -0.324489 0.007784 -v -0.115907 -0.318985 0.005504 -v -0.112981 -0.314476 0.000000 -v -0.101974 -0.325484 0.000000 -v -0.103586 -0.323872 0.005504 -v -0.107478 -0.319980 0.007784 -v -0.111369 -0.316088 0.005504 -v -0.077776 -0.133292 0.000000 -v -0.145706 -0.319804 0.004685 -v -0.145706 -0.324489 0.006626 -v -0.145706 -0.329175 0.004685 -v -0.145706 -0.331115 0.000000 -v -0.145706 -0.317863 0.000000 -v -0.120728 -0.330146 0.000000 -v -0.120728 -0.328489 0.004000 -v -0.120728 -0.324489 0.005656 -v -0.120728 -0.320490 0.004000 -v -0.120728 -0.318833 0.000000 -v -0.120728 -0.324489 0.000000 -v -0.102383 -0.109911 0.026878 -v -0.018593 -0.124361 0.000000 -v -0.146509 -0.110962 0.026891 -v -0.018918 -0.119800 0.023713 -v -0.176358 -0.112152 0.025424 -v -0.182451 -0.118212 0.000000 -v -0.074675 -0.109265 0.023799 -v -0.046854 -0.111511 0.023756 -v -0.106319 -0.101496 0.028531 -v -0.141797 -0.100168 0.029340 -v -0.107087 -0.103696 0.026878 -v -0.140874 -0.104992 0.026891 -v -0.014671 -0.119098 0.000000 -v -0.179464 -0.101651 0.027380 -v -0.187317 -0.109068 0.000000 -v -0.101694 -0.100142 0.027239 -v -0.147175 -0.101746 0.028116 -v -0.015169 -0.115125 0.024953 -v -0.073027 -0.098992 0.025039 -v -0.044185 -0.102430 0.024996 -v -0.105455 -0.102694 0.027239 -v -0.143547 -0.102580 0.028116 -v -0.106319 -0.101496 0.062227 -v -0.125329 -0.100168 0.062227 -v -0.107087 -0.103696 0.062227 -v -0.124406 -0.104992 0.062227 -v -0.105455 -0.102694 0.062227 -v -0.127079 -0.102580 0.062227 -v -0.107364 -0.101496 0.065167 -v -0.121148 -0.100168 0.065167 -v -0.108133 -0.103696 0.065167 -v -0.120226 -0.104992 0.065167 -v -0.106501 -0.102694 0.065167 -v -0.122898 -0.102580 0.065167 -v 0.012813 -0.073349 0.036122 -v -0.196426 -0.071466 0.034717 -v -0.203515 -0.084806 0.000000 -v -0.098092 -0.075120 0.034196 -v 0.014590 -0.083280 0.000000 -v -0.146207 -0.075843 0.034660 -v -0.019775 -0.084803 0.032963 -v -0.072104 -0.074173 0.033049 -v -0.045998 -0.076371 0.033006 -v -0.424131 -0.065797 0.000000 -v -0.424131 -0.046842 0.040035 -v -0.424487 0.002283 0.060537 -v -0.424487 0.045435 0.042433 -v -0.424487 0.071361 -0.000000 -vt 0.956699 0.719683 -vt 0.973082 0.719310 -vt 0.974494 0.728254 -vt 0.949748 0.704509 -vt 0.974991 0.711418 -vt 0.958181 0.693076 -vt 0.977042 0.704159 -vt 0.907825 0.773992 -vt 0.887056 0.783358 -vt 0.880780 0.755188 -vt 0.286455 0.752799 -vt 0.137715 0.743003 -vt 0.138655 0.698133 -vt 0.694869 0.800055 -vt 0.769701 0.787194 -vt 0.776890 0.824753 -vt 0.277870 0.810293 -vt 0.267395 0.851549 -vt 0.123009 0.829069 -vt 0.688444 0.648397 -vt 0.767177 0.648892 -vt 0.765769 0.689809 -vt 0.288114 0.704141 -vt 0.135808 0.648392 -vt 0.689264 0.697552 -vt 0.766204 0.742566 -vt 0.131898 0.789275 -vt 0.690402 0.744884 -vt 0.097617 0.777222 -vt 0.084045 0.812811 -vt 0.045082 0.796553 -vt 0.103543 0.736881 -vt 0.063335 0.765169 -vt 0.101905 0.699179 -vt 0.069372 0.730760 -vt 0.093869 0.656193 -vt 0.065156 0.700224 -vt 0.037224 0.728794 -vt 0.032491 0.746804 -vt 0.033494 0.713118 -vt 0.021201 0.695908 -vt 0.017826 0.760292 -vt 0.010998 0.727527 -vt 0.977171 0.704193 -vt 0.975703 0.734427 -vt 0.974615 0.728233 -vt 0.838588 0.769634 -vt 0.835263 0.690651 -vt 0.839009 0.659916 -vt 0.879313 0.668961 -vt 0.835369 0.732184 -vt 0.877743 0.698691 -vt 0.877323 0.725104 -vt 0.415659 0.754567 -vt 0.419670 0.813267 -vt 0.398655 0.813246 -vt 0.415931 0.705907 -vt 0.391538 0.705777 -vt 0.391906 0.656135 -vt 0.391122 0.754382 -vt 0.351927 0.812827 -vt 0.352421 0.705403 -vt 0.289522 0.654422 -vt 0.468309 0.867106 -vt 0.471717 0.863299 -vt 0.483180 0.882615 -vt 0.351716 0.754025 -vt 0.505857 0.754851 -vt 0.504829 0.705273 -vt 0.699604 0.838311 -vt 0.522669 0.854806 -vt 0.503774 0.655536 -vt 0.511306 0.814964 -vt 0.352497 0.879550 -vt 0.351096 0.899092 -vt 0.324099 0.895900 -vt 0.308155 0.883658 -vt 0.323932 0.864809 -vt 0.329413 0.877829 -vt 0.493037 0.837225 -vt 0.500877 0.868485 -vt 0.353163 0.655720 -vt 0.351389 0.862551 -vt 0.442095 0.863398 -vt 0.464902 0.870842 -vt 0.458778 0.877530 -vt 0.897456 0.701066 -vt 0.896868 0.721761 -vt 0.465002 0.754877 -vt 0.464844 0.705847 -vt 0.464449 0.656145 -vt 0.462247 0.814277 -vt 0.466982 0.838788 -vt 0.447123 0.847503 -vt 0.350750 0.829156 -vt 0.349573 0.845485 -vt 0.317535 0.847624 -vt 0.502172 0.826094 -vt 0.280974 0.860490 -vt 0.297702 0.828959 -vt 0.511773 0.861646 -vt 0.395896 0.828442 -vt 0.393138 0.843639 -vt 0.922858 0.260577 -vt 0.925930 0.259385 -vt 0.935654 0.293772 -vt 0.901593 0.674617 -vt 0.899437 0.749902 -vt 0.960525 0.746115 -vt 0.954794 0.735768 -vt 0.912682 0.680414 -vt 0.950788 0.720117 -vt 0.949700 0.718292 -vt 0.909608 0.719599 -vt 0.918396 0.308253 -vt 0.918484 0.307670 -vt 0.934245 0.293888 -vt 0.890558 0.291134 -vt 0.890558 0.296112 -vt 0.917233 0.766853 -vt 0.953478 0.749118 -vt 0.956504 0.750947 -vt 0.708158 0.132508 -vt 0.704332 0.132234 -vt 0.716412 0.089060 -vt 0.773619 0.132508 -vt 0.746105 0.089377 -vt 0.748250 0.086560 -vt 0.909786 0.723528 -vt 0.908195 0.721502 -vt 0.949739 0.722183 -vt 0.782891 0.117603 -vt 0.808955 0.119545 -vt 0.810904 0.121963 -vt 0.719849 0.091084 -vt 0.835681 0.076855 -vt 0.838224 0.078280 -vt 0.771670 0.076855 -vt 0.779742 0.119304 -vt 0.947052 0.231319 -vt 0.942942 0.232366 -vt 0.937691 0.203709 -vt 0.910529 0.677094 -vt 0.948600 0.686253 -vt 0.915767 0.202873 -vt 0.938912 0.202873 -vt 0.902311 0.229152 -vt 0.916150 0.203292 -vt 0.898615 0.227897 -vt 0.847021 0.801607 -vt 0.973236 0.719313 -vt 0.980624 0.721996 -vt 0.975133 0.711453 -vt 0.981902 0.717750 -vt 0.983569 0.714759 -vt 0.992567 0.719520 -vt 0.980571 0.726412 -vt 0.989793 0.725888 -vt 0.990587 0.728388 -vt 0.981204 0.729516 -vt 0.993796 0.724584 -vt 0.989802 0.723612 -vt 0.990759 0.721624 -vt 0.420067 0.828054 -vt 0.420464 0.842841 -vt 0.443942 0.830522 -vt 0.391734 0.861782 -vt 0.417316 0.861560 -vt 0.414702 0.879465 -vt 0.438011 0.878742 -vt 0.463775 0.895049 -vt 0.439829 0.898990 -vt 0.440295 0.754740 -vt 0.440364 0.705938 -vt 0.440263 0.656268 -vt 0.416082 0.656257 -vt 0.440761 0.813541 -vt 0.403951 0.888257 -vt 0.415290 0.900009 -vt 0.390625 0.879851 -vt 0.374799 0.900133 -vt 0.375264 0.888040 -vt 0.384354 0.894908 -vt 0.389584 0.888211 -vt 0.389551 0.892816 -vt 0.394721 0.894985 -vt 0.404220 0.900399 -vt 0.397123 0.900623 -vt 0.201431 0.018740 -vt 0.204459 0.032820 -vt 0.198901 0.034006 -vt 0.185297 0.024764 -vt 0.190322 0.021174 -vt 0.193388 0.035191 -vt 0.207523 0.019904 -vt 0.210089 0.031604 -vt 0.195868 0.019959 -vt 0.242781 0.183629 -vt 0.237075 0.184535 -vt 0.231698 0.186019 -vt 0.226252 0.187508 -vt 0.220586 0.188371 -vt 0.227975 0.203945 -vt 0.232410 0.196081 -vt 0.237446 0.197744 -vt 0.231540 0.208340 -vt 0.242781 0.199409 -vt 0.213511 0.225097 -vt 0.210377 0.221512 -vt 0.235589 0.212241 -vt 0.215991 0.229265 -vt 0.219927 0.195976 -vt 0.221003 0.192874 -vt 0.226787 0.194301 -vt 0.206719 0.218153 -vt 0.224298 0.199339 -vt 0.202150 0.215354 -vt 0.206074 0.218974 -vt 0.209672 0.222170 -vt 0.215115 0.229392 -vt 0.212790 0.225598 -vt 0.140139 0.057135 -vt 0.157845 0.057141 -vt 0.152655 0.069659 -vt 0.198295 0.243393 -vt 0.152664 0.044619 -vt 0.195828 0.240517 -vt 0.193472 0.238001 -vt 0.190979 0.235622 -vt 0.188364 0.233395 -vt 0.874095 0.050219 -vt 0.875908 0.043938 -vt 0.878762 0.051906 -vt 0.418842 0.852187 -vt 0.444506 0.855530 -vt 0.392448 0.852757 -vt 0.350516 0.854102 -vt 0.301302 0.876545 -vt 0.320771 0.856514 -vt 0.473809 0.889187 -vt 0.920749 0.053099 -vt 0.907153 0.084830 -vt 0.895681 0.081984 -vt 0.922440 0.043939 -vt 0.958282 0.098639 -vt 0.954459 0.092451 -vt 0.956155 0.091536 -vt 0.913736 0.098639 -vt 0.918947 0.092696 -vt 0.923698 0.049927 -vt 0.922612 0.052967 -vt 0.915945 0.090531 -vt 0.933466 0.059802 -vt 0.294553 0.869430 -vt 0.912536 0.090359 -vt 0.478530 0.885930 -vt 0.936616 0.060625 -vt 0.937370 0.056797 -vt 0.908205 0.085437 -vt 0.906287 0.087309 -vt 0.949638 0.059539 -vt 0.893472 0.082637 -vt 0.896349 0.085428 -vt 0.898089 0.084370 -vt 0.905592 0.086379 -vt 0.948228 0.057363 -vt 0.939888 0.058329 -vt 0.949667 0.056538 -vt 0.051929 0.663994 -vt 0.975810 0.734403 -vt 0.916076 0.770760 -vt 0.951627 0.684121 -vt 0.381864 0.900481 -vt 0.187840 0.036396 -vt 0.201962 0.216530 -vt 0.875817 0.052307 -vt 0.951387 0.059099 -vt 0.776477 0.130857 -vt 0.768235 0.077013 -vt 0.140133 0.074841 -vt 0.140145 0.039428 -vt 0.960070 0.090264 -vn 0.551200 0.039400 -0.833400 -vn 0.950700 0.181400 0.251500 -vn 0.478000 -0.752000 0.453900 -vn 0.367000 0.671900 -0.643200 -vn 0.274600 0.846900 0.455200 -vn 0.766600 0.642000 0.000000 -vn 0.064600 0.655500 0.752400 -vn 0.258500 -0.966000 0.000000 -vn 0.318600 -0.947900 0.000000 -vn 0.240900 -0.665100 -0.706800 -vn -0.000700 -0.014900 -0.999900 -vn -0.042200 -0.043000 -0.998200 -vn -0.018500 0.642400 -0.766100 -vn 0.030900 -0.736000 -0.676200 -vn 0.141900 -0.694100 -0.705700 -vn 0.154300 -0.988000 0.000000 -vn -0.095700 -0.641800 -0.760800 -vn -0.248600 -0.968600 0.000000 -vn -0.080900 -0.996700 0.000000 -vn -0.012600 0.999900 0.000000 -vn 0.091000 0.995800 0.000000 -vn 0.069900 0.636500 -0.768100 -vn 0.001200 0.645100 -0.764100 -vn -0.016700 0.999800 0.000000 -vn 0.013600 0.626200 -0.779500 -vn 0.102100 -0.035900 -0.994100 -vn -0.044300 -0.706400 -0.706400 -vn 0.043600 -0.001400 -0.999000 -vn -0.145300 -0.709100 -0.689900 -vn -0.206500 -0.978400 0.000000 -vn -0.457000 -0.889400 0.000000 -vn -0.098200 0.004400 -0.995100 -vn -0.403100 -0.630100 -0.663600 -vn -0.040000 0.649700 -0.759100 -vn -0.355300 0.025400 -0.934400 -vn -0.038500 0.999200 0.000000 -vn -0.335300 0.626100 -0.704000 -vn -0.793800 0.020200 -0.607900 -vn -0.795500 -0.449000 -0.406800 -vn -0.797000 0.417400 -0.436500 -vn -0.788900 0.614500 0.000000 -vn -0.771500 -0.636200 0.000000 -vn -0.999900 0.011200 0.000000 -vn 0.424100 0.197000 0.883900 -vn 0.333300 -0.680300 0.652700 -vn 0.619300 -0.491800 0.612000 -vn 0.243400 -0.662900 -0.708000 -vn 0.154900 0.697800 -0.699300 -vn 0.161400 0.986900 0.000000 -vn 0.225000 0.974300 0.000000 -vn 0.154600 -0.005400 -0.987900 -vn 0.166500 0.672400 -0.721200 -vn 0.132100 0.028700 -0.990800 -vn 0.001900 -0.005700 -1.000000 -vn 0.005800 -0.410100 -0.912000 -vn 0.010400 -0.381400 -0.924300 -vn 0.001200 0.643900 -0.765100 -vn 0.001500 0.644200 -0.764800 -vn 0.000200 1.000000 0.000000 -vn 0.001500 -0.006100 -1.000000 -vn -0.004400 -0.358000 -0.933700 -vn 0.001600 0.644500 -0.764500 -vn 0.000300 1.000000 0.000000 -vn 0.444900 -0.536900 -0.716800 -vn 0.453900 -0.563800 -0.690000 -vn 0.797300 -0.603500 0.000000 -vn 0.002300 -0.007600 -0.999900 -vn 0.003800 -0.010800 -0.999900 -vn 0.001600 0.643200 -0.765600 -vn 0.033600 -0.999400 0.000000 -vn 0.435300 -0.900300 0.000000 -vn 0.000400 1.000000 0.000000 -vn 0.157500 -0.582400 -0.797500 -vn -0.065100 -0.732800 -0.677300 -vn -0.103200 -0.994600 0.000000 -vn -0.423100 -0.906000 0.000000 -vn -0.811000 -0.585000 0.000000 -vn -0.528100 -0.388400 -0.755100 -vn -0.377800 -0.687000 -0.620700 -vn 0.508300 -0.510500 -0.693500 -vn 0.759900 -0.650000 0.000000 -vn -0.002900 -0.215900 -0.976400 -vn -0.015900 -0.138400 -0.990200 -vn 0.402800 -0.612300 -0.680300 -vn 0.204100 -0.722500 -0.660500 -vn 0.210700 0.706700 -0.675400 -vn 0.192100 0.068700 -0.978900 -vn 0.002300 -0.007700 -0.999900 -vn 0.001700 0.643500 -0.765400 -vn -0.011000 -0.346500 -0.938000 -vn -0.076300 -0.285500 -0.955300 -vn -0.081100 -0.263600 -0.961200 -vn 0.001800 -0.303300 -0.952900 -vn -0.013700 -0.201500 -0.979400 -vn -0.394000 -0.364600 -0.843700 -vn 0.501500 -0.456800 -0.734700 -vn -0.604900 -0.796200 0.000000 -vn -0.275900 -0.577100 -0.768600 -vn 0.743800 -0.668400 0.000000 -vn 0.037600 -0.357100 -0.933300 -vn 0.070100 -0.224100 -0.972000 -vn 0.640400 -0.441500 -0.628400 -vn 0.940400 -0.340000 0.000000 -vn 0.796300 -0.604800 0.000000 -vn 0.301100 0.953600 0.000000 -vn 0.261800 -0.681400 -0.683400 -vn 0.721400 -0.692500 0.000000 -vn 0.420600 -0.637800 -0.645100 -vn -0.150900 0.650100 -0.744700 -vn 0.873700 0.014200 -0.486300 -vn 0.534800 0.700100 -0.473000 -vn -0.033600 0.716400 -0.696900 -vn -0.682100 -0.731200 0.000000 -vn -0.233300 -0.723400 -0.649700 -vn 0.286900 -0.622500 -0.728100 -vn 0.078600 -0.670900 -0.737400 -vn -0.427200 -0.904100 0.000000 -vn -0.021400 -0.660700 -0.750400 -vn -0.118800 0.000200 -0.992900 -vn -0.682600 0.029300 -0.730200 -vn 0.556800 -0.672800 -0.487000 -vn 0.412400 -0.699600 -0.583500 -vn 0.789700 0.025000 -0.612900 -vn -0.189600 0.676200 -0.711900 -vn 0.391100 0.710400 -0.585100 -vn -0.212000 -0.674900 -0.706800 -vn 0.998400 0.056000 0.000000 -vn 0.591500 0.244800 -0.768200 -vn 0.323400 0.606300 -0.726400 -vn -0.134800 0.990900 0.000000 -vn -0.682200 0.731100 0.000000 -vn 0.818200 0.574900 0.000000 -vn -0.295800 0.710100 -0.638900 -vn 0.297300 -0.954800 0.000000 -vn 0.668300 0.047000 0.742400 -vn 0.479600 -0.078300 -0.874000 -vn 0.697300 0.326500 0.638100 -vn 0.544300 0.656900 -0.521700 -vn 0.586300 0.810100 0.000000 -vn 0.412900 0.910700 0.000000 -vn 0.383600 -0.731600 -0.563600 -vn 0.496300 -0.690100 -0.526700 -vn 0.404600 -0.914500 0.000000 -vn 0.429300 -0.903100 0.000000 -vn 0.999900 -0.010500 0.000000 -vn 0.482200 -0.006100 -0.876000 -vn 0.501100 0.679900 -0.535300 -vn 0.009900 -0.410200 -0.911900 -vn 0.019500 -0.276200 -0.960900 -vn -0.056800 -0.368300 -0.927900 -vn 0.033000 -0.154300 -0.987500 -vn 0.046800 -0.123400 -0.991200 -vn 0.035700 -0.676900 -0.735200 -vn 0.029300 -0.675000 -0.737200 -vn 0.345600 -0.938400 0.000000 -vn 0.036000 -0.999300 0.000000 -vn 0.002200 -0.006800 -1.000000 -vn 0.001200 0.643800 -0.765200 -vn -0.000800 -0.391100 -0.920300 -vn 0.000600 -0.970800 -0.239800 -vn 0.035200 -0.999400 0.000000 -vn -0.005800 -0.680300 -0.732900 -vn 0.065700 -0.997800 0.000000 -vn 0.022600 -0.964400 -0.263300 -vn -0.310500 -0.819400 -0.481800 -vn 0.000300 -0.986300 -0.164700 -vn 0.000000 -0.833700 -0.552200 -vn 0.310600 -0.819400 -0.481800 -vn -0.027400 -0.999600 0.000000 -vn 0.708400 -0.705800 0.000000 -vn 0.707100 0.000000 -0.707100 -vn 0.000000 0.000000 -1.000000 -vn -0.708400 -0.705800 0.000000 -vn -0.707100 0.000000 -0.707100 -vn 1.000000 0.000000 0.000000 -vn 0.989500 -0.144100 0.000000 -vn 0.720100 -0.106400 -0.685600 -vn 0.027600 -0.011700 -0.999500 -vn -0.700800 0.053300 -0.711400 -vn -0.998800 0.048400 0.000000 -vn 0.026600 -0.056900 -0.998000 -vn 0.077600 -0.054200 -0.995500 -vn 0.573400 -0.484400 -0.660700 -vn 0.169300 -0.718400 -0.674700 -vn 0.754500 -0.656200 0.000000 -vn -0.630200 -0.549000 -0.549000 -vn -0.630200 0.000000 -0.776400 -vn 0.213600 -0.976900 0.000000 -vn -0.630200 -0.776400 0.000000 -vn -0.324100 0.946000 0.000000 -vn -0.876400 0.481600 0.000000 -vn -0.548000 0.361400 -0.754300 -vn -0.630200 0.549000 -0.549000 -vn -0.187000 0.650000 -0.736600 -vn -0.630200 0.776400 0.000000 -vn -0.814800 -0.409900 0.409900 -vn -0.814800 0.000000 0.579700 -vn -0.814800 0.579700 0.000000 -vn -0.814800 0.409900 0.409900 -vn -1.000000 0.000000 0.000000 -vn -0.644800 0.000000 0.764400 -vn -0.644800 0.540500 0.540500 -vn -0.644800 0.764400 0.000000 -vn -0.644800 -0.540500 0.540500 -vn -0.644800 -0.764400 0.000000 -vn -0.068200 -0.162600 -0.984300 -vn -0.362500 0.291100 -0.885300 -vn 0.035400 -0.126300 -0.991300 -vn -0.031500 -0.127900 -0.991300 -vn 0.167000 -0.134100 -0.976800 -vn -0.900300 -0.435100 0.000000 -vn -0.570800 -0.245100 -0.783600 -vn 0.681800 -0.731600 0.000000 -vn 0.535100 0.423900 -0.730800 -vn 0.519400 0.849600 -0.091400 -vn -0.386500 0.832800 -0.396300 -vn 0.124700 -0.623100 -0.772100 -vn 0.388300 -0.399500 -0.830400 -vn -0.098800 -0.532300 -0.840800 -vn -0.283300 -0.355800 -0.890500 -vn -0.796700 -0.099400 -0.596100 -vn -0.861300 -0.508000 0.000000 -vn 0.799100 -0.601200 0.000000 -vn -0.322400 -0.882300 -0.343000 -vn -0.413900 -0.075400 -0.907200 -vn 0.970600 -0.183300 -0.156000 -vn 0.698000 -0.169200 -0.695800 -vn 0.334100 -0.940700 -0.058700 -vn -0.097300 0.732200 -0.674100 -vn 0.311500 0.663800 -0.679900 -vn 0.200000 -0.689000 -0.696600 -vn -0.062100 -0.741600 -0.668000 -vn 0.223600 -0.351800 0.909000 -vn 0.192200 0.036700 0.980700 -vn 0.551200 0.039400 0.833400 -vn 0.120200 0.370700 0.920900 -vn 0.261800 -0.681400 0.683400 -vn 0.240900 -0.665100 0.706800 -vn -0.018500 0.642400 0.766100 -vn -0.042200 -0.043000 0.998200 -vn -0.000700 -0.014900 0.999900 -vn 0.141900 -0.694100 0.705700 -vn 0.030900 -0.736000 0.676200 -vn -0.095700 -0.641800 0.760800 -vn -0.044300 -0.706400 0.706400 -vn 0.069900 0.636500 0.768100 -vn 0.001200 0.645100 0.764100 -vn 0.102100 -0.035900 0.994100 -vn 0.013600 0.626200 0.779500 -vn 0.043600 -0.001400 0.999000 -vn -0.145300 -0.709100 0.689900 -vn -0.403100 -0.630100 0.663600 -vn -0.098200 0.004400 0.995100 -vn -0.355300 0.025400 0.934400 -vn -0.040000 0.649700 0.759100 -vn -0.335300 0.626100 0.704000 -vn -0.353900 0.935300 0.000000 -vn -0.797000 0.417400 0.436500 -vn -0.793800 0.020200 0.607900 -vn -0.795500 -0.449000 0.406800 -vn 0.538700 0.252200 0.803900 -vn 0.404600 -0.361000 0.840200 -vn 0.403300 -0.320300 0.857100 -vn 0.243400 -0.662900 0.708000 -vn 0.154900 0.697800 0.699300 -vn 0.166500 0.672400 0.721200 -vn 0.154600 -0.005400 0.987900 -vn 0.132100 0.028700 0.990800 -vn 0.001900 -0.005700 1.000000 -vn 0.001500 -0.006100 1.000000 -vn 0.010400 -0.381400 0.924300 -vn 0.001500 0.644200 0.764800 -vn 0.001200 0.643900 0.765100 -vn -0.004400 -0.358000 0.933700 -vn 0.001600 0.644500 0.764500 -vn 0.453900 -0.563800 0.690000 -vn 0.444900 -0.536900 0.716800 -vn 0.002300 -0.007600 0.999900 -vn 0.001600 0.643200 0.765600 -vn 0.003800 -0.010800 0.999900 -vn 0.157500 -0.582400 0.797500 -vn -0.065100 -0.732800 0.677300 -vn -0.377800 -0.687000 0.620700 -vn 0.508300 -0.510500 0.693500 -vn -0.002900 -0.215900 0.976400 -vn -0.015900 -0.138400 0.990200 -vn 0.029300 -0.675000 0.737200 -vn 0.204100 -0.722500 0.660500 -vn 0.192100 0.068700 0.978900 -vn 0.210700 0.706700 0.675400 -vn 0.001700 0.643500 0.765400 -vn 0.002300 -0.007700 0.999900 -vn -0.011000 -0.346500 0.938000 -vn -0.081100 -0.263600 0.961200 -vn -0.076300 -0.285500 0.955300 -vn -0.394000 -0.364600 0.843700 -vn -0.013700 -0.201500 0.979400 -vn 0.001800 -0.303300 0.952900 -vn 0.070100 -0.224100 0.972000 -vn 0.640400 -0.441500 0.628400 -vn 0.286900 -0.622500 0.728100 -vn 0.420600 -0.637800 0.645100 -vn 0.367000 0.671900 0.643200 -vn 0.591500 0.244800 0.768200 -vn -0.150900 0.650100 0.744700 -vn 0.534800 0.700100 0.473000 -vn 0.873700 0.014200 0.486300 -vn -0.118800 0.000200 0.992900 -vn -0.033600 0.716400 0.696900 -vn -0.233300 -0.723400 0.649700 -vn 0.078600 -0.670900 0.737400 -vn -0.021400 -0.660700 0.750400 -vn -0.212000 -0.674900 0.706800 -vn -0.682600 0.029300 0.730200 -vn 0.789700 0.025000 0.612900 -vn 0.412400 -0.699600 0.583500 -vn 0.556800 -0.672800 0.487000 -vn 0.391100 0.710400 0.585100 -vn -0.189600 0.676200 0.711900 -vn 0.323400 0.606300 0.726500 -vn -0.295800 0.710100 0.638900 -vn 0.383600 -0.731600 0.563600 -vn 0.479600 -0.078300 0.874000 -vn 0.363500 0.025600 0.931200 -vn 0.544300 0.656900 0.521700 -vn 0.501100 0.679900 0.535300 -vn 0.496300 -0.690100 0.526700 -vn 0.482200 -0.006100 0.876000 -vn 0.037600 -0.357100 0.933300 -vn 0.019500 -0.276200 0.960900 -vn -0.056800 -0.368300 0.927900 -vn 0.033000 -0.154300 0.987500 -vn -0.005800 -0.680300 0.732900 -vn 0.035700 -0.676900 0.735200 -vn 0.046800 -0.123400 0.991200 -vn 0.001200 0.643800 0.765200 -vn 0.002200 -0.006800 1.000000 -vn -0.000800 -0.391100 0.920300 -vn 0.005800 -0.410100 0.912000 -vn 0.000600 -0.970800 0.239800 -vn 0.000300 -0.986300 0.164700 -vn -0.310500 -0.819400 0.481800 -vn 0.000000 -0.833700 0.552200 -vn 0.310600 -0.819400 0.481800 -vn 0.000000 0.000000 1.000000 -vn 0.707100 0.000000 0.707100 -vn -0.707100 0.000000 0.707100 -vn 0.720100 -0.106400 0.685600 -vn -0.700800 0.053300 0.711400 -vn 0.027600 -0.011700 0.999500 -vn 0.573400 -0.484400 0.660700 -vn 0.077600 -0.054200 0.995500 -vn 0.026600 -0.056900 0.998000 -vn 0.169300 -0.718400 0.674700 -vn -0.630200 0.000000 0.776400 -vn -0.630200 -0.549000 0.549000 -vn -0.548000 0.361400 0.754300 -vn -0.630200 0.549000 0.549000 -vn -0.187000 0.650000 0.736600 -vn 0.022600 -0.964400 0.263300 -vn -0.814800 -0.579700 0.000000 -vn -0.814800 -0.409900 -0.409900 -vn -0.814800 0.000000 -0.579700 -vn -0.814800 0.409900 -0.409900 -vn -0.644800 0.540500 -0.540500 -vn -0.644800 0.000000 -0.764400 -vn -0.644800 -0.540500 -0.540500 -vn -0.068200 -0.162600 0.984300 -vn -0.283300 -0.355800 0.890500 -vn -0.362500 0.291100 0.885300 -vn 0.035400 -0.126300 0.991300 -vn 0.167000 -0.134100 0.976800 -vn -0.031500 -0.127900 0.991300 -vn 0.402800 -0.612300 0.680300 -vn -0.528100 -0.388400 0.755100 -vn -0.386500 0.832800 0.396300 -vn 0.519400 0.849600 0.091400 -vn 0.535100 0.423900 0.730800 -vn 0.388300 -0.399500 0.830400 -vn 0.124700 -0.623100 0.772100 -vn -0.098800 -0.532300 0.840800 -vn -0.322400 -0.882300 0.343000 -vn -0.796700 -0.099400 0.596100 -vn -0.570800 -0.245100 0.783600 -vn -0.062100 -0.741600 0.668000 -vn -0.413900 -0.075400 0.907200 -vn 0.311500 0.663800 0.679900 -vn 0.698000 -0.169200 0.695800 -vn 0.970600 -0.183300 0.156000 -vn 0.334100 -0.940700 0.058700 -vn -0.097300 0.732200 0.674100 -vn 0.200000 -0.689000 0.696600 -vn 0.009900 -0.410200 0.911900 -vn 0.501500 -0.456800 0.734700 -vn -0.275900 -0.577100 0.768600 -usemtl Material -s 1 -f 50/1/1 5/2/2 4/3/3 -f 50/1/1 49/4/4 7/5/5 -f 284/6/6 261/7/7 7/5/5 -f 283/8/8 267/9/9 21/10/10 -f 28/11/11 1/12/12 6/13/13 -f 10/14/14 9/15/15 258/16/16 -f 26/17/17 270/18/18 256/19/19 -f 255/20/20 254/21/21 8/22/22 -f 27/23/23 6/13/13 259/24/24 -f 2/25/25 8/22/22 12/26/26 -f 26/17/17 3/27/27 1/12/12 -f 11/28/28 12/26/26 9/15/15 -f 158/29/29 398/30/30 262/31/31 -f 159/32/32 158/29/29 14/33/33 -f 160/34/34 159/32/32 13/35/35 -f 402/36/36 160/34/34 15/37/37 -f 15/37/37 13/35/35 16/38/38 -f 13/35/35 14/33/33 17/39/39 -f 15/37/37 18/40/40 265/41/41 -f 14/33/33 262/31/31 264/42/42 -f 18/40/40 16/38/38 266/43/43 -f 17/39/39 264/42/42 266/43/43 -f 7/5/5 261/7/7 297/44/44 -f 260/45/45 4/3/3 75/46/46 -f 74/47/47 21/10/10 267/9/9 -f 72/48/48 294/49/49 268/50/50 -f 73/51/51 72/48/48 19/52/52 -f 73/51/51 20/53/53 21/10/10 -f 90/54/54 85/55/55 23/56/56 -f 88/57/57 22/58/58 269/59/59 -f 90/54/54 25/60/60 22/58/58 -f 35/61/61 26/17/17 28/11/11 -f 24/62/62 27/23/23 271/63/63 -f 134/64/64 45/65/65 276/66/66 -f 34/67/67 28/11/11 27/23/23 -f 11/28/28 30/68/68 29/69/69 -f 10/14/14 257/70/70 273/71/71 -f 2/25/25 29/69/69 272/72/72 -f 11/28/28 10/14/14 31/73/73 -f 36/74/74 278/75/75 274/76/76 -f 360/77/77 124/78/78 33/79/79 -f 45/65/65 42/80/80 281/81/81 -f 25/60/60 34/67/67 24/62/62 -f 22/58/58 24/62/62 277/82/72 -f 25/60/60 23/56/56 35/61/61 -f 122/83/82 36/74/74 33/79/79 -f 126/84/83 123/85/84 40/86/85 -f 19/52/52 48/87/86 47/88/87 -f 30/68/68 39/89/88 38/90/89 -f 29/69/69 38/90/89 279/91/72 -f 30/68/68 31/73/73 37/92/90 -f 155/93/91 45/65/65 92/94/92 -f 154/95/93 44/96/94 43/97/95 -f 155/93/91 151/98/96 42/80/80 -f 391/99/97 152/100/98 43/97/95 -f 393/101/99 281/81/81 42/80/80 -f 154/95/93 153/102/100 41/103/101 -f 54/104/102 289/105/103 287/106/104 -f 19/52/52 268/50/50 275/107/105 -f 20/53/53 47/88/87 46/108/106 -f 260/45/45 285/109/107 51/110/108 -f 49/4/4 48/87/86 68/111/109 -f 50/1/1 60/112/110 59/113/111 -f 47/88/87 48/87/86 58/114/112 -f 286/115/113 52/116/114 53/117/115 -f 55/118/116 54/104/102 53/117/115 -f 288/119/117 55/118/116 52/116/114 -f 283/8/8 46/108/106 55/120/116 -f 51/110/108 54/121/102 55/120/116 -f 285/109/107 289/122/103 54/121/102 -f 56/123/118 57/124/119 63/125/120 -f 61/126/121 67/127/122 66/128/123 -f 51/110/108 46/108/106 56/129/118 -f 49/4/4 59/113/111 58/114/112 -f 47/88/87 57/130/119 56/129/118 -f 50/1/1 51/110/108 61/131/121 -f 64/132/124 65/133/125 66/134/123 -f 62/135/126 63/125/120 66/128/123 -f 56/123/118 62/135/126 67/127/122 -f 59/136/111 60/137/110 66/134/123 -f 58/138/112 59/136/111 65/133/125 -f 58/138/112 64/132/124 63/139/120 -f 291/140/127 69/141/128 71/142/129 -f 48/87/86 275/107/105 290/143/130 -f 284/6/6 49/4/4 69/144/128 -f 292/145/131 293/146/132 71/142/129 -f 69/141/128 68/147/109 70/148/133 -f 68/147/109 290/149/130 292/145/131 -f 9/15/15 74/47/47 295/150/134 -f 8/22/22 72/48/48 73/51/51 -f 12/26/26 73/51/51 74/47/47 -f 294/49/49 72/48/48 8/22/22 -f 75/46/46 76/151/135 80/152/136 -f 76/151/135 77/153/137 81/154/138 -f 5/2/2 7/5/5 77/153/137 -f 4/3/3 5/2/2 76/151/135 -f 81/154/138 301/155/139 303/156/140 -f 79/157/141 78/158/142 302/159/143 -f 75/46/46 79/157/141 299/160/144 -f 77/153/137 297/44/44 301/155/139 -f 304/161/145 302/159/143 78/158/142 -f 304/161/145 82/162/146 83/163/147 -f 80/152/136 81/154/138 83/163/147 -f 79/157/141 80/152/136 82/162/146 -f 153/102/100 156/164/148 93/165/149 -f 157/166/150 92/94/92 93/165/149 -f 121/167/151 125/168/152 87/169/153 -f 125/168/152 126/84/83 86/170/154 -f 280/171/155 307/172/156 86/170/154 -f 39/89/88 91/173/157 89/174/158 -f 91/173/157 90/54/54 88/57/57 -f 38/90/89 89/174/158 306/175/59 -f 89/174/158 88/57/57 305/176/59 -f 37/92/90 84/177/159 91/173/157 -f 91/173/157 84/177/159 85/55/55 -f 95/178/160 87/169/153 343/179/161 -f 32/180/162 87/169/153 95/178/160 -f 86/170/154 307/172/156 343/179/161 -f 311/181/163 94/182/164 97/183/165 -f 96/184/166 98/185/167 97/183/165 -f 96/184/166 95/178/160 99/186/168 -f 312/187/169 313/188/170 99/186/168 -f 99/189/168 102/190/171 101/191/172 -f 314/192/173 97/193/165 100/194/174 -f 313/195/170 318/196/175 102/190/171 -f 98/197/167 101/191/172 100/194/174 -f 318/196/175 323/198/176 105/199/177 -f 101/191/172 104/200/178 103/201/179 -f 101/191/172 102/190/171 105/199/177 -f 100/194/174 103/201/179 324/202/180 -f 110/203/181 113/204/182 112/205/183 -f 109/206/184 112/205/183 339/207/185 -f 109/206/184 108/208/186 107/209/187 -f 334/210/188 331/211/189 108/208/186 -f 333/212/190 338/213/191 114/214/192 -f 110/203/181 107/209/187 106/215/193 -f 111/216/194 106/215/193 332/217/195 -f 111/216/194 114/214/192 113/204/182 -f 103/201/179 114/214/192 338/213/191 -f 104/200/178 113/204/182 114/214/192 -f 105/199/177 112/205/183 113/204/182 -f 323/198/176 339/207/185 112/205/183 -f 94/182/164 311/181/163 278/75/75 -f 32/180/162 96/184/166 94/182/164 -f 332/217/195 106/215/193 115/218/196 -f 106/215/193 107/209/187 116/219/197 -f 331/211/189 347/220/198 117/221/199 -f 108/208/186 117/221/199 116/219/197 -f 354/222/200 119/223/201 118/224/202 -f 117/221/199 347/220/198 349/225/203 -f 120/226/204 119/223/201 354/222/200 -f 117/221/199 118/227/202 119/228/201 -f 116/219/197 119/228/201 120/229/204 -f 115/218/196 120/229/204 353/230/205 -f 133/231/206 44/232/94 128/233/207 -f 32/180/162 36/74/74 122/83/82 -f 135/234/208 136/235/209 126/84/83 -f 132/236/210 135/234/208 125/168/152 -f 136/235/209 134/64/64 123/85/84 -f 133/237/206 122/83/82 124/78/78 -f 369/238/211 131/239/212 124/78/78 -f 40/86/85 123/85/84 356/240/213 -f 127/241/214 139/242/215 140/243/216 -f 41/244/101 127/241/214 128/233/207 -f 121/245/151 129/246/217 137/247/218 -f 121/245/151 122/248/82 130/249/219 -f 132/250/210 137/251/218 127/241/214 -f 130/249/219 138/252/220 144/253/221 -f 282/254/222 43/97/95 131/239/212 -f 44/96/94 133/237/206 131/239/212 -f 92/94/92 45/65/65 134/64/64 -f 41/103/101 93/165/149 135/234/208 -f 93/165/149 92/94/92 136/235/209 -f 122/248/82 133/255/206 138/252/220 -f 123/85/84 134/64/64 367/256/223 -f 142/257/224 144/253/221 150/258/225 -f 139/242/215 143/259/226 149/260/227 -f 127/241/214 137/251/218 143/259/226 -f 129/246/217 130/249/219 142/257/224 -f 137/247/218 129/246/217 141/261/228 -f 128/233/207 140/243/216 144/262/221 -f 150/263/225 146/264/229 145/265/230 -f 147/266/231 148/267/232 150/258/225 -f 139/242/215 145/265/230 146/264/229 -f 140/243/216 146/264/229 150/263/225 -f 141/261/228 142/257/224 148/267/232 -f 141/261/228 147/266/231 149/268/227 -f 84/177/159 157/166/150 156/164/148 -f 23/56/56 85/55/55 156/164/148 -f 35/61/61 23/56/56 153/102/100 -f 273/71/71 393/101/99 151/98/96 -f 270/18/18 26/17/17 152/100/98 -f 37/92/90 31/73/73 151/98/96 -f 35/61/61 154/95/93 152/100/98 -f 37/92/90 155/93/91 157/166/150 -f 259/24/24 6/13/13 160/34/34 -f 6/13/13 1/12/12 159/32/32 -f 1/12/12 3/27/27 158/29/29 -f 3/27/27 256/19/19 398/30/30 -f 164/3/233 165/2/234 210/1/235 -f 210/1/235 165/2/234 167/5/236 -f 167/5/236 261/7/7 284/6/6 -f 283/8/8 206/108/237 181/10/238 -f 166/13/239 161/12/240 188/11/241 -f 258/16/16 169/15/242 170/14/243 -f 186/17/244 163/27/245 256/19/19 -f 168/22/246 254/21/21 255/20/20 -f 259/24/24 166/13/239 187/23/247 -f 172/26/248 168/22/246 162/25/249 -f 161/12/240 163/27/245 186/17/244 -f 169/15/242 172/26/248 171/28/250 -f 399/29/251 174/33/252 262/31/31 -f 400/32/253 173/35/254 174/33/252 -f 401/34/255 175/37/256 173/35/254 -f 402/36/36 263/269/257 175/37/256 -f 175/37/256 178/40/258 176/38/259 -f 173/35/254 176/38/259 177/39/260 -f 265/41/41 178/40/258 175/37/256 -f 174/33/252 177/39/260 264/42/42 -f 178/40/258 265/41/41 266/43/43 -f 266/43/43 264/42/42 177/39/260 -f 167/5/236 237/153/261 297/44/44 -f 260/45/45 296/270/262 235/46/263 -f 267/9/9 181/10/238 234/47/264 -f 232/48/265 179/52/266 268/50/50 -f 233/51/267 180/53/268 179/52/266 -f 181/10/238 180/53/268 233/51/267 -f 250/54/269 185/60/270 183/56/271 -f 269/59/59 182/58/272 248/57/273 -f 182/58/272 185/60/270 250/54/269 -f 188/11/241 186/17/244 195/61/274 -f 271/63/63 187/23/247 184/62/275 -f 276/66/66 205/65/276 372/64/277 -f 187/23/247 188/11/241 194/67/278 -f 189/69/279 190/68/280 171/28/250 -f 170/14/243 191/73/281 273/71/71 -f 272/72/72 189/69/279 162/25/249 -f 171/28/250 190/68/280 191/73/281 -f 196/74/282 193/79/283 274/76/76 -f 360/77/77 274/76/76 193/79/283 -f 281/81/81 202/80/284 205/65/276 -f 184/62/275 194/67/278 185/60/270 -f 277/82/72 184/62/275 182/58/272 -f 185/60/270 194/67/278 195/61/274 -f 193/79/283 196/74/282 357/83/285 -f 362/84/286 246/170/287 200/86/288 -f 207/88/289 208/87/290 179/52/266 -f 198/90/291 199/89/292 190/68/280 -f 279/91/72 198/90/291 189/69/279 -f 190/68/280 199/89/292 197/92/293 -f 252/94/294 205/65/276 395/93/295 -f 203/97/296 204/96/297 394/95/298 -f 395/93/295 205/65/276 202/80/284 -f 391/99/97 282/254/222 203/97/296 -f 202/80/284 281/81/81 393/101/99 -f 394/95/298 204/96/297 201/103/299 -f 214/104/300 213/117/301 287/106/104 -f 179/52/266 208/87/290 275/107/105 -f 206/108/237 207/88/289 180/53/268 -f 260/45/45 164/3/233 211/110/302 -f 209/4/303 229/144/304 228/111/305 -f 219/113/306 220/112/307 210/1/235 -f 207/88/289 217/130/308 218/114/309 -f 213/117/301 212/116/310 286/115/113 -f 215/118/311 212/116/310 213/117/301 -f 288/119/117 286/115/113 212/116/310 -f 283/8/8 288/271/117 215/120/311 -f 215/120/311 214/121/300 211/110/302 -f 214/121/300 289/122/103 285/109/107 -f 216/123/312 222/135/313 223/125/314 -f 226/128/315 227/127/316 221/126/317 -f 211/110/302 221/131/317 216/129/312 -f 218/114/309 219/113/306 209/4/303 -f 216/129/312 217/130/308 207/88/289 -f 210/1/235 220/112/307 221/131/317 -f 226/134/315 225/133/318 224/132/319 -f 222/135/313 227/127/316 226/128/315 -f 227/127/316 222/135/313 216/123/312 -f 219/136/306 225/133/318 226/134/315 -f 218/138/309 224/132/319 225/133/318 -f 223/139/314 224/132/319 218/138/309 -f 291/140/127 293/146/132 231/142/320 -f 208/87/290 228/111/305 290/143/130 -f 284/6/6 291/272/127 229/144/304 -f 231/142/320 293/146/132 292/145/131 -f 229/141/304 231/142/320 230/148/321 -f 228/147/305 230/148/321 292/145/131 -f 169/15/242 258/16/16 295/150/134 -f 168/22/246 172/26/248 233/51/267 -f 172/26/248 169/15/242 234/47/264 -f 168/22/246 232/48/265 294/49/49 -f 235/46/263 239/157/322 240/152/323 -f 236/151/324 240/152/323 241/154/325 -f 165/2/234 236/151/324 237/153/261 -f 164/3/233 235/46/263 236/151/324 -f 241/154/325 243/163/326 303/156/140 -f 302/159/143 238/158/327 239/157/322 -f 299/160/144 239/157/322 235/46/263 -f 237/153/261 241/154/325 301/155/139 -f 238/158/327 302/159/143 304/161/145 -f 243/163/326 242/162/328 304/161/145 -f 242/162/328 243/163/326 241/154/325 -f 239/157/322 238/158/327 242/162/328 -f 392/102/329 201/103/299 253/165/330 -f 253/165/330 252/94/294 397/166/331 -f 355/167/332 192/180/333 247/169/334 -f 361/168/335 247/169/334 246/170/287 -f 246/170/287 307/172/156 280/171/155 -f 249/174/336 251/173/337 199/89/292 -f 248/57/273 250/54/269 251/173/337 -f 306/175/59 249/174/336 198/90/291 -f 305/176/59 248/57/273 249/174/336 -f 251/173/337 244/177/338 197/92/293 -f 251/173/337 250/54/269 245/55/339 -f 343/179/161 247/169/334 309/178/340 -f 192/180/333 310/184/341 309/178/340 -f 343/179/161 307/172/156 246/170/287 -f 311/181/163 314/273/173 315/183/342 -f 315/183/342 316/185/343 310/184/341 -f 310/184/341 316/185/343 317/186/344 -f 317/186/344 313/188/170 312/187/169 -f 321/191/345 322/190/346 317/189/344 -f 314/192/173 319/274/200 320/194/347 -f 322/190/346 318/196/175 313/195/170 -f 320/194/347 321/191/345 316/197/343 -f 327/199/348 323/198/176 318/196/175 -f 325/201/349 326/200/350 321/191/345 -f 326/200/350 327/199/348 322/190/346 -f 324/202/180 325/201/349 320/194/347 -f 340/205/351 341/204/352 336/203/353 -f 339/207/185 340/205/351 335/206/354 -f 329/209/355 330/208/356 335/206/354 -f 330/208/356 331/211/189 334/210/188 -f 342/214/357 338/213/191 333/212/190 -f 328/215/358 329/209/355 336/203/353 -f 332/217/195 328/215/358 337/216/359 -f 341/204/352 342/214/357 337/216/359 -f 325/201/349 324/202/180 338/213/191 -f 326/200/350 325/201/349 342/214/357 -f 327/199/348 326/200/350 341/204/352 -f 323/198/176 327/199/348 340/205/351 -f 278/75/75 311/181/163 308/182/360 -f 308/182/360 310/184/341 192/180/333 -f 332/217/195 348/275/361 344/218/362 -f 328/215/358 344/218/362 345/219/363 -f 346/221/364 347/220/198 331/211/189 -f 345/219/363 346/221/364 330/208/356 -f 350/224/365 351/223/366 354/222/200 -f 350/227/365 349/225/203 347/220/198 -f 354/222/200 351/223/366 352/226/367 -f 345/219/363 351/228/366 350/227/365 -f 344/218/362 352/229/367 351/228/366 -f 353/230/205 352/229/367 344/218/362 -f 371/231/368 376/276/369 364/233/370 -f 192/180/333 355/167/332 357/83/285 -f 373/234/371 361/168/335 362/84/286 -f 370/236/372 355/167/332 361/168/335 -f 374/235/373 362/84/286 358/85/374 -f 359/78/375 357/83/285 371/237/368 -f 369/238/211 360/77/77 359/78/375 -f 356/240/213 358/85/374 200/86/288 -f 378/243/376 377/242/377 363/241/378 -f 364/233/370 363/241/378 201/244/299 -f 375/247/379 365/246/380 355/245/332 -f 355/245/332 365/246/380 366/249/381 -f 363/241/378 375/251/379 370/250/372 -f 366/249/381 380/257/382 382/253/383 -f 282/254/222 369/238/211 368/239/384 -f 368/239/384 371/237/368 204/96/297 -f 252/94/294 374/235/373 372/64/277 -f 201/103/299 370/236/372 373/234/371 -f 253/165/330 373/234/371 374/235/373 -f 357/248/285 366/249/381 376/252/369 -f 367/256/223 372/64/277 358/85/374 -f 380/257/382 386/267/385 388/258/386 -f 377/242/377 383/265/387 387/260/388 -f 363/241/378 377/242/377 381/259/389 -f 365/246/380 379/261/390 380/257/382 -f 375/247/379 381/277/389 379/261/390 -f 382/262/383 378/243/376 364/233/370 -f 383/265/387 384/264/391 388/263/386 -f 385/266/392 387/268/388 388/258/386 -f 384/264/391 383/265/387 377/242/377 -f 388/263/386 384/264/391 378/243/376 -f 379/261/390 385/266/392 386/267/385 -f 387/268/388 385/266/392 379/261/390 -f 396/164/393 397/166/331 244/177/338 -f 183/56/271 392/102/329 396/164/393 -f 195/61/274 394/95/298 392/102/329 -f 389/98/394 393/101/99 273/71/71 -f 270/18/18 391/99/97 390/100/395 -f 197/92/293 395/93/295 389/98/394 -f 390/100/395 394/95/298 195/61/274 -f 397/166/331 395/93/295 197/92/293 -f 259/24/24 402/36/36 401/34/255 -f 166/13/239 401/34/255 400/32/253 -f 161/12/240 400/32/253 399/29/251 -f 163/27/245 399/29/251 398/30/30 -f 51/110/108 50/1/1 4/3/3 -f 5/2/2 50/1/1 7/5/5 -f 49/4/4 284/6/6 7/5/5 -f 46/108/106 283/8/8 21/10/10 -f 27/23/23 28/11/11 6/13/13 -f 257/70/70 10/14/14 258/16/16 -f 3/27/27 26/17/17 256/19/19 -f 2/25/25 255/20/20 8/22/22 -f 271/63/63 27/23/23 259/24/24 -f 11/28/28 2/25/25 12/26/26 -f 28/11/11 26/17/17 1/12/12 -f 10/14/14 11/28/28 9/15/15 -f 14/33/33 158/29/29 262/31/31 -f 13/35/35 159/32/32 14/33/33 -f 15/37/37 160/34/34 13/35/35 -f 263/269/257 402/36/36 15/37/37 -f 18/40/40 15/37/37 16/38/38 -f 16/38/38 13/35/35 17/39/39 -f 263/269/257 15/37/37 265/41/41 -f 17/39/39 14/33/33 264/42/42 -f 265/41/41 18/40/40 266/43/43 -f 16/38/38 17/39/39 266/43/43 -f 77/153/137 7/5/5 297/44/44 -f 296/270/262 260/45/45 75/46/46 -f 295/150/134 74/47/47 267/9/9 -f 19/52/52 72/48/48 268/50/50 -f 20/53/53 73/51/51 19/52/52 -f 74/47/47 73/51/51 21/10/10 -f 25/60/60 90/54/54 23/56/56 -f 305/176/59 88/57/57 269/59/59 -f 88/57/57 90/54/54 22/58/58 -f 34/67/67 35/61/61 28/11/11 -f 277/82/72 24/62/62 271/63/63 -f 367/256/223 134/64/64 276/66/66 -f 24/62/62 34/67/67 27/23/23 -f 2/25/25 11/28/28 29/69/69 -f 31/73/73 10/14/14 273/71/71 -f 255/20/20 2/25/25 272/72/72 -f 30/68/68 11/28/28 31/73/73 -f 33/79/79 36/74/74 274/76/76 -f 274/76/76 360/77/77 33/79/79 -f 276/66/66 45/65/65 281/81/81 -f 22/58/58 25/60/60 24/62/62 -f 269/59/59 22/58/58 277/82/72 -f 34/67/67 25/60/60 35/61/61 -f 124/78/78 122/83/82 33/79/79 -f 86/170/154 126/84/83 40/86/85 -f 20/53/53 19/52/52 47/88/87 -f 29/69/69 30/68/68 38/90/89 -f 272/72/72 29/69/69 279/91/72 -f 39/89/88 30/68/68 37/92/90 -f 157/166/150 155/93/91 92/94/92 -f 152/100/98 154/95/93 43/97/95 -f 45/65/65 155/93/91 42/80/80 -f 282/254/222 391/99/97 43/97/95 -f 151/98/96 393/101/99 42/80/80 -f 44/96/94 154/95/93 41/103/101 -f 53/117/115 54/104/102 287/106/104 -f 48/87/86 19/52/52 275/107/105 -f 21/10/10 20/53/53 46/108/106 -f 4/3/3 260/45/45 51/110/108 -f 69/144/128 49/4/4 68/111/109 -f 49/4/4 50/1/1 59/113/111 -f 57/130/119 47/88/87 58/114/112 -f 287/106/104 286/115/113 53/117/115 -f 52/116/114 55/118/116 53/117/115 -f 286/115/113 288/119/117 52/116/114 -f 288/271/117 283/8/8 55/120/116 -f 46/108/106 51/110/108 55/120/116 -f 51/110/108 285/109/107 54/121/102 -f 62/135/126 56/123/118 63/125/120 -f 60/278/110 61/126/121 66/128/123 -f 61/131/121 51/110/108 56/129/118 -f 48/87/86 49/4/4 58/114/112 -f 46/108/106 47/88/87 56/129/118 -f 60/112/110 50/1/1 61/131/121 -f 63/139/120 64/132/124 66/134/123 -f 67/127/122 62/135/126 66/128/123 -f 61/126/121 56/123/118 67/127/122 -f 65/133/125 59/136/111 66/134/123 -f 64/132/124 58/138/112 65/133/125 -f 57/279/119 58/138/112 63/139/120 -f 293/146/132 291/140/127 71/142/129 -f 68/111/109 48/87/86 290/143/130 -f 291/272/127 284/6/6 69/144/128 -f 70/148/133 292/145/131 71/142/129 -f 71/142/129 69/141/128 70/148/133 -f 70/148/133 68/147/109 292/145/131 -f 258/16/16 9/15/15 295/150/134 -f 12/26/26 8/22/22 73/51/51 -f 9/15/15 12/26/26 74/47/47 -f 254/21/21 294/49/49 8/22/22 -f 79/157/141 75/46/46 80/152/136 -f 80/152/136 76/151/135 81/154/138 -f 76/151/135 5/2/2 77/153/137 -f 75/46/46 4/3/3 76/151/135 -f 83/163/147 81/154/138 303/156/140 -f 299/160/144 79/157/141 302/159/143 -f 296/270/262 75/46/46 299/160/144 -f 81/154/138 77/153/137 301/155/139 -f 82/162/146 304/161/145 78/158/142 -f 303/156/140 304/161/145 83/163/147 -f 82/162/146 80/152/136 83/163/147 -f 78/158/142 79/157/141 82/162/146 -f 41/103/101 153/102/100 93/165/149 -f 156/164/148 157/166/150 93/165/149 -f 32/180/162 121/167/151 87/169/153 -f 87/169/153 125/168/152 86/170/154 -f 40/86/85 280/171/155 86/170/154 -f 38/90/89 39/89/88 89/174/158 -f 89/174/158 91/173/157 88/57/57 -f 279/91/72 38/90/89 306/175/59 -f 306/175/59 89/174/158 305/176/59 -f 39/89/88 37/92/90 91/173/157 -f 90/54/54 91/173/157 85/55/55 -f 312/187/169 95/178/160 343/179/161 -f 96/184/166 32/180/162 95/178/160 -f 87/169/153 86/170/154 343/179/161 -f 314/273/173 311/181/163 97/183/165 -f 94/182/164 96/184/166 97/183/165 -f 98/185/167 96/184/166 99/186/168 -f 95/178/160 312/187/169 99/186/168 -f 98/197/167 99/189/168 101/191/172 -f 319/274/200 314/192/173 100/194/174 -f 99/189/168 313/195/170 102/190/171 -f 97/193/165 98/197/167 100/194/174 -f 102/190/171 318/196/175 105/199/177 -f 100/194/174 101/191/172 103/201/179 -f 104/200/178 101/191/172 105/199/177 -f 319/274/200 100/194/174 324/202/180 -f 109/206/184 110/203/181 112/205/183 -f 334/210/188 109/206/184 339/207/185 -f 110/203/181 109/206/184 107/209/187 -f 109/206/184 334/210/188 108/208/186 -f 111/216/194 333/212/190 114/214/192 -f 111/216/194 110/203/181 106/215/193 -f 333/212/190 111/216/194 332/217/195 -f 110/203/181 111/216/194 113/204/182 -f 324/202/180 103/201/179 338/213/191 -f 103/201/179 104/200/178 114/214/192 -f 104/200/178 105/199/177 113/204/182 -f 105/199/177 323/198/176 112/205/183 -f 36/74/74 94/182/164 278/75/75 -f 36/74/74 32/180/162 94/182/164 -f 348/275/361 332/217/195 115/218/196 -f 115/218/196 106/215/193 116/219/197 -f 108/208/186 331/211/189 117/221/199 -f 107/209/187 108/208/186 116/219/197 -f 349/280/203 354/222/200 118/224/202 -f 118/227/202 117/221/199 349/225/203 -f 353/281/205 120/226/204 354/222/200 -f 116/219/197 117/221/199 119/228/201 -f 115/218/196 116/219/197 120/229/204 -f 348/275/361 115/218/196 353/230/205 -f 138/276/220 133/231/206 128/233/207 -f 121/167/151 32/180/162 122/83/82 -f 125/168/152 135/234/208 126/84/83 -f 121/167/151 132/236/210 125/168/152 -f 126/84/83 136/235/209 123/85/84 -f 131/239/212 133/237/206 124/78/78 -f 360/77/77 369/238/211 124/78/78 -f 280/171/155 40/86/85 356/240/213 -f 128/233/207 127/241/214 140/243/216 -f 44/232/94 41/244/101 128/233/207 -f 132/282/210 121/245/151 137/247/218 -f 129/246/217 121/245/151 130/249/219 -f 41/244/101 132/250/210 127/241/214 -f 142/257/224 130/249/219 144/253/221 -f 369/238/211 282/254/222 131/239/212 -f 43/97/95 44/96/94 131/239/212 -f 136/235/209 92/94/92 134/64/64 -f 132/236/210 41/103/101 135/234/208 -f 135/234/208 93/165/149 136/235/209 -f 130/249/219 122/248/82 138/252/220 -f 356/240/213 123/85/84 367/256/223 -f 148/267/232 142/257/224 150/258/225 -f 145/265/230 139/242/215 149/260/227 -f 139/242/215 127/241/214 143/259/226 -f 141/261/228 129/246/217 142/257/224 -f 143/277/226 137/247/218 141/261/228 -f 138/276/220 128/233/207 144/262/221 -f 149/260/227 150/263/225 145/265/230 -f 149/268/227 147/266/231 150/258/225 -f 140/243/216 139/242/215 146/264/229 -f 144/262/221 140/243/216 150/263/225 -f 147/266/231 141/261/228 148/267/232 -f 143/277/226 141/261/228 149/268/227 -f 85/55/55 84/177/159 156/164/148 -f 153/102/100 23/56/56 156/164/148 -f 154/95/93 35/61/61 153/102/100 -f 31/73/73 273/71/71 151/98/96 -f 391/99/97 270/18/18 152/100/98 -f 155/93/91 37/92/90 151/98/96 -f 26/17/17 35/61/61 152/100/98 -f 84/177/159 37/92/90 157/166/150 -f 402/36/36 259/24/24 160/34/34 -f 160/34/34 6/13/13 159/32/32 -f 159/32/32 1/12/12 158/29/29 -f 158/29/29 3/27/27 398/30/30 -f 211/110/302 164/3/233 210/1/235 -f 209/4/303 210/1/235 167/5/236 -f 209/4/303 167/5/236 284/6/6 -f 267/9/9 283/8/8 181/10/238 -f 187/23/247 166/13/239 188/11/241 -f 257/70/70 258/16/16 170/14/243 -f 270/18/18 186/17/244 256/19/19 -f 162/25/249 168/22/246 255/20/20 -f 271/63/63 259/24/24 187/23/247 -f 171/28/250 172/26/248 162/25/249 -f 188/11/241 161/12/240 186/17/244 -f 170/14/243 169/15/242 171/28/250 -f 398/30/30 399/29/251 262/31/31 -f 399/29/251 400/32/253 174/33/252 -f 400/32/253 401/34/255 173/35/254 -f 401/34/255 402/36/36 175/37/256 -f 173/35/254 175/37/256 176/38/259 -f 174/33/252 173/35/254 177/39/260 -f 263/269/257 265/41/41 175/37/256 -f 262/31/31 174/33/252 264/42/42 -f 176/38/259 178/40/258 266/43/43 -f 176/38/259 266/43/43 177/39/260 -f 261/7/7 167/5/236 297/44/44 -f 164/3/233 260/45/45 235/46/263 -f 295/150/134 267/9/9 234/47/264 -f 294/49/49 232/48/265 268/50/50 -f 232/48/265 233/51/267 179/52/266 -f 234/47/264 181/10/238 233/51/267 -f 245/55/339 250/54/269 183/56/271 -f 305/176/59 269/59/59 248/57/273 -f 248/57/273 182/58/272 250/54/269 -f 194/67/278 188/11/241 195/61/274 -f 277/82/72 271/63/63 184/62/275 -f 367/256/223 276/66/66 372/64/277 -f 184/62/275 187/23/247 194/67/278 -f 162/25/249 189/69/279 171/28/250 -f 257/70/70 170/14/243 273/71/71 -f 255/20/20 272/72/72 162/25/249 -f 170/14/243 171/28/250 191/73/281 -f 278/75/75 196/74/282 274/76/76 -f 359/78/375 360/77/77 193/79/283 -f 276/66/66 281/81/81 205/65/276 -f 182/58/272 184/62/275 185/60/270 -f 269/59/59 277/82/72 182/58/272 -f 183/56/271 185/60/270 195/61/274 -f 359/78/375 193/79/283 357/83/285 -f 358/85/374 362/84/286 200/86/288 -f 180/53/268 207/88/289 179/52/266 -f 189/69/279 198/90/291 190/68/280 -f 272/72/72 279/91/72 189/69/279 -f 191/73/281 190/68/280 197/92/293 -f 397/166/331 252/94/294 395/93/295 -f 390/100/395 203/97/296 394/95/298 -f 389/98/394 395/93/295 202/80/284 -f 390/100/395 391/99/97 203/97/296 -f 389/98/394 202/80/284 393/101/99 -f 392/102/329 394/95/298 201/103/299 -f 289/105/103 214/104/300 287/106/104 -f 268/50/50 179/52/266 275/107/105 -f 181/10/238 206/108/237 180/53/268 -f 285/109/107 260/45/45 211/110/302 -f 208/87/290 209/4/303 228/111/305 -f 209/4/303 219/113/306 210/1/235 -f 208/87/290 207/88/289 218/114/309 -f 287/106/104 213/117/301 286/115/113 -f 214/104/300 215/118/311 213/117/301 -f 215/118/311 288/119/117 212/116/310 -f 206/108/237 283/8/8 215/120/311 -f 206/108/237 215/120/311 211/110/302 -f 211/110/302 214/121/300 285/109/107 -f 217/124/308 216/123/312 223/125/314 -f 220/278/307 226/128/315 221/126/317 -f 206/108/237 211/110/302 216/129/312 -f 208/87/290 218/114/309 209/4/303 -f 206/108/237 216/129/312 207/88/289 -f 211/110/302 210/1/235 221/131/317 -f 223/139/314 226/134/315 224/132/319 -f 223/125/314 222/135/313 226/128/315 -f 221/126/317 227/127/316 216/123/312 -f 220/137/307 219/136/306 226/134/315 -f 219/136/306 218/138/309 225/133/318 -f 217/279/308 223/139/314 218/138/309 -f 229/141/304 291/140/127 231/142/320 -f 275/107/105 208/87/290 290/143/130 -f 209/4/303 284/6/6 229/144/304 -f 230/148/321 231/142/320 292/145/131 -f 228/147/305 229/141/304 230/148/321 -f 290/149/130 228/147/305 292/145/131 -f 234/47/264 169/15/242 295/150/134 -f 232/48/265 168/22/246 233/51/267 -f 233/51/267 172/26/248 234/47/264 -f 254/21/21 168/22/246 294/49/49 -f 236/151/324 235/46/263 240/152/323 -f 237/153/261 236/151/324 241/154/325 -f 167/5/236 165/2/234 237/153/261 -f 165/2/234 164/3/233 236/151/324 -f 301/155/139 241/154/325 303/156/140 -f 299/160/144 302/159/143 239/157/322 -f 296/270/262 299/160/144 235/46/263 -f 297/44/44 237/153/261 301/155/139 -f 242/162/328 238/158/327 304/161/145 -f 303/156/140 243/163/326 304/161/145 -f 240/152/323 242/162/328 241/154/325 -f 240/152/323 239/157/322 242/162/328 -f 396/164/393 392/102/329 253/165/330 -f 396/164/393 253/165/330 397/166/331 -f 361/168/335 355/167/332 247/169/334 -f 362/84/286 361/168/335 246/170/287 -f 200/86/288 246/170/287 280/171/155 -f 198/90/291 249/174/336 199/89/292 -f 249/174/336 248/57/273 251/173/337 -f 279/91/72 306/175/59 198/90/291 -f 306/175/59 305/176/59 249/174/336 -f 199/89/292 251/173/337 197/92/293 -f 244/177/338 251/173/337 245/55/339 -f 312/187/169 343/179/161 309/178/340 -f 247/169/334 192/180/333 309/178/340 -f 247/169/334 343/179/161 246/170/287 -f 308/182/360 311/181/163 315/183/342 -f 308/182/360 315/183/342 310/184/341 -f 309/178/340 310/184/341 317/186/344 -f 309/178/340 317/186/344 312/187/169 -f 316/197/343 321/191/345 317/189/344 -f 315/193/342 314/192/173 320/194/347 -f 317/189/344 322/190/346 313/195/170 -f 315/193/342 320/194/347 316/197/343 -f 322/190/346 327/199/348 318/196/175 -f 320/194/347 325/201/349 321/191/345 -f 321/191/345 326/200/350 322/190/346 -f 319/274/200 324/202/180 320/194/347 -f 335/206/354 340/205/351 336/203/353 -f 334/210/188 339/207/185 335/206/354 -f 336/203/353 329/209/355 335/206/354 -f 335/206/354 330/208/356 334/210/188 -f 337/216/359 342/214/357 333/212/190 -f 337/216/359 328/215/358 336/203/353 -f 333/212/190 332/217/195 337/216/359 -f 336/203/353 341/204/352 337/216/359 -f 342/214/357 325/201/349 338/213/191 -f 341/204/352 326/200/350 342/214/357 -f 340/205/351 327/199/348 341/204/352 -f 339/207/185 323/198/176 340/205/351 -f 196/74/282 278/75/75 308/182/360 -f 196/74/282 308/182/360 192/180/333 -f 328/215/358 332/217/195 344/218/362 -f 329/209/355 328/215/358 345/219/363 -f 330/208/356 346/221/364 331/211/189 -f 329/209/355 345/219/363 330/208/356 -f 349/280/203 350/224/365 354/222/200 -f 346/221/364 350/227/365 347/220/198 -f 353/281/205 354/222/200 352/226/367 -f 346/221/364 345/219/363 350/227/365 -f 345/219/363 344/218/362 351/228/366 -f 348/275/361 353/230/205 344/218/362 -f 204/232/297 371/231/368 364/233/370 -f 196/74/282 192/180/333 357/83/285 -f 374/235/373 373/234/371 362/84/286 -f 373/234/371 370/236/372 361/168/335 -f 372/64/277 374/235/373 358/85/374 -f 368/239/384 359/78/375 371/237/368 -f 368/239/384 369/238/211 359/78/375 -f 280/171/155 356/240/213 200/86/288 -f 364/233/370 378/243/376 363/241/378 -f 204/232/297 364/233/370 201/244/299 -f 370/282/372 375/247/379 355/245/332 -f 357/248/285 355/245/332 366/249/381 -f 201/244/299 363/241/378 370/250/372 -f 376/252/369 366/249/381 382/253/383 -f 203/97/296 282/254/222 368/239/384 -f 203/97/296 368/239/384 204/96/297 -f 205/65/276 252/94/294 372/64/277 -f 253/165/330 201/103/299 373/234/371 -f 252/94/294 253/165/330 374/235/373 -f 371/255/368 357/248/285 376/252/369 -f 356/240/213 367/256/223 358/85/374 -f 382/253/383 380/257/382 388/258/386 -f 381/259/389 377/242/377 387/260/388 -f 375/251/379 363/241/378 381/259/389 -f 366/249/381 365/246/380 380/257/382 -f 365/246/380 375/247/379 379/261/390 -f 376/276/369 382/262/383 364/233/370 -f 387/260/388 383/265/387 388/263/386 -f 386/267/385 385/266/392 388/258/386 -f 378/243/376 384/264/391 377/242/377 -f 382/262/383 388/263/386 378/243/376 -f 380/257/382 379/261/390 386/267/385 -f 381/277/389 387/268/388 379/261/390 -f 245/55/339 396/164/393 244/177/338 -f 245/55/339 183/56/271 396/164/393 -f 183/56/271 195/61/274 392/102/329 -f 191/73/281 389/98/394 273/71/71 -f 186/17/244 270/18/18 390/100/395 -f 191/73/281 197/92/293 389/98/394 -f 186/17/244 390/100/395 195/61/274 -f 244/177/338 397/166/331 197/92/293 -f 166/13/239 259/24/24 401/34/255 -f 161/12/240 166/13/239 400/32/253 -f 163/27/245 161/12/240 399/29/251 -f 256/19/19 163/27/245 398/30/30 diff --git a/assets/Models/SubmarineTexture.png b/assets/Models/SubmarineTexture.png deleted file mode 100644 index c64d62d..0000000 Binary files a/assets/Models/SubmarineTexture.png and /dev/null differ diff --git a/deps/include/DirectXTK/Audio.h b/deps/include/DirectXTK/Audio.h new file mode 100644 index 0000000..cfbd3f3 --- /dev/null +++ b/deps/include/DirectXTK/Audio.h @@ -0,0 +1,716 @@ +//-------------------------------------------------------------------------------------- +// File: Audio.h +// +// DirectXTK for Audio header +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include +#include + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#pragma comment(lib,"acphal.lib") +#endif + +#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#pragma comment(lib,"PhoneAudioSes.lib") +#endif + +#ifndef XAUDIO2_HELPER_FUNCTIONS +#define XAUDIO2_HELPER_FUNCTIONS +#endif + +#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#error DirectX Tool Kit for Audio does not support VS 2010 without the DirectX SDK +#endif +#include +#include +#include +#include +#pragma comment(lib,"xaudio2.lib") +#else +// Using XAudio 2.7 requires the DirectX SDK +#include +#include +#include +#include +#pragma warning(push) +#pragma warning( disable : 4005 ) +#include +#pragma warning(pop) +#pragma comment(lib,"x3daudio.lib") +#pragma comment(lib,"xapofx.lib") +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include +#include +#include +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#pragma warning(push) +#pragma warning(disable : 4481) +// VS 2010 considers 'override' to be a extension, but it's part of C++11 as of VS 2012 + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + class SoundEffectInstance; + + //---------------------------------------------------------------------------------- + struct AudioStatistics + { + size_t playingOneShots; // Number of one-shot sounds currently playing + size_t playingInstances; // Number of sound effect instances currently playing + size_t allocatedInstances; // Number of SoundEffectInstance allocated + size_t allocatedVoices; // Number of XAudio2 voices allocated (standard, 3D, one-shots, and idle one-shots) + size_t allocatedVoices3d; // Number of XAudio2 voices allocated for 3D + size_t allocatedVoicesOneShot; // Number of XAudio2 voices allocated for one-shot sounds + size_t allocatedVoicesIdle; // Number of XAudio2 voices allocated for one-shot sounds but not currently in use + size_t audioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks +#if defined(_XBOX_ONE) && defined(_TITLE) + size_t xmaAudioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks allocated with ApuAlloc +#endif + }; + + + //---------------------------------------------------------------------------------- + class IVoiceNotify + { + public: + virtual void __cdecl OnBufferEnd() = 0; + // Notfication that a voice buffer has finished + // Note this is called from XAudio2's worker thread, so it should perform very minimal and thread-safe operations + + virtual void __cdecl OnCriticalError() = 0; + // Notification that the audio engine encountered a critical error + + virtual void __cdecl OnReset() = 0; + // Notification of an audio engine reset + + virtual void __cdecl OnUpdate() = 0; + // Notification of an audio engine per-frame update (opt-in) + + virtual void __cdecl OnDestroyEngine() = 0; + // Notification that the audio engine is being destroyed + + virtual void __cdecl OnTrim() = 0; + // Notification of a request to trim the voice pool + + virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const = 0; + // Contribute to statistics request + }; + + //---------------------------------------------------------------------------------- + enum AUDIO_ENGINE_FLAGS + { + AudioEngine_Default = 0x0, + + AudioEngine_EnvironmentalReverb = 0x1, + AudioEngine_ReverbUseFilters = 0x2, + AudioEngine_UseMasteringLimiter = 0x4, + + AudioEngine_Debug = 0x10000, + AudioEngine_ThrowOnNoAudioHW = 0x20000, + AudioEngine_DisableVoiceReuse = 0x40000, + }; + + inline AUDIO_ENGINE_FLAGS operator|(AUDIO_ENGINE_FLAGS a, AUDIO_ENGINE_FLAGS b) { return static_cast( static_cast(a) | static_cast(b) ); } + + enum SOUND_EFFECT_INSTANCE_FLAGS + { + SoundEffectInstance_Default = 0x0, + + SoundEffectInstance_Use3D = 0x1, + SoundEffectInstance_ReverbUseFilters = 0x2, + SoundEffectInstance_NoSetPitch = 0x4, + + SoundEffectInstance_UseRedirectLFE = 0x10000, + }; + + inline SOUND_EFFECT_INSTANCE_FLAGS operator|(SOUND_EFFECT_INSTANCE_FLAGS a, SOUND_EFFECT_INSTANCE_FLAGS b) { return static_cast( static_cast(a) | static_cast(b) ); } + + enum AUDIO_ENGINE_REVERB + { + Reverb_Off, + Reverb_Default, + Reverb_Generic, + Reverb_Forest, + Reverb_PaddedCell, + Reverb_Room, + Reverb_Bathroom, + Reverb_LivingRoom, + Reverb_StoneRoom, + Reverb_Auditorium, + Reverb_ConcertHall, + Reverb_Cave, + Reverb_Arena, + Reverb_Hangar, + Reverb_CarpetedHallway, + Reverb_Hallway, + Reverb_StoneCorridor, + Reverb_Alley, + Reverb_City, + Reverb_Mountains, + Reverb_Quarry, + Reverb_Plain, + Reverb_ParkingLot, + Reverb_SewerPipe, + Reverb_Underwater, + Reverb_SmallRoom, + Reverb_MediumRoom, + Reverb_LargeRoom, + Reverb_MediumHall, + Reverb_LargeHall, + Reverb_Plate, + Reverb_MAX + }; + + enum SoundState + { + STOPPED = 0, + PLAYING, + PAUSED + }; + + + //---------------------------------------------------------------------------------- + class AudioEngine + { + public: + explicit AudioEngine( AUDIO_ENGINE_FLAGS flags = AudioEngine_Default, _In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr, + AUDIO_STREAM_CATEGORY category = AudioCategory_GameEffects ); + + AudioEngine(AudioEngine&& moveFrom); + AudioEngine& operator= (AudioEngine&& moveFrom); + virtual ~AudioEngine(); + + bool __cdecl Update(); + // Performs per-frame processing for the audio engine, returns false if in 'silent mode' + + bool __cdecl Reset( _In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr ); + // Reset audio engine from critical error/silent mode using a new device; can also 'migrate' the graph + // Returns true if succesfully reset, false if in 'silent mode' due to no default device + // Note: One shots are lost, all SoundEffectInstances are in the STOPPED state after successful reset + + void __cdecl Suspend(); + void __cdecl Resume(); + // Suspend/resumes audio processing (i.e. global pause/resume) + + float __cdecl GetMasterVolume() const; + void __cdecl SetMasterVolume( float volume ); + // Master volume property for all sounds + + void __cdecl SetReverb( AUDIO_ENGINE_REVERB reverb ); + void __cdecl SetReverb( _In_opt_ const XAUDIO2FX_REVERB_PARAMETERS* native ); + // Sets environmental reverb for 3D positional audio (if active) + + void __cdecl SetMasteringLimit( int release, int loudness ); + // Sets the mastering volume limiter properties (if active) + + AudioStatistics __cdecl GetStatistics() const; + // Gathers audio engine statistics + + WAVEFORMATEXTENSIBLE __cdecl GetOutputFormat() const; + // Returns the format consumed by the mastering voice (which is the same as the device output if defaults are used) + + uint32_t __cdecl GetChannelMask() const; + // Returns the output channel mask + + int __cdecl GetOutputChannels() const; + // Returns the number of output channels + + bool __cdecl IsAudioDevicePresent() const; + // Returns true if the audio graph is operating normally, false if in 'silent mode' + + bool __cdecl IsCriticalError() const; + // Returns true if the audio graph is halted due to a critical error (which also places the engine into 'silent mode') + + // Voice pool management. + void __cdecl SetDefaultSampleRate( int sampleRate ); + // Sample rate for voices in the reuse pool (defaults to 44100) + + void __cdecl SetMaxVoicePool( size_t maxOneShots, size_t maxInstances ); + // Maximum number of voices to allocate for one-shots and instances + // Note: one-shots over this limit are ignored; too many instance voices throws an exception + + void __cdecl TrimVoicePool(); + // Releases any currently unused voices + + // Internal-use functions + void __cdecl AllocateVoice( _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags, bool oneshot, _Outptr_result_maybenull_ IXAudio2SourceVoice** voice ); + + void __cdecl DestroyVoice( _In_ IXAudio2SourceVoice* voice ); + // Should only be called for instance voices, not one-shots + + void __cdecl RegisterNotify( _In_ IVoiceNotify* notify, bool usesUpdate ); + void __cdecl UnregisterNotify( _In_ IVoiceNotify* notify, bool usesOneShots, bool usesUpdate ); + + // XAudio2 interface access + IXAudio2* __cdecl GetInterface() const; + IXAudio2MasteringVoice* __cdecl GetMasterVoice() const; + IXAudio2SubmixVoice* __cdecl GetReverbVoice() const; + X3DAUDIO_HANDLE& __cdecl Get3DHandle() const; + + // Static functions + struct RendererDetail + { + std::wstring deviceId; + std::wstring description; + }; + + static std::vector __cdecl GetRendererDetails(); + // Returns a list of valid audio endpoint devices + + private: + // Private implementation. + class Impl; + std::unique_ptr pImpl; + + // Prevent copying. + AudioEngine(AudioEngine const&) DIRECTX_CTOR_DELETE + AudioEngine& operator= (AudioEngine const&) DIRECTX_CTOR_DELETE + }; + + + //---------------------------------------------------------------------------------- + class WaveBank + { + public: + WaveBank( _In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName ); + + WaveBank(WaveBank&& moveFrom); + WaveBank& operator= (WaveBank&& moveFrom); + virtual ~WaveBank(); + + void __cdecl Play( int index ); + void __cdecl Play( int index, float volume, float pitch, float pan ); + + void __cdecl Play( _In_z_ const char* name ); + void __cdecl Play( _In_z_ const char* name, float volume, float pitch, float pan ); + + std::unique_ptr __cdecl CreateInstance( int index, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default ); + std::unique_ptr __cdecl CreateInstance( _In_z_ const char* name, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default ); + + bool __cdecl IsPrepared() const; + bool __cdecl IsInUse() const; + bool __cdecl IsStreamingBank() const; + + size_t __cdecl GetSampleSizeInBytes( int index ) const; + // Returns size of wave audio data + + size_t __cdecl GetSampleDuration( int index ) const; + // Returns the duration in samples + + size_t __cdecl GetSampleDurationMS( int index ) const; + // Returns the duration in milliseconds + + const WAVEFORMATEX* __cdecl GetFormat( int index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* wfx, size_t maxsize ) const; + + int __cdecl Find( _In_z_ const char* name ) const; + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ ) + bool __cdecl FillSubmitBuffer( int index, _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const; +#else + void __cdecl FillSubmitBuffer( int index, _Out_ XAUDIO2_BUFFER& buffer ) const; +#endif + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + WaveBank(WaveBank const&) DIRECTX_CTOR_DELETE + WaveBank& operator= (WaveBank const&) DIRECTX_CTOR_DELETE + + // Private interface + void __cdecl UnregisterInstance( _In_ SoundEffectInstance* instance ); + + friend class SoundEffectInstance; + }; + + + //---------------------------------------------------------------------------------- + class SoundEffect + { + public: + SoundEffect( _In_ AudioEngine* engine, _In_z_ const wchar_t* waveFileName ); + + SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr& wavData, + _In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes ); + + SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr& wavData, + _In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes, + uint32_t loopStart, uint32_t loopLength ); + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/) + + SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr& wavData, + _In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes, + _In_reads_(seekCount) const uint32_t* seekTable, size_t seekCount ); + +#endif + + SoundEffect(SoundEffect&& moveFrom); + SoundEffect& operator= (SoundEffect&& moveFrom); + virtual ~SoundEffect(); + + void __cdecl Play(); + void __cdecl Play(float volume, float pitch, float pan); + + std::unique_ptr __cdecl CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default ); + + bool __cdecl IsInUse() const; + + size_t __cdecl GetSampleSizeInBytes() const; + // Returns size of wave audio data + + size_t __cdecl GetSampleDuration() const; + // Returns the duration in samples + + size_t __cdecl GetSampleDurationMS() const; + // Returns the duration in milliseconds + + const WAVEFORMATEX* __cdecl GetFormat() const; + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/) + bool __cdecl FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const; +#else + void __cdecl FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer ) const; +#endif + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + SoundEffect(SoundEffect const&) DIRECTX_CTOR_DELETE + SoundEffect& operator= (SoundEffect const&) DIRECTX_CTOR_DELETE + + // Private interface + void __cdecl UnregisterInstance( _In_ SoundEffectInstance* instance ); + + friend class SoundEffectInstance; + }; + + + //---------------------------------------------------------------------------------- + struct AudioListener : public X3DAUDIO_LISTENER + { + AudioListener() + { + memset( this, 0, sizeof(X3DAUDIO_LISTENER) ); + + OrientFront.z = + OrientTop.y = 1.f; + } + + void XM_CALLCONV SetPosition( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Position ), v ); + } + void __cdecl SetPosition( const XMFLOAT3& pos ) + { + Position.x = pos.x; + Position.y = pos.y; + Position.z = pos.z; + } + + void XM_CALLCONV SetVelocity( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + } + void __cdecl SetVelocity( const XMFLOAT3& vel ) + { + Velocity.x = vel.x; + Velocity.y = vel.y; + Velocity.z = vel.z; + } + + void XM_CALLCONV SetOrientation( FXMVECTOR forward, FXMVECTOR up ) + { + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), up ); + } + void __cdecl SetOrientation( const XMFLOAT3& forward, const XMFLOAT3& up ) + { + OrientFront.x = forward.x; OrientTop.x = up.x; + OrientFront.y = forward.y; OrientTop.y = up.y; + OrientFront.z = forward.z; OrientTop.z = up.z; + } + + void XM_CALLCONV SetOrientationFromQuaternion( FXMVECTOR quat ) + { + XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + + XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), up ); + } + + void XM_CALLCONV Update( FXMVECTOR newPos, XMVECTOR upDir, float dt ) + // Updates velocity and orientation by tracking changes in position over time... + { + if ( dt > 0.f ) + { + XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast( &Position ) ); + + XMVECTOR vDelta = ( newPos - lastPos ); + XMVECTOR v = vDelta / dt; + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + + vDelta = XMVector3Normalize( vDelta ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), vDelta ); + + v = XMVector3Cross( upDir, vDelta ); + v = XMVector3Normalize( v ); + + v = XMVector3Cross( vDelta, v ); + v = XMVector3Normalize( v ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), v ); + + XMStoreFloat3( reinterpret_cast( &Position ), newPos ); + } + } + }; + + + //---------------------------------------------------------------------------------- + struct AudioEmitter : public X3DAUDIO_EMITTER + { + float EmitterAzimuths[XAUDIO2_MAX_AUDIO_CHANNELS]; + + AudioEmitter() + { + memset( this, 0, sizeof(X3DAUDIO_EMITTER) ); + memset( EmitterAzimuths, 0, sizeof(EmitterAzimuths) ); + + OrientFront.z = + OrientTop.y = + ChannelRadius = + CurveDistanceScaler = + DopplerScaler = 1.f; + + ChannelCount = 1; + pChannelAzimuths = EmitterAzimuths; + + InnerRadiusAngle = X3DAUDIO_PI / 4.0f; + } + + void XM_CALLCONV SetPosition( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Position ), v ); + } + void __cdecl SetPosition( const XMFLOAT3& pos ) + { + Position.x = pos.x; + Position.y = pos.y; + Position.z = pos.z; + } + + void XM_CALLCONV SetVelocity( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + } + void __cdecl SetVelocity( const XMFLOAT3& vel ) + { + Velocity.x = vel.x; + Velocity.y = vel.y; + Velocity.z = vel.z; + } + + void XM_CALLCONV SetOrientation( FXMVECTOR forward, FXMVECTOR up ) + { + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), up ); + } + void __cdecl SetOrientation( const XMFLOAT3& forward, const XMFLOAT3& up ) + { + OrientFront.x = forward.x; OrientTop.x = up.x; + OrientFront.y = forward.y; OrientTop.y = up.y; + OrientFront.z = forward.z; OrientTop.z = up.z; + } + + void XM_CALLCONV SetOrientationFromQuaternion( FXMVECTOR quat ) + { + XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + + XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), up ); + } + + void XM_CALLCONV Update( FXMVECTOR newPos, XMVECTOR upDir, float dt ) + // Updates velocity and orientation by tracking changes in position over time... + { + if ( dt > 0.f ) + { + XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast( &Position ) ); + + XMVECTOR vDelta = ( newPos - lastPos ); + XMVECTOR v = vDelta / dt; + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + + vDelta = XMVector3Normalize( vDelta ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), vDelta ); + + v = XMVector3Cross( upDir, vDelta ); + v = XMVector3Normalize( v ); + + v = XMVector3Cross( vDelta, v ); + v = XMVector3Normalize( v ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), v ); + + XMStoreFloat3( reinterpret_cast( &Position ), newPos ); + } + } + }; + + + //---------------------------------------------------------------------------------- + class SoundEffectInstance + { + public: + SoundEffectInstance(SoundEffectInstance&& moveFrom); + SoundEffectInstance& operator= (SoundEffectInstance&& moveFrom); + virtual ~SoundEffectInstance(); + + void __cdecl Play( bool loop = false ); + void __cdecl Stop( bool immediate = true ); + void __cdecl Pause(); + void __cdecl Resume(); + + void __cdecl SetVolume( float volume ); + void __cdecl SetPitch( float pitch ); + void __cdecl SetPan( float pan ); + + void __cdecl Apply3D( const AudioListener& listener, const AudioEmitter& emitter ); + + bool __cdecl IsLooped() const; + + SoundState __cdecl GetState(); + + // Notifications. + void __cdecl OnDestroyParent(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Private constructors + SoundEffectInstance( _In_ AudioEngine* engine, _In_ SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags ); + SoundEffectInstance( _In_ AudioEngine* engine, _In_ WaveBank* effect, int index, SOUND_EFFECT_INSTANCE_FLAGS flags ); + + friend std::unique_ptr __cdecl SoundEffect::CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS ); + friend std::unique_ptr __cdecl WaveBank::CreateInstance( int, SOUND_EFFECT_INSTANCE_FLAGS ); + + // Prevent copying. + SoundEffectInstance(SoundEffectInstance const&) DIRECTX_CTOR_DELETE + SoundEffectInstance& operator= (SoundEffectInstance const&) DIRECTX_CTOR_DELETE + }; + + + //---------------------------------------------------------------------------------- + class DynamicSoundEffectInstance + { + public: + DynamicSoundEffectInstance( _In_ AudioEngine* engine, + _In_opt_ std::function bufferNeeded, + int sampleRate, int channels, int sampleBits = 16, + SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default ); + DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom); + DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance&& moveFrom); + virtual ~DynamicSoundEffectInstance(); + + void __cdecl Play(); + void __cdecl Stop( bool immediate = true ); + void __cdecl Pause(); + void __cdecl Resume(); + + void __cdecl SetVolume( float volume ); + void __cdecl SetPitch( float pitch ); + void __cdecl SetPan( float pan ); + + void __cdecl Apply3D( const AudioListener& listener, const AudioEmitter& emitter ); + + void __cdecl SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, size_t audioBytes ); + void __cdecl SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, uint32_t offset, size_t audioBytes ); + + SoundState __cdecl GetState(); + + size_t __cdecl GetSampleDuration( size_t bytes ) const; + // Returns duration in samples of a buffer of a given size + + size_t __cdecl GetSampleDurationMS( size_t bytes ) const; + // Returns duration in milliseconds of a buffer of a given size + + size_t __cdecl GetSampleSizeInBytes( uint64_t duration ) const; + // Returns size of a buffer for a duration given in milliseconds + + int __cdecl GetPendingBufferCount() const; + + const WAVEFORMATEX* __cdecl GetFormat() const; + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + DynamicSoundEffectInstance(DynamicSoundEffectInstance const&) DIRECTX_CTOR_DELETE + DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance const&) DIRECTX_CTOR_DELETE + }; +} + +#pragma warning(pop) \ No newline at end of file diff --git a/deps/include/DirectXTK/CommonStates.h b/deps/include/DirectXTK/CommonStates.h new file mode 100644 index 0000000..77fdc49 --- /dev/null +++ b/deps/include/DirectXTK/CommonStates.h @@ -0,0 +1,81 @@ +//-------------------------------------------------------------------------------------- +// File: CommonStates.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + + +namespace DirectX +{ + class CommonStates + { + public: + explicit CommonStates(_In_ ID3D11Device* device); + CommonStates(CommonStates&& moveFrom); + CommonStates& operator= (CommonStates&& moveFrom); + virtual ~CommonStates(); + + // Blend states. + ID3D11BlendState* __cdecl Opaque() const; + ID3D11BlendState* __cdecl AlphaBlend() const; + ID3D11BlendState* __cdecl Additive() const; + ID3D11BlendState* __cdecl NonPremultiplied() const; + + // Depth stencil states. + ID3D11DepthStencilState* __cdecl DepthNone() const; + ID3D11DepthStencilState* __cdecl DepthDefault() const; + ID3D11DepthStencilState* __cdecl DepthRead() const; + + // Rasterizer states. + ID3D11RasterizerState* __cdecl CullNone() const; + ID3D11RasterizerState* __cdecl CullClockwise() const; + ID3D11RasterizerState* __cdecl CullCounterClockwise() const; + ID3D11RasterizerState* __cdecl Wireframe() const; + + // Sampler states. + ID3D11SamplerState* __cdecl PointWrap() const; + ID3D11SamplerState* __cdecl PointClamp() const; + ID3D11SamplerState* __cdecl LinearWrap() const; + ID3D11SamplerState* __cdecl LinearClamp() const; + ID3D11SamplerState* __cdecl AnisotropicWrap() const; + ID3D11SamplerState* __cdecl AnisotropicClamp() const; + + private: + // Private implementation. + class Impl; + + std::shared_ptr pImpl; + + // Prevent copying. + CommonStates(CommonStates const&) DIRECTX_CTOR_DELETE + CommonStates& operator= (CommonStates const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/deps/include/DirectXTK/DDSTextureLoader.h b/deps/include/DirectXTK/DDSTextureLoader.h new file mode 100644 index 0000000..683ab7c --- /dev/null +++ b/deps/include/DirectXTK/DDSTextureLoader.h @@ -0,0 +1,160 @@ +//-------------------------------------------------------------------------------------- +// File: DDSTextureLoader.h +// +// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it +// +// Note these functions are useful as a light-weight runtime loader for DDS files. For +// a full-featured DDS file reader, writer, and texture processing pipeline see +// the 'Texconv' sample and the 'DirectXTex' library. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +namespace DirectX +{ + enum DDS_ALPHA_MODE + { + DDS_ALPHA_MODE_UNKNOWN = 0, + DDS_ALPHA_MODE_STRAIGHT = 1, + DDS_ALPHA_MODE_PREMULTIPLIED = 2, + DDS_ALPHA_MODE_OPAQUE = 3, + DDS_ALPHA_MODE_CUSTOM = 4, + }; + + // Standard version + HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Standard version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Extended version + HRESULT __cdecl CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT __cdecl CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Extended version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromMemoryEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromFileEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); +} \ No newline at end of file diff --git a/deps/include/DirectXTK/DirectXHelpers.h b/deps/include/DirectXTK/DirectXHelpers.h new file mode 100644 index 0000000..f60cc40 --- /dev/null +++ b/deps/include/DirectXTK/DirectXHelpers.h @@ -0,0 +1,130 @@ +//-------------------------------------------------------------------------------------- +// File: DirectXHelpers.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) +#if !defined(_XBOX_ONE) || !defined(_TITLE) +#pragma comment(lib,"dxguid.lib") +#endif +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +// +// The core Direct3D headers provide the following helper C++ classes +// CD3D11_RECT +// CD3D11_BOX +// CD3D11_DEPTH_STENCIL_DESC +// CD3D11_BLEND_DESC, CD3D11_BLEND_DESC1 +// CD3D11_RASTERIZER_DESC, CD3D11_RASTERIZER_DESC1 +// CD3D11_BUFFER_DESC +// CD3D11_TEXTURE1D_DESC +// CD3D11_TEXTURE2D_DESC +// CD3D11_TEXTURE3D_DESC +// CD3D11_SHADER_RESOURCE_VIEW_DESC +// CD3D11_RENDER_TARGET_VIEW_DESC +// CD3D11_VIEWPORT +// CD3D11_DEPTH_STENCIL_VIEW_DESC +// CD3D11_UNORDERED_ACCESS_VIEW_DESC +// CD3D11_SAMPLER_DESC +// CD3D11_QUERY_DESC +// CD3D11_COUNTER_DESC +// + + +namespace DirectX +{ + // simliar to std::lock_guard for exception-safe Direct3D 11 resource locking + class MapGuard : public D3D11_MAPPED_SUBRESOURCE + { + public: + MapGuard( _In_ ID3D11DeviceContext* context, + _In_ ID3D11Resource *resource, + _In_ UINT subresource, + _In_ D3D11_MAP mapType, + _In_ UINT mapFlags ) + : mContext(context), mResource(resource), mSubresource(subresource) + { + HRESULT hr = mContext->Map( resource, subresource, mapType, mapFlags, this ); + if (FAILED(hr)) + { + throw std::exception(); + } + } + + ~MapGuard() + { + mContext->Unmap( mResource, mSubresource ); + } + + uint8_t* get() const + { + return reinterpret_cast( pData ); + } + uint8_t* get(size_t slice) const + { + return reinterpret_cast( pData ) + ( slice * DepthPitch ); + } + + uint8_t* scanline(size_t row) const + { + return reinterpret_cast( pData ) + ( row * RowPitch ); + } + uint8_t* scanline(size_t slice, size_t row) const + { + return reinterpret_cast( pData ) + ( slice * DepthPitch ) + ( row * RowPitch ); + } + + private: + ID3D11DeviceContext* mContext; + ID3D11Resource* mResource; + UINT mSubresource; + + MapGuard(MapGuard const&); + MapGuard& operator= (MapGuard const&); + }; + + + // Helper sets a D3D resource name string (used by PIX and debug layer leak reporting). + template + inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const char (&name)[TNameLength]) + { + #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + #if defined(_XBOX_ONE) && defined(_TITLE) + WCHAR wname[MAX_PATH]; + int result = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, name, TNameLength, wname, MAX_PATH ); + if ( result > 0 ) + { + resource->SetName( wname ); + } + #else + resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); + #endif + #else + UNREFERENCED_PARAMETER(resource); + UNREFERENCED_PARAMETER(name); + #endif + } +} \ No newline at end of file diff --git a/deps/include/DirectXTK/Effects.h b/deps/include/DirectXTK/Effects.h new file mode 100644 index 0000000..d7e7dec --- /dev/null +++ b/deps/include/DirectXTK/Effects.h @@ -0,0 +1,612 @@ +//-------------------------------------------------------------------------------------- +// File: Effects.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include +#include + +#pragma warning(push) +#pragma warning(disable : 4481) +// VS 2010 considers 'override' to be a extension, but it's part of C++11 as of VS 2012 + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + //---------------------------------------------------------------------------------- + // Abstract interface representing any effect which can be applied onto a D3D device context. + class IEffect + { + public: + virtual ~IEffect() { } + + virtual void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) = 0; + + virtual void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) = 0; + }; + + + // Abstract interface for effects with world, view, and projection matrices. + class IEffectMatrices + { + public: + virtual ~IEffectMatrices() { } + + virtual void XM_CALLCONV SetWorld(FXMMATRIX value) = 0; + virtual void XM_CALLCONV SetView(FXMMATRIX value) = 0; + virtual void XM_CALLCONV SetProjection(FXMMATRIX value) = 0; + }; + + + // Abstract interface for effects which support directional lighting. + class IEffectLights + { + public: + virtual ~IEffectLights() { } + + virtual void __cdecl SetLightingEnabled(bool value) = 0; + virtual void __cdecl SetPerPixelLighting(bool value) = 0; + virtual void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) = 0; + + virtual void __cdecl SetLightEnabled(int whichLight, bool value) = 0; + virtual void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) = 0; + virtual void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) = 0; + virtual void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) = 0; + + virtual void __cdecl EnableDefaultLighting() = 0; + + static const int MaxDirectionalLights = 3; + }; + + + // Abstract interface for effects which support fog. + class IEffectFog + { + public: + virtual ~IEffectFog() { } + + virtual void __cdecl SetFogEnabled(bool value) = 0; + virtual void __cdecl SetFogStart(float value) = 0; + virtual void __cdecl SetFogEnd(float value) = 0; + virtual void XM_CALLCONV SetFogColor(FXMVECTOR value) = 0; + }; + + + // Abstract interface for effects which support skinning + class IEffectSkinning + { + public: + virtual ~IEffectSkinning() { } + + virtual void __cdecl SetWeightsPerVertex(int value) = 0; + virtual void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) = 0; + virtual void __cdecl ResetBoneTransforms() = 0; + + static const int MaxBones = 72; + }; + + + //---------------------------------------------------------------------------------- + // Built-in shader supports optional texture mapping, vertex coloring, directional lighting, and fog. + class BasicEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog + { + public: + explicit BasicEffect(_In_ ID3D11Device* device); + BasicEffect(BasicEffect&& moveFrom); + BasicEffect& operator= (BasicEffect&& moveFrom); + virtual ~BasicEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void XM_CALLCONV SetSpecularColor(FXMVECTOR value); + void __cdecl SetSpecularPower(float value); + void __cdecl DisableSpecular(); + void __cdecl SetAlpha(float value); + + // Light settings. + void __cdecl SetLightingEnabled(bool value) override; + void __cdecl SetPerPixelLighting(bool value) override; + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture setting. + void __cdecl SetTextureEnabled(bool value); + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + BasicEffect(BasicEffect const&) DIRECTX_CTOR_DELETE + BasicEffect& operator= (BasicEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports per-pixel alpha testing. + class AlphaTestEffect : public IEffect, public IEffectMatrices, public IEffectFog + { + public: + explicit AlphaTestEffect(_In_ ID3D11Device* device); + AlphaTestEffect(AlphaTestEffect&& moveFrom); + AlphaTestEffect& operator= (AlphaTestEffect&& moveFrom); + virtual ~AlphaTestEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void __cdecl SetAlpha(float value); + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture setting. + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + + // Alpha test settings. + void __cdecl SetAlphaFunction(D3D11_COMPARISON_FUNC value); + void __cdecl SetReferenceAlpha(int value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + AlphaTestEffect(AlphaTestEffect const&) DIRECTX_CTOR_DELETE + AlphaTestEffect& operator= (AlphaTestEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports two layer multitexturing (eg. for lightmaps or detail textures). + class DualTextureEffect : public IEffect, public IEffectMatrices, public IEffectFog + { + public: + explicit DualTextureEffect(_In_ ID3D11Device* device); + DualTextureEffect(DualTextureEffect&& moveFrom); + DualTextureEffect& operator= (DualTextureEffect&& moveFrom); + ~DualTextureEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void __cdecl SetAlpha(float value); + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture settings. + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetTexture2(_In_opt_ ID3D11ShaderResourceView* value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + DualTextureEffect(DualTextureEffect const&) DIRECTX_CTOR_DELETE + DualTextureEffect& operator= (DualTextureEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports cubic environment mapping. + class EnvironmentMapEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog + { + public: + explicit EnvironmentMapEffect(_In_ ID3D11Device* device); + EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom); + EnvironmentMapEffect& operator= (EnvironmentMapEffect&& moveFrom); + virtual ~EnvironmentMapEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void __cdecl SetAlpha(float value); + + // Light settings. + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Texture setting. + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + + // Environment map settings. + void __cdecl SetEnvironmentMap(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetEnvironmentMapAmount(float value); + void XM_CALLCONV SetEnvironmentMapSpecular(FXMVECTOR value); + void __cdecl SetFresnelFactor(float value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Unsupported interface methods. + void __cdecl SetLightingEnabled(bool value) override; + void __cdecl SetPerPixelLighting(bool value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + // Prevent copying. + EnvironmentMapEffect(EnvironmentMapEffect const&) DIRECTX_CTOR_DELETE + EnvironmentMapEffect& operator= (EnvironmentMapEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports skinned animation. + class SkinnedEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog, public IEffectSkinning + { + public: + explicit SkinnedEffect(_In_ ID3D11Device* device); + SkinnedEffect(SkinnedEffect&& moveFrom); + SkinnedEffect& operator= (SkinnedEffect&& moveFrom); + virtual ~SkinnedEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void XM_CALLCONV SetSpecularColor(FXMVECTOR value); + void __cdecl SetSpecularPower(float value); + void __cdecl DisableSpecular(); + void __cdecl SetAlpha(float value); + + // Light settings. + void __cdecl SetPerPixelLighting(bool value) override; + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Texture setting. + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + + // Animation settings. + void __cdecl SetWeightsPerVertex(int value) override; + void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override; + void __cdecl ResetBoneTransforms() override; + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Unsupported interface method. + void __cdecl SetLightingEnabled(bool value) override; + + // Prevent copying. + SkinnedEffect(SkinnedEffect const&) DIRECTX_CTOR_DELETE + SkinnedEffect& operator= (SkinnedEffect const&) DIRECTX_CTOR_DELETE + }; + + + + //---------------------------------------------------------------------------------- + // Built-in effect for Visual Studio Shader Designer (DGSL) shaders + class DGSLEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectSkinning + { + public: + explicit DGSLEffect( _In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader = nullptr, + _In_ bool enableSkinning = false ); + DGSLEffect(DGSLEffect&& moveFrom); + DGSLEffect& operator= (DGSLEffect&& moveFrom); + virtual ~DGSLEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetAmbientColor(FXMVECTOR value); + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void XM_CALLCONV SetSpecularColor(FXMVECTOR value); + void __cdecl SetSpecularPower(float value); + void __cdecl DisableSpecular(); + void __cdecl SetAlpha(float value); + + // Additional settings. + void XM_CALLCONV SetUVTransform(FXMMATRIX value); + void __cdecl SetViewport( float width, float height ); + void __cdecl SetTime( float time ); + void __cdecl SetAlphaDiscardEnable(bool value); + + // Light settings. + void __cdecl SetLightingEnabled(bool value) override; + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + static const int MaxDirectionalLights = 4; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture settings. + void __cdecl SetTextureEnabled(bool value); + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetTexture2(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetTexture(int whichTexture, _In_opt_ ID3D11ShaderResourceView* value); + + static const int MaxTextures = 8; + + // Animation setting. + void __cdecl SetWeightsPerVertex(int value) override; + void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override; + void __cdecl ResetBoneTransforms() override; + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Unsupported interface methods. + void __cdecl SetPerPixelLighting(bool value) override; + + // Prevent copying. + DGSLEffect(DGSLEffect const&) DIRECTX_CTOR_DELETE + DGSLEffect& operator= (DGSLEffect const&) DIRECTX_CTOR_DELETE + }; + + + + //---------------------------------------------------------------------------------- + // Abstract interface to factory for sharing effects and texture resources + class IEffectFactory + { + public: + virtual ~IEffectFactory() {} + + struct EffectInfo + { + const WCHAR* name; + bool perVertexColor; + bool enableSkinning; + bool enableDualTexture; + float specularPower; + float alpha; + DirectX::XMFLOAT3 ambientColor; + DirectX::XMFLOAT3 diffuseColor; + DirectX::XMFLOAT3 specularColor; + DirectX::XMFLOAT3 emissiveColor; + const WCHAR* texture; + const WCHAR* texture2; + + EffectInfo() { memset( this, 0, sizeof(EffectInfo) ); }; + }; + + virtual std::shared_ptr __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) = 0; + + virtual void __cdecl CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) = 0; + }; + + + // Factory for sharing effects and texture resources + class EffectFactory : public IEffectFactory + { + public: + explicit EffectFactory(_In_ ID3D11Device* device); + EffectFactory(EffectFactory&& moveFrom); + EffectFactory& operator= (EffectFactory&& moveFrom); + virtual ~EffectFactory(); + + // IEffectFactory methods. + virtual std::shared_ptr __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override; + virtual void __cdecl CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override; + + // Settings. + void __cdecl ReleaseCache(); + + void __cdecl SetSharing( bool enabled ); + + void __cdecl SetDirectory( _In_opt_z_ const WCHAR* path ); + + private: + // Private implementation. + class Impl; + + std::shared_ptr pImpl; + + // Prevent copying. + EffectFactory(EffectFactory const&) DIRECTX_CTOR_DELETE + EffectFactory& operator= (EffectFactory const&) DIRECTX_CTOR_DELETE + }; + + + // Factory for sharing Visual Studio Shader Designer (DGSL) shaders and texture resources + class DGSLEffectFactory : public IEffectFactory + { + public: + explicit DGSLEffectFactory(_In_ ID3D11Device* device); + DGSLEffectFactory(DGSLEffectFactory&& moveFrom); + DGSLEffectFactory& operator= (DGSLEffectFactory&& moveFrom); + virtual ~DGSLEffectFactory(); + + // IEffectFactory methods. + virtual std::shared_ptr __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override; + virtual void __cdecl CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override; + + // DGSL methods. + struct DGSLEffectInfo : public EffectInfo + { + const WCHAR* textures[6]; + const WCHAR* pixelShader; + + DGSLEffectInfo() { memset( this, 0, sizeof(DGSLEffectInfo) ); }; + }; + + virtual std::shared_ptr __cdecl CreateDGSLEffect( _In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ); + + virtual void __cdecl CreatePixelShader( _In_z_ const WCHAR* shader, _Outptr_ ID3D11PixelShader** pixelShader ); + + // Settings. + void __cdecl ReleaseCache(); + + void __cdecl SetSharing( bool enabled ); + + void __cdecl SetDirectory( _In_opt_z_ const WCHAR* path ); + + private: + // Private implementation. + class Impl; + + std::shared_ptr pImpl; + + // Prevent copying. + DGSLEffectFactory(DGSLEffectFactory const&) DIRECTX_CTOR_DELETE + DGSLEffectFactory& operator= (DGSLEffectFactory const&) DIRECTX_CTOR_DELETE + }; + +} + +#pragma warning(pop) diff --git a/deps/include/DirectXTK/GamePad.h b/deps/include/DirectXTK/GamePad.h new file mode 100644 index 0000000..bfeebda --- /dev/null +++ b/deps/include/DirectXTK/GamePad.h @@ -0,0 +1,244 @@ +//-------------------------------------------------------------------------------------- +// File: GamePad.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if (_WIN32_WINNT < 0x0A00 /*_WIN32_WINNT_WIN10*/) +#ifndef _XBOX_ONE +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) +#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/ ) +#pragma comment(lib,"xinput.lib") +#else +#pragma comment(lib,"xinput9_1_0.lib") +#endif +#endif +#endif +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + + +namespace DirectX +{ + class GamePad + { + public: + GamePad(); + GamePad(GamePad&& moveFrom); + GamePad& operator= (GamePad&& moveFrom); + virtual ~GamePad(); + +#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ ) || defined(_XBOX_ONE) + static const int MAX_PLAYER_COUNT = 8; +#else + static const int MAX_PLAYER_COUNT = 4; +#endif + + enum DeadZone + { + DEAD_ZONE_INDEPENDENT_AXES = 0, + DEAD_ZONE_CIRCULAR, + DEAD_ZONE_NONE, + }; + + struct Buttons + { + bool a; + bool b; + bool x; + bool y; + bool leftStick; + bool rightStick; + bool leftShoulder; + bool rightShoulder; + bool back; + bool start; + }; + + struct DPad + { + bool up; + bool down; + bool right; + bool left; + }; + + struct ThumbSticks + { + float leftX; + float leftY; + float rightX; + float rightY; + }; + + struct Triggers + { + float left; + float right; + }; + + struct State + { + bool connected; + uint64_t packet; + Buttons buttons; + DPad dpad; + ThumbSticks thumbSticks; + Triggers triggers; + + bool __cdecl IsConnected() const { return connected; } + + // Is the button pressed currently? + bool __cdecl IsAPressed() const { return buttons.a; } + bool __cdecl IsBPressed() const { return buttons.b; } + bool __cdecl IsXPressed() const { return buttons.x; } + bool __cdecl IsYPressed() const { return buttons.y; } + + bool __cdecl IsLeftStickPressed() const { return buttons.leftStick; } + bool __cdecl IsRightStickPressed() const { return buttons.rightStick; } + + bool __cdecl IsLeftShoulderPressed() const { return buttons.leftShoulder; } + bool __cdecl IsRightShoulderPressed() const { return buttons.rightShoulder; } + + bool __cdecl IsBackPressed() const { return buttons.back; } + bool __cdecl IsViewPressed() const { return buttons.back; } + bool __cdecl IsStartPressed() const { return buttons.start; } + bool __cdecl IsMenuPressed() const { return buttons.start; } + + bool __cdecl IsDPadDownPressed() const { return dpad.down; }; + bool __cdecl IsDPadUpPressed() const { return dpad.up; }; + bool __cdecl IsDPadLeftPressed() const { return dpad.left; }; + bool __cdecl IsDPadRightPressed() const { return dpad.right; }; + + bool __cdecl IsLeftThumbStickUp() const { return (thumbSticks.leftY > 0.5f) != 0; } + bool __cdecl IsLeftThumbStickDown() const { return (thumbSticks.leftY < -0.5f) != 0; } + bool __cdecl IsLeftThumbStickLeft() const { return (thumbSticks.leftX < -0.5f) != 0; } + bool __cdecl IsLeftThumbStickRight() const { return (thumbSticks.leftX > 0.5f) != 0; } + + bool __cdecl IsRightThumbStickUp() const { return (thumbSticks.rightY > 0.5f ) != 0; } + bool __cdecl IsRightThumbStickDown() const { return (thumbSticks.rightY < -0.5f) != 0; } + bool __cdecl IsRightThumbStickLeft() const { return (thumbSticks.rightX < -0.5f) != 0; } + bool __cdecl IsRightThumbStickRight() const { return (thumbSticks.rightX > 0.5f) != 0; } + + bool __cdecl IsLeftTriggerPressed() const { return (triggers.left > 0.5f) != 0; } + bool __cdecl IsRightTriggerPressed() const { return (triggers.right > 0.5f) != 0; } + }; + + struct Capabilities + { + enum Type + { + UNKNOWN = 0, + GAMEPAD, + WHEEL, + ARCADE_STICK, + FLIGHT_STICK, + DANCE_PAD, + GUITAR, + GUITAR_ALTERNATE, + DRUM_KIT, + GUITAR_BASS = 11, + ARCADE_PAD = 19, + }; + + bool connected; + Type gamepadType; + uint64_t id; + + bool __cdecl IsConnected() const { return connected; } + }; + + class ButtonStateTracker + { + public: + enum ButtonState + { + UP = 0, // Button is up + HELD = 1, // Button is held down + RELEASED = 2, // Button was just released + PRESSED = 3, // Buton was just pressed + }; + + ButtonState a; + ButtonState b; + ButtonState x; + ButtonState y; + + ButtonState leftStick; + ButtonState rightStick; + + ButtonState leftShoulder; + ButtonState rightShoulder; + + ButtonState back; + ButtonState start; + + ButtonState dpadUp; + ButtonState dpadDown; + ButtonState dpadLeft; + ButtonState dpadRight; + + ButtonStateTracker() { Reset(); } + + void __cdecl Update( const State& state ); + + void __cdecl Reset(); + + private: + State lastState; + }; + + // Retrieve the current state of the gamepad of the associated player index + State __cdecl GetState(int player, DeadZone deadZoneMode = DEAD_ZONE_INDEPENDENT_AXES); + + // Retrieve the current capabilities of the gamepad of the associated player index + Capabilities __cdecl GetCapabilities(int player); + + // Set the vibration motor speeds of the gamepad + bool __cdecl SetVibration( int player, float leftMotor, float rightMotor, float leftTrigger = 0.f, float rightTrigger = 0.f ); + + // Handle suspending/resuming + void __cdecl Suspend(); + void __cdecl Resume(); + + // Singleton + static GamePad& __cdecl Get(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + GamePad(GamePad const&) DIRECTX_CTOR_DELETE + GamePad& operator=(GamePad const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/deps/include/DirectXTK/GeometricPrimitive.h b/deps/include/DirectXTK/GeometricPrimitive.h new file mode 100644 index 0000000..c346c46 --- /dev/null +++ b/deps/include/DirectXTK/GeometricPrimitive.h @@ -0,0 +1,100 @@ +//-------------------------------------------------------------------------------------- +// File: GeometricPrimitive.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include +#include +#include +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + class IEffect; + + class GeometricPrimitive + { + public: + virtual ~GeometricPrimitive(); + + // Factory methods. + static std::unique_ptr __cdecl CreateCube (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateBox (_In_ ID3D11DeviceContext* deviceContext, const XMFLOAT3& size, bool rhcoords = true, bool invertn = false); + static std::unique_ptr __cdecl CreateSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 16, bool rhcoords = true, bool invertn = false); + static std::unique_ptr __cdecl CreateGeoSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 3, bool rhcoords = true); + static std::unique_ptr __cdecl CreateCylinder (_In_ ID3D11DeviceContext* deviceContext, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true); + static std::unique_ptr __cdecl CreateCone (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true); + static std::unique_ptr __cdecl CreateTorus (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true); + static std::unique_ptr __cdecl CreateTetrahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateOctahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateDodecahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateIcosahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateTeapot (_In_ ID3D11DeviceContext* deviceContext, float size = 1, size_t tessellation = 8, bool rhcoords = true); + + // Draw the primitive. + void XM_CALLCONV Draw(FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, FXMVECTOR color = Colors::White, _In_opt_ ID3D11ShaderResourceView* texture = nullptr, bool wireframe = false, + _In_opt_ std::function setCustomState = nullptr ); + + // Draw the primitive using a custom effect. + void __cdecl Draw( _In_ IEffect* effect, _In_ ID3D11InputLayout* inputLayout, bool alpha = false, bool wireframe = false, + _In_opt_ std::function setCustomState = nullptr ); + + // Create input layout for drawing with a custom effect. + void __cdecl CreateInputLayout( _In_ IEffect* effect, _Outptr_ ID3D11InputLayout** inputLayout ); + + private: + GeometricPrimitive(); + + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + GeometricPrimitive(GeometricPrimitive const&) DIRECTX_CTOR_DELETE + GeometricPrimitive& operator= (GeometricPrimitive const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/deps/include/DirectXTK/Keyboard.h b/deps/include/DirectXTK/Keyboard.h new file mode 100644 index 0000000..637e294 --- /dev/null +++ b/deps/include/DirectXTK/Keyboard.h @@ -0,0 +1,490 @@ +//-------------------------------------------------------------------------------------- +// File: Keyboard.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +namespace ABI { namespace Windows { namespace UI { namespace Core { struct ICoreWindow; } } } } +#endif + + +namespace DirectX +{ + class Keyboard + { + public: + Keyboard(); + Keyboard(Keyboard&& moveFrom); + Keyboard& operator= (Keyboard&& moveFrom); + virtual ~Keyboard(); + + enum Keys + { + None = 0, + + Back = 0x8, + Tab = 0x9, + + Enter = 0xd, + + Pause = 0x13, + CapsLock = 0x14, + Kana = 0x15, + + Kanji = 0x19, + + Escape = 0x1b, + ImeConvert = 0x1c, + ImeNoConvert = 0x1d, + + Space = 0x20, + PageUp = 0x21, + PageDown = 0x22, + End = 0x23, + Home = 0x24, + Left = 0x25, + Up = 0x26, + Right = 0x27, + Down = 0x28, + Select = 0x29, + Print = 0x2a, + Execute = 0x2b, + PrintScreen = 0x2c, + Insert = 0x2d, + Delete = 0x2e, + Help = 0x2f, + D0 = 0x30, + D1 = 0x31, + D2 = 0x32, + D3 = 0x33, + D4 = 0x34, + D5 = 0x35, + D6 = 0x36, + D7 = 0x37, + D8 = 0x38, + D9 = 0x39, + + A = 0x41, + B = 0x42, + C = 0x43, + D = 0x44, + E = 0x45, + F = 0x46, + G = 0x47, + H = 0x48, + I = 0x49, + J = 0x4a, + K = 0x4b, + L = 0x4c, + M = 0x4d, + N = 0x4e, + O = 0x4f, + P = 0x50, + Q = 0x51, + R = 0x52, + S = 0x53, + T = 0x54, + U = 0x55, + V = 0x56, + W = 0x57, + X = 0x58, + Y = 0x59, + Z = 0x5a, + LeftWindows = 0x5b, + RightWindows = 0x5c, + Apps = 0x5d, + + Sleep = 0x5f, + NumPad0 = 0x60, + NumPad1 = 0x61, + NumPad2 = 0x62, + NumPad3 = 0x63, + NumPad4 = 0x64, + NumPad5 = 0x65, + NumPad6 = 0x66, + NumPad7 = 0x67, + NumPad8 = 0x68, + NumPad9 = 0x69, + Multiply = 0x6a, + Add = 0x6b, + Separator = 0x6c, + Subtract = 0x6d, + + Decimal = 0x6e, + Divide = 0x6f, + F1 = 0x70, + F2 = 0x71, + F3 = 0x72, + F4 = 0x73, + F5 = 0x74, + F6 = 0x75, + F7 = 0x76, + F8 = 0x77, + F9 = 0x78, + F10 = 0x79, + F11 = 0x7a, + F12 = 0x7b, + F13 = 0x7c, + F14 = 0x7d, + F15 = 0x7e, + F16 = 0x7f, + F17 = 0x80, + F18 = 0x81, + F19 = 0x82, + F20 = 0x83, + F21 = 0x84, + F22 = 0x85, + F23 = 0x86, + F24 = 0x87, + + NumLock = 0x90, + Scroll = 0x91, + + LeftShift = 0xa0, + RightShift = 0xa1, + LeftControl = 0xa2, + RightControl = 0xa3, + LeftAlt = 0xa4, + RightAlt = 0xa5, + BrowserBack = 0xa6, + BrowserForward = 0xa7, + BrowserRefresh = 0xa8, + BrowserStop = 0xa9, + BrowserSearch = 0xaa, + BrowserFavorites = 0xab, + BrowserHome = 0xac, + VolumeMute = 0xad, + VolumeDown = 0xae, + VolumeUp = 0xaf, + MediaNextTrack = 0xb0, + MediaPreviousTrack = 0xb1, + MediaStop = 0xb2, + MediaPlayPause = 0xb3, + LaunchMail = 0xb4, + SelectMedia = 0xb5, + LaunchApplication1 = 0xb6, + LaunchApplication2 = 0xb7, + + OemSemicolon = 0xba, + OemPlus = 0xbb, + OemComma = 0xbc, + OemMinus = 0xbd, + OemPeriod = 0xbe, + OemQuestion = 0xbf, + OemTilde = 0xc0, + + OemOpenBrackets = 0xdb, + OemPipe = 0xdc, + OemCloseBrackets = 0xdd, + OemQuotes = 0xde, + Oem8 = 0xdf, + + OemBackslash = 0xe2, + + ProcessKey = 0xe5, + + OemCopy = 0xf2, + OemAuto = 0xf3, + OemEnlW = 0xf4, + + Attn = 0xf6, + Crsel = 0xf7, + Exsel = 0xf8, + EraseEof = 0xf9, + Play = 0xfa, + Zoom = 0xfb, + + Pa1 = 0xfd, + OemClear = 0xfe, + }; + + struct State + { + bool Reserved0 : 8; + bool Back : 1; // VK_BACK, 0x8 + bool Tab : 1; // VK_TAB, 0x9 + bool Reserved1 : 3; + bool Enter : 1; // VK_RETURN, 0xD + bool Reserved2 : 2; + bool Reserved3 : 3; + bool Pause : 1; // VK_PAUSE, 0x13 + bool CapsLock : 1; // VK_CAPITAL, 0x14 + bool Kana : 1; // VK_KANA, 0x15 + bool Reserved4 : 2; + bool Reserved5 : 1; + bool Kanji : 1; // VK_KANJI, 0x19 + bool Reserved6 : 1; + bool Escape : 1; // VK_ESCAPE, 0x1B + bool ImeConvert : 1; // VK_CONVERT, 0x1C + bool ImeNoConvert : 1; // VK_NONCONVERT, 0x1D + bool Reserved7 : 2; + bool Space : 1; // VK_SPACE, 0x20 + bool PageUp : 1; // VK_PRIOR, 0x21 + bool PageDown : 1; // VK_NEXT, 0x22 + bool End : 1; // VK_END, 0x23 + bool Home : 1; // VK_HOME, 0x24 + bool Left : 1; // VK_LEFT, 0x25 + bool Up : 1; // VK_UP, 0x26 + bool Right : 1; // VK_RIGHT, 0x27 + bool Down : 1; // VK_DOWN, 0x28 + bool Select : 1; // VK_SELECT, 0x29 + bool Print : 1; // VK_PRINT, 0x2A + bool Execute : 1; // VK_EXECUTE, 0x2B + bool PrintScreen : 1; // VK_SNAPSHOT, 0x2C + bool Insert : 1; // VK_INSERT, 0x2D + bool Delete : 1; // VK_DELETE, 0x2E + bool Help : 1; // VK_HELP, 0x2F + bool D0 : 1; // 0x30 + bool D1 : 1; // 0x31 + bool D2 : 1; // 0x32 + bool D3 : 1; // 0x33 + bool D4 : 1; // 0x34 + bool D5 : 1; // 0x35 + bool D6 : 1; // 0x36 + bool D7 : 1; // 0x37 + bool D8 : 1; // 0x38 + bool D9 : 1; // 0x39 + bool Reserved8 : 6; + bool Reserved9 : 1; + bool A : 1; // 0x41 + bool B : 1; // 0x42 + bool C : 1; // 0x43 + bool D : 1; // 0x44 + bool E : 1; // 0x45 + bool F : 1; // 0x46 + bool G : 1; // 0x47 + bool H : 1; // 0x48 + bool I : 1; // 0x49 + bool J : 1; // 0x4A + bool K : 1; // 0x4B + bool L : 1; // 0x4C + bool M : 1; // 0x4D + bool N : 1; // 0x4E + bool O : 1; // 0x4F + bool P : 1; // 0x50 + bool Q : 1; // 0x51 + bool R : 1; // 0x52 + bool S : 1; // 0x53 + bool T : 1; // 0x54 + bool U : 1; // 0x55 + bool V : 1; // 0x56 + bool W : 1; // 0x57 + bool X : 1; // 0x58 + bool Y : 1; // 0x59 + bool Z : 1; // 0x5A + bool LeftWindows : 1; // VK_LWIN, 0x5B + bool RightWindows : 1; // VK_RWIN, 0x5C + bool Apps : 1; // VK_APPS, 0x5D + bool Reserved10 : 1; + bool Sleep : 1; // VK_SLEEP, 0x5F + bool NumPad0 : 1; // VK_NUMPAD0, 0x60 + bool NumPad1 : 1; // VK_NUMPAD1, 0x61 + bool NumPad2 : 1; // VK_NUMPAD2, 0x62 + bool NumPad3 : 1; // VK_NUMPAD3, 0x63 + bool NumPad4 : 1; // VK_NUMPAD4, 0x64 + bool NumPad5 : 1; // VK_NUMPAD5, 0x65 + bool NumPad6 : 1; // VK_NUMPAD6, 0x66 + bool NumPad7 : 1; // VK_NUMPAD7, 0x67 + bool NumPad8 : 1; // VK_NUMPAD8, 0x68 + bool NumPad9 : 1; // VK_NUMPAD9, 0x69 + bool Multiply : 1; // VK_MULTIPLY, 0x6A + bool Add : 1; // VK_ADD, 0x6B + bool Separator : 1; // VK_SEPARATOR, 0x6C + bool Subtract : 1; // VK_SUBTRACT, 0x6D + bool Decimal : 1; // VK_DECIMANL, 0x6E + bool Divide : 1; // VK_DIVIDE, 0x6F + bool F1 : 1; // VK_F1, 0x70 + bool F2 : 1; // VK_F2, 0x71 + bool F3 : 1; // VK_F3, 0x72 + bool F4 : 1; // VK_F4, 0x73 + bool F5 : 1; // VK_F5, 0x74 + bool F6 : 1; // VK_F6, 0x75 + bool F7 : 1; // VK_F7, 0x76 + bool F8 : 1; // VK_F8, 0x77 + bool F9 : 1; // VK_F9, 0x78 + bool F10 : 1; // VK_F10, 0x79 + bool F11 : 1; // VK_F11, 0x7A + bool F12 : 1; // VK_F12, 0x7B + bool F13 : 1; // VK_F13, 0x7C + bool F14 : 1; // VK_F14, 0x7D + bool F15 : 1; // VK_F15, 0x7E + bool F16 : 1; // VK_F16, 0x7F + bool F17 : 1; // VK_F17, 0x80 + bool F18 : 1; // VK_F18, 0x81 + bool F19 : 1; // VK_F19, 0x82 + bool F20 : 1; // VK_F20, 0x83 + bool F21 : 1; // VK_F21, 0x84 + bool F22 : 1; // VK_F22, 0x85 + bool F23 : 1; // VK_F23, 0x86 + bool F24 : 1; // VK_F24, 0x87 + bool Reserved11 : 8; + bool NumLock : 1; // VK_NUMLOCK, 0x90 + bool Scroll : 1; // VK_SCROLL, 0x91 + bool Reserved12 : 6; + bool Reserved13 : 8; + bool LeftShift : 1; // VK_LSHIFT, 0xA0 + bool RightShift : 1; // VK_RSHIFT, 0xA1 + bool LeftControl : 1; // VK_LCONTROL, 0xA2 + bool RightControl : 1; // VK_RCONTROL, 0xA3 + bool LeftAlt : 1; // VK_LMENU, 0xA4 + bool RightAlt : 1; // VK_RMENU, 0xA5 + bool BrowserBack : 1; // VK_BROWSER_BACK, 0xA6 + bool BrowserForward : 1; // VK_BROWSER_FORWARD, 0xA7 + bool BrowserRefresh : 1; // VK_BROWSER_REFRESH, 0xA8 + bool BrowserStop : 1; // VK_BROWSER_STOP, 0xA9 + bool BrowserSearch : 1; // VK_BROWSER_SEARCH, 0xAA + bool BrowserFavorites : 1; // VK_BROWSER_FAVORITES, 0xAB + bool BrowserHome : 1; // VK_BROWSER_HOME, 0xAC + bool VolumeMute : 1; // VK_VOLUME_MUTE, 0xAD + bool VolumeDown : 1; // VK_VOLUME_DOWN, 0xAE + bool VolumeUp : 1; // VK_VOLUME_UP, 0xAF + bool MediaNextTrack : 1; // VK_MEDIA_NEXT_TRACK, 0xB0 + bool MediaPreviousTrack : 1;// VK_MEDIA_PREV_TRACK, 0xB1 + bool MediaStop : 1; // VK_MEDIA_STOP, 0xB2 + bool MediaPlayPause : 1; // VK_MEDIA_PLAY_PAUSE, 0xB3 + bool LaunchMail : 1; // VK_LAUNCH_MAIL, 0xB4 + bool SelectMedia : 1; // VK_LAUNCH_MEDIA_SELECT, 0xB5 + bool LaunchApplication1 : 1;// VK_LAUNCH_APP1, 0xB6 + bool LaunchApplication2 : 1;// VK_LAUNCH_APP2, 0xB7 + bool Reserved14 : 2; + bool OemSemicolon : 1; // VK_OEM_1, 0xBA + bool OemPlus : 1; // VK_OEM_PLUS, 0xBB + bool OemComma : 1; // VK_OEM_COMMA, 0xBC + bool OemMinus : 1; // VK_OEM_MINUS, 0xBD + bool OemPeriod : 1; // VK_OEM_PERIOD, 0xBE + bool OemQuestion : 1; // VK_OEM_2, 0xBF + bool OemTilde : 1; // VK_OEM_3, 0xC0 + bool Reserved15 : 7; + bool Reserved16 : 8; + bool Reserved17 : 8; + bool Reserved18 : 1; + bool OemOpenBrackets : 1; // VK_OEM_4, 0xDB + bool OemPipe : 1; // VK_OEM_5, 0xDC + bool OemCloseBrackets : 1; // VK_OEM_6, 0xDD + bool OemQuotes : 1; // VK_OEM_7, 0xDE + bool Oem8 : 1; // VK_OEM_8, 0xDF + bool Reserved19 : 2; + bool OemBackslash : 1; // VK_OEM_102, 0xE2 + bool Reserved20 : 2; + bool ProcessKey : 1; // VK_PROCESSKEY, 0xE5 + bool Reserved21 : 4; + bool Reserved22 : 8; + bool OemCopy : 1; // 0XF2 + bool OemAuto : 1; // 0xF3 + bool OemEnlW : 1; // 0xF4 + bool Reserved23 : 1; + bool Attn : 1; // VK_ATTN, 0xF6 + bool Crsel : 1; // VK_CRSEL, 0xF7 + bool Exsel : 1; // VK_EXSEL, 0xF8 + bool EraseEof : 1; // VK_EREOF, 0xF9 + bool Play : 1; // VK_PLAY, 0xFA + bool Zoom : 1; // VK_ZOOM, 0xFB + bool Reserved24 : 1; + bool Pa1 : 1; // VK_PA1, 0xFD + bool OemClear : 1; // VK_OEM_CLEAR, 0xFE + + bool __cdecl IsKeyDown(Keys key) const + { + if (key >= 0 && key <= 0xff) + { + auto ptr = reinterpret_cast(this); + unsigned int bf = 1u << (key & 0x1f); + return (ptr[(key >> 5)] & bf) != 0; + } + return false; + } + + bool __cdecl IsKeyUp(Keys key) const + { + if (key >= 0 && key <= 0xfe) + { + auto ptr = reinterpret_cast(this); + unsigned int bf = 1u << (key & 0x1f); + return (ptr[(key >> 5)] & bf) == 0; + } + return false; + } + }; + + class KeyboardStateTracker + { + public: + State released; + State pressed; + + KeyboardStateTracker() { Reset(); } + + void __cdecl Update(const State& state); + + void __cdecl Reset(); + + bool __cdecl IsKeyPressed(Keys key) const { return pressed.IsKeyDown(key); } + bool __cdecl IsKeyReleased(Keys key) const { return released.IsKeyDown(key); } + + public: + State lastState; + }; + + // Retrieve the current state of the keyboard + State __cdecl GetState() const; + + // Reset the keyboard state + void __cdecl Reset(); + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) && defined(WM_USER) + static void __cdecl ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam); +#endif + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) + void __cdecl SetWindow(ABI::Windows::UI::Core::ICoreWindow* window); +#ifdef __cplusplus_winrt + void __cdecl SetWindow(Windows::UI::Core::CoreWindow^ window) + { + // See https://msdn.microsoft.com/en-us/library/hh755802.aspx + SetWindow(reinterpret_cast(window)); + } +#endif +#endif + + // Singleton + static Keyboard& __cdecl Get(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + Keyboard(Keyboard const&) DIRECTX_CTOR_DELETE + Keyboard& operator=(Keyboard const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/deps/include/DirectXTK/Model.h b/deps/include/DirectXTK/Model.h new file mode 100644 index 0000000..cc98c55 --- /dev/null +++ b/deps/include/DirectXTK/Model.h @@ -0,0 +1,163 @@ +//-------------------------------------------------------------------------------------- +// File: Model.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + class IEffect; + class IEffectFactory; + class CommonStates; + class ModelMesh; + + //---------------------------------------------------------------------------------- + // Each mesh part is a submesh with a single effect + class ModelMeshPart + { + public: + ModelMeshPart(); + virtual ~ModelMeshPart(); + + uint32_t indexCount; + uint32_t startIndex; + uint32_t vertexOffset; + uint32_t vertexStride; + D3D_PRIMITIVE_TOPOLOGY primitiveType; + DXGI_FORMAT indexFormat; + Microsoft::WRL::ComPtr inputLayout; + Microsoft::WRL::ComPtr indexBuffer; + Microsoft::WRL::ComPtr vertexBuffer; + std::shared_ptr effect; + std::shared_ptr> vbDecl; + bool isAlpha; + + typedef std::vector> Collection; + + // Draw mesh part with custom effect + void __cdecl Draw( _In_ ID3D11DeviceContext* deviceContext, _In_ IEffect* ieffect, _In_ ID3D11InputLayout* iinputLayout, + _In_opt_ std::function setCustomState = nullptr ) const; + + // Create input layout for drawing with a custom effect. + void __cdecl CreateInputLayout( _In_ ID3D11Device* d3dDevice, _In_ IEffect* ieffect, _Outptr_ ID3D11InputLayout** iinputLayout ); + + // Change effect used by part and regenerate input layout (be sure to call Model::Modified as well) + void __cdecl ModifyEffect( _In_ ID3D11Device* d3dDevice, _In_ std::shared_ptr& ieffect, bool isalpha = false ); + }; + + + //---------------------------------------------------------------------------------- + // A mesh consists of one or more model mesh parts + class ModelMesh + { + public: + ModelMesh(); + virtual ~ModelMesh(); + + BoundingSphere boundingSphere; + BoundingBox boundingBox; + ModelMeshPart::Collection meshParts; + std::wstring name; + bool ccw; + bool pmalpha; + + typedef std::vector> Collection; + + // Setup states for drawing mesh + void __cdecl PrepareForRendering( _In_ ID3D11DeviceContext* deviceContext, CommonStates& states, bool alpha = false, bool wireframe = false ) const; + + // Draw the mesh + void XM_CALLCONV Draw( _In_ ID3D11DeviceContext* deviceContext, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, + bool alpha = false, _In_opt_ std::function setCustomState = nullptr ) const; + }; + + + //---------------------------------------------------------------------------------- + // A model consists of one or more meshes + class Model + { + public: + virtual ~Model(); + + ModelMesh::Collection meshes; + std::wstring name; + + // Draw all the meshes in the model + void XM_CALLCONV Draw( _In_ ID3D11DeviceContext* deviceContext, CommonStates& states, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, + bool wireframe = false, _In_opt_ std::function setCustomState = nullptr ) const; + + // Notify model that effects, parts list, or mesh list has changed + void __cdecl Modified() { mEffectCache.clear(); } + + // Update all effects used by the model + void __cdecl UpdateEffects( _In_ std::function setEffect ); + + // Loads a model from a Visual Studio Starter Kit .CMO file + static std::unique_ptr __cdecl CreateFromCMO( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, size_t dataSize, + _In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false ); + static std::unique_ptr __cdecl CreateFromCMO( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, + _In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false ); + + // Loads a model from a DirectX SDK .SDKMESH file + static std::unique_ptr __cdecl CreateFromSDKMESH( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize, + _In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false ); + static std::unique_ptr __cdecl CreateFromSDKMESH( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, + _In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false ); + + // Loads a model from a .VBO file + static std::unique_ptr __cdecl CreateFromVBO( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize, + _In_opt_ std::shared_ptr ieffect = nullptr, bool ccw = false, bool pmalpha = false ); + static std::unique_ptr __cdecl CreateFromVBO( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, + _In_opt_ std::shared_ptr ieffect = nullptr, bool ccw = false, bool pmalpha = false ); + + private: + std::set mEffectCache; + }; + } \ No newline at end of file diff --git a/deps/include/DirectXTK/Mouse.h b/deps/include/DirectXTK/Mouse.h new file mode 100644 index 0000000..ed44947 --- /dev/null +++ b/deps/include/DirectXTK/Mouse.h @@ -0,0 +1,129 @@ +//-------------------------------------------------------------------------------------- +// File: Mouse.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +namespace ABI { namespace Windows { namespace UI { namespace Core { struct ICoreWindow; } } } } +#endif + + +namespace DirectX +{ + class Mouse + { + public: + Mouse(); + Mouse(Mouse&& moveFrom); + Mouse& operator= (Mouse&& moveFrom); + virtual ~Mouse(); + + enum Mode + { + MODE_ABSOLUTE = 0, + MODE_RELATIVE, + }; + + struct State + { + bool leftButton; + bool middleButton; + bool rightButton; + bool xButton1; + bool xButton2; + int x; + int y; + int scrollWheelValue; + Mode positionMode; + }; + + class ButtonStateTracker + { + public: + enum ButtonState + { + UP = 0, // Button is up + HELD = 1, // Button is held down + RELEASED = 2, // Button was just released + PRESSED = 3, // Buton was just pressed + }; + + ButtonState leftButton; + ButtonState middleButton; + ButtonState rightButton; + ButtonState xButton1; + ButtonState xButton2; + + ButtonStateTracker() { Reset(); } + + void __cdecl Update( const State& state ); + + void __cdecl Reset(); + + private: + State lastState; + }; + + // Retrieve the current state of the mouse + State __cdecl GetState() const; + + // Resets the accumulated scroll wheel value + void __cdecl ResetScrollWheelValue(); + + // Sets mouse mode (defaults to absolute) + void __cdecl SetMode(Mode mode); + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) && defined(WM_USER) + void __cdecl SetWindow(HWND window); + static void __cdecl ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam); +#endif + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) + void __cdecl SetWindow(ABI::Windows::UI::Core::ICoreWindow* window); +#ifdef __cplusplus_winrt + void __cdecl SetWindow(Windows::UI::Core::CoreWindow^ window) + { + // See https://msdn.microsoft.com/en-us/library/hh755802.aspx + SetWindow(reinterpret_cast(window)); + } +#endif + static void __cdecl SetDpi(float dpi); +#endif + + // Singleton + static Mouse& __cdecl Get(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + Mouse(Mouse const&) DIRECTX_CTOR_DELETE + Mouse& operator=(Mouse const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/deps/include/DirectXTK/PrimitiveBatch.h b/deps/include/DirectXTK/PrimitiveBatch.h new file mode 100644 index 0000000..5009b1d --- /dev/null +++ b/deps/include/DirectXTK/PrimitiveBatch.h @@ -0,0 +1,158 @@ +//-------------------------------------------------------------------------------------- +// File: PrimitiveBatch.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include +#include + +#pragma warning(push) +#pragma warning(disable: 4005) +#include +#pragma warning(pop) + + +namespace DirectX +{ + namespace Internal + { + // Base class, not to be used directly: clients should access this via the derived PrimitiveBatch. + class PrimitiveBatchBase + { + protected: + PrimitiveBatchBase(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize); + PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom); + PrimitiveBatchBase& operator= (PrimitiveBatchBase&& moveFrom); + virtual ~PrimitiveBatchBase(); + + public: + // Begin/End a batch of primitive drawing operations. + void __cdecl Begin(); + void __cdecl End(); + + protected: + // Internal, untyped drawing method. + void __cdecl Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIndexed, _In_opt_count_(indexCount) uint16_t const* indices, size_t indexCount, size_t vertexCount, _Out_ void** pMappedVertices); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + PrimitiveBatchBase(PrimitiveBatchBase const&) DIRECTX_CTOR_DELETE + PrimitiveBatchBase& operator= (PrimitiveBatchBase const&) DIRECTX_CTOR_DELETE + }; + } + + + // Template makes the API typesafe, eg. PrimitiveBatch. + template + class PrimitiveBatch : public Internal::PrimitiveBatchBase + { + static const size_t DefaultBatchSize = 2048; + + public: + PrimitiveBatch(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices = DefaultBatchSize * 3, size_t maxVertices = DefaultBatchSize) + : PrimitiveBatchBase(deviceContext, maxIndices, maxVertices, sizeof(TVertex)) + { } + + PrimitiveBatch(PrimitiveBatch&& moveFrom) + : PrimitiveBatchBase(std::move(moveFrom)) + { } + + PrimitiveBatch& __cdecl operator= (PrimitiveBatch&& moveFrom) + { + PrimitiveBatchBase::operator=(std::move(moveFrom)); + return *this; + } + + + // Similar to the D3D9 API DrawPrimitiveUP. + void __cdecl Draw(D3D11_PRIMITIVE_TOPOLOGY topology, _In_reads_(vertexCount) TVertex const* vertices, size_t vertexCount) + { + void* mappedVertices; + + PrimitiveBatchBase::Draw(topology, false, nullptr, 0, vertexCount, &mappedVertices); + + memcpy(mappedVertices, vertices, vertexCount * sizeof(TVertex)); + } + + + // Similar to the D3D9 API DrawIndexedPrimitiveUP. + void __cdecl DrawIndexed(D3D11_PRIMITIVE_TOPOLOGY topology, _In_reads_(indexCount) uint16_t const* indices, size_t indexCount, _In_reads_(vertexCount) TVertex const* vertices, size_t vertexCount) + { + void* mappedVertices; + + PrimitiveBatchBase::Draw(topology, true, indices, indexCount, vertexCount, &mappedVertices); + + memcpy(mappedVertices, vertices, vertexCount * sizeof(TVertex)); + } + + + void __cdecl DrawLine(TVertex const& v1, TVertex const& v2) + { + TVertex* mappedVertices; + + PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_LINELIST, false, nullptr, 0, 2, reinterpret_cast(&mappedVertices)); + + mappedVertices[0] = v1; + mappedVertices[1] = v2; + } + + + void __cdecl DrawTriangle(TVertex const& v1, TVertex const& v2, TVertex const& v3) + { + TVertex* mappedVertices; + + PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, false, nullptr, 0, 3, reinterpret_cast(&mappedVertices)); + + mappedVertices[0] = v1; + mappedVertices[1] = v2; + mappedVertices[2] = v3; + } + + + void __cdecl DrawQuad(TVertex const& v1, TVertex const& v2, TVertex const& v3, TVertex const& v4) + { + static const uint16_t quadIndices[] = { 0, 1, 2, 0, 2, 3 }; + + TVertex* mappedVertices; + + PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, true, quadIndices, 6, 4, reinterpret_cast(&mappedVertices)); + + mappedVertices[0] = v1; + mappedVertices[1] = v2; + mappedVertices[2] = v3; + mappedVertices[3] = v4; + } + }; +} diff --git a/deps/include/DirectXTK/ScreenGrab.h b/deps/include/DirectXTK/ScreenGrab.h new file mode 100644 index 0000000..9fa0c0a --- /dev/null +++ b/deps/include/DirectXTK/ScreenGrab.h @@ -0,0 +1,64 @@ +//-------------------------------------------------------------------------------------- +// File: ScreenGrab.h +// +// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' +// when used on a Direct3D 11 Render Target). +// +// Note these functions are useful as a light-weight runtime screen grabber. For +// full-featured texture capture, DDS writer, and texture processing pipeline, +// see the 'Texconv' sample and the 'DirectXTex' library. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +namespace DirectX +{ + HRESULT __cdecl SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_z_ LPCWSTR fileName ); + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) + + HRESULT __cdecl SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_ REFGUID guidContainerFormat, + _In_z_ LPCWSTR fileName, + _In_opt_ const GUID* targetFormat = nullptr, + _In_opt_ std::function setCustomProps = nullptr ); + +#endif +} \ No newline at end of file diff --git a/deps/include/DirectXTK/SimpleMath.h b/deps/include/DirectXTK/SimpleMath.h new file mode 100644 index 0000000..1ab60e2 --- /dev/null +++ b/deps/include/DirectXTK/SimpleMath.h @@ -0,0 +1,845 @@ +//------------------------------------------------------------------------------------- +// SimpleMath.h -- Simplified C++ Math wrapper for DirectXMath +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#pragma once + +#include +#include + +#include +#include +#include + +namespace DirectX +{ + +namespace SimpleMath +{ + +struct Vector4; +struct Matrix; +struct Quaternion; +struct Plane; + +//------------------------------------------------------------------------------ +// 2D vector +struct Vector2 : public XMFLOAT2 +{ + Vector2() : XMFLOAT2(0.f, 0.f) {} + explicit Vector2(float x) : XMFLOAT2( x, x ) {} + Vector2(float _x, float _y) : XMFLOAT2(_x, _y) {} + explicit Vector2(_In_reads_(2) const float *pArray) : XMFLOAT2(pArray) {} + Vector2(FXMVECTOR V) { XMStoreFloat2( this, V ); } + Vector2(const XMFLOAT2& V) { this->x = V.x; this->y = V.y; } + + operator XMVECTOR() const { return XMLoadFloat2( this ); } + + // Comparision operators + bool operator == ( const Vector2& V ) const; + bool operator != ( const Vector2& V ) const; + + // Assignment operators + Vector2& operator= (const Vector2& V) { x = V.x; y = V.y; return *this; } + Vector2& operator= (const XMFLOAT2& V) { x = V.x; y = V.y; return *this; } + Vector2& operator+= (const Vector2& V); + Vector2& operator-= (const Vector2& V); + Vector2& operator*= (const Vector2& V); + Vector2& operator*= (float S); + Vector2& operator/= (float S); + + // Urnary operators + Vector2 operator+ () const { return *this; } + Vector2 operator- () const { return Vector2(-x, -y); } + + // Vector operations + bool InBounds( const Vector2& Bounds ) const; + + float Length() const; + float LengthSquared() const; + + float Dot( const Vector2& V ) const; + void Cross( const Vector2& V, Vector2& result ) const; + Vector2 Cross( const Vector2& V ) const; + + void Normalize(); + void Normalize( Vector2& result ) const; + + void Clamp( const Vector2& vmin, const Vector2& vmax ); + void Clamp( const Vector2& vmin, const Vector2& vmax, Vector2& result ) const; + + // Static functions + static float Distance( const Vector2& v1, const Vector2& v2 ); + static float DistanceSquared( const Vector2& v1, const Vector2& v2 ); + + static void Min( const Vector2& v1, const Vector2& v2, Vector2& result ); + static Vector2 Min( const Vector2& v1, const Vector2& v2 ); + + static void Max( const Vector2& v1, const Vector2& v2, Vector2& result ); + static Vector2 Max( const Vector2& v1, const Vector2& v2 ); + + static void Lerp( const Vector2& v1, const Vector2& v2, float t, Vector2& result ); + static Vector2 Lerp( const Vector2& v1, const Vector2& v2, float t ); + + static void SmoothStep( const Vector2& v1, const Vector2& v2, float t, Vector2& result ); + static Vector2 SmoothStep( const Vector2& v1, const Vector2& v2, float t ); + + static void Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g, Vector2& result ); + static Vector2 Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g ); + + static void CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t, Vector2& result ); + static Vector2 CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t ); + + static void Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t, Vector2& result ); + static Vector2 Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t ); + + static void Reflect( const Vector2& ivec, const Vector2& nvec, Vector2& result ); + static Vector2 Reflect( const Vector2& ivec, const Vector2& nvec ); + + static void Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex, Vector2& result ); + static Vector2 Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex ); + + static void Transform( const Vector2& v, const Quaternion& quat, Vector2& result ); + static Vector2 Transform( const Vector2& v, const Quaternion& quat ); + + static void Transform( const Vector2& v, const Matrix& m, Vector2& result ); + static Vector2 Transform( const Vector2& v, const Matrix& m ); + static void Transform( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector2* resultArray ); + + static void Transform( const Vector2& v, const Matrix& m, Vector4& result ); + static void Transform( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray ); + + static void TransformNormal( const Vector2& v, const Matrix& m, Vector2& result ); + static Vector2 TransformNormal( const Vector2& v, const Matrix& m ); + static void TransformNormal( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector2* resultArray ); + + // Constants + static const Vector2 Zero; + static const Vector2 One; + static const Vector2 UnitX; + static const Vector2 UnitY; +}; + +// Binary operators +Vector2 operator+ (const Vector2& V1, const Vector2& V2); +Vector2 operator- (const Vector2& V1, const Vector2& V2); +Vector2 operator* (const Vector2& V1, const Vector2& V2); +Vector2 operator* (const Vector2& V, float S); +Vector2 operator/ (const Vector2& V1, const Vector2& V2); +Vector2 operator* (float S, const Vector2& V); + +//------------------------------------------------------------------------------ +// 3D vector +struct Vector3 : public XMFLOAT3 +{ + Vector3() : XMFLOAT3(0.f, 0.f, 0.f) {} + explicit Vector3(float x) : XMFLOAT3( x, x, x ) {} + Vector3(float _x, float _y, float _z) : XMFLOAT3(_x, _y, _z) {} + explicit Vector3(_In_reads_(3) const float *pArray) : XMFLOAT3(pArray) {} + Vector3(FXMVECTOR V) { XMStoreFloat3( this, V ); } + Vector3(const XMFLOAT3& V) { this->x = V.x; this->y = V.y; this->z = V.z; } + + operator XMVECTOR() const { return XMLoadFloat3( this ); } + + // Comparision operators + bool operator == ( const Vector3& V ) const; + bool operator != ( const Vector3& V ) const; + + // Assignment operators + Vector3& operator= (const Vector3& V) { x = V.x; y = V.y; z = V.z; return *this; } + Vector3& operator= (const XMFLOAT3& V) { x = V.x; y = V.y; z = V.z; return *this; } + Vector3& operator+= (const Vector3& V); + Vector3& operator-= (const Vector3& V); + Vector3& operator*= (const Vector3& V); + Vector3& operator*= (float S); + Vector3& operator/= (float S); + + // Urnary operators + Vector3 operator+ () const { return *this; } + Vector3 operator- () const; + + // Vector operations + bool InBounds( const Vector3& Bounds ) const; + + float Length() const; + float LengthSquared() const; + + float Dot( const Vector3& V ) const; + void Cross( const Vector3& V, Vector3& result ) const; + Vector3 Cross( const Vector3& V ) const; + + void Normalize(); + void Normalize( Vector3& result ) const; + + void Clamp( const Vector3& vmin, const Vector3& vmax ); + void Clamp( const Vector3& vmin, const Vector3& vmax, Vector3& result ) const; + + // Static functions + static float Distance( const Vector3& v1, const Vector3& v2 ); + static float DistanceSquared( const Vector3& v1, const Vector3& v2 ); + + static void Min( const Vector3& v1, const Vector3& v2, Vector3& result ); + static Vector3 Min( const Vector3& v1, const Vector3& v2 ); + + static void Max( const Vector3& v1, const Vector3& v2, Vector3& result ); + static Vector3 Max( const Vector3& v1, const Vector3& v2 ); + + static void Lerp( const Vector3& v1, const Vector3& v2, float t, Vector3& result ); + static Vector3 Lerp( const Vector3& v1, const Vector3& v2, float t ); + + static void SmoothStep( const Vector3& v1, const Vector3& v2, float t, Vector3& result ); + static Vector3 SmoothStep( const Vector3& v1, const Vector3& v2, float t ); + + static void Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g, Vector3& result ); + static Vector3 Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g ); + + static void CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t, Vector3& result ); + static Vector3 CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t ); + + static void Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t, Vector3& result ); + static Vector3 Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t ); + + static void Reflect( const Vector3& ivec, const Vector3& nvec, Vector3& result ); + static Vector3 Reflect( const Vector3& ivec, const Vector3& nvec ); + + static void Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex, Vector3& result ); + static Vector3 Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex ); + + static void Transform( const Vector3& v, const Quaternion& quat, Vector3& result ); + static Vector3 Transform( const Vector3& v, const Quaternion& quat ); + + static void Transform( const Vector3& v, const Matrix& m, Vector3& result ); + static Vector3 Transform( const Vector3& v, const Matrix& m ); + static void Transform( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector3* resultArray ); + + static void Transform( const Vector3& v, const Matrix& m, Vector4& result ); + static void Transform( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray ); + + static void TransformNormal( const Vector3& v, const Matrix& m, Vector3& result ); + static Vector3 TransformNormal( const Vector3& v, const Matrix& m ); + static void TransformNormal( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector3* resultArray ); + + // Constants + static const Vector3 Zero; + static const Vector3 One; + static const Vector3 UnitX; + static const Vector3 UnitY; + static const Vector3 UnitZ; + static const Vector3 Up; + static const Vector3 Down; + static const Vector3 Right; + static const Vector3 Left; + static const Vector3 Forward; + static const Vector3 Backward; +}; + +// Binary operators +Vector3 operator+ (const Vector3& V1, const Vector3& V2); +Vector3 operator- (const Vector3& V1, const Vector3& V2); +Vector3 operator* (const Vector3& V1, const Vector3& V2); +Vector3 operator* (const Vector3& V, float S); +Vector3 operator/ (const Vector3& V1, const Vector3& V2); +Vector3 operator* (float S, const Vector3& V); + +//------------------------------------------------------------------------------ +// 4D vector +struct Vector4 : public XMFLOAT4 +{ + Vector4() : XMFLOAT4(0.f, 0.f, 0.f, 0.f) {} + explicit Vector4(float x) : XMFLOAT4( x, x, x, x ) {} + Vector4(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {} + explicit Vector4(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Vector4(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Vector4(const XMFLOAT4& V) { this->x = V.x; this->y = V.y; this->z = V.z; this->w = V.w; } + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + + // Comparision operators + bool operator == ( const Vector4& V ) const; + bool operator != ( const Vector4& V ) const; + + // Assignment operators + Vector4& operator= (const Vector4& V) { x = V.x; y = V.y; z = V.z; w = V.w; return *this; } + Vector4& operator= (const XMFLOAT4& V) { x = V.x; y = V.y; z = V.z; w = V.w; return *this; } + Vector4& operator+= (const Vector4& V); + Vector4& operator-= (const Vector4& V); + Vector4& operator*= (const Vector4& V); + Vector4& operator*= (float S); + Vector4& operator/= (float S); + + // Urnary operators + Vector4 operator+ () const { return *this; } + Vector4 operator- () const; + + // Vector operations + bool InBounds( const Vector4& Bounds ) const; + + float Length() const; + float LengthSquared() const; + + float Dot( const Vector4& V ) const; + void Cross( const Vector4& v1, const Vector4& v2, Vector4& result ) const; + Vector4 Cross( const Vector4& v1, const Vector4& v2 ) const; + + void Normalize(); + void Normalize( Vector4& result ) const; + + void Clamp( const Vector4& vmin, const Vector4& vmax ); + void Clamp( const Vector4& vmin, const Vector4& vmax, Vector4& result ) const; + + // Static functions + static float Distance( const Vector4& v1, const Vector4& v2 ); + static float DistanceSquared( const Vector4& v1, const Vector4& v2 ); + + static void Min( const Vector4& v1, const Vector4& v2, Vector4& result ); + static Vector4 Min( const Vector4& v1, const Vector4& v2 ); + + static void Max( const Vector4& v1, const Vector4& v2, Vector4& result ); + static Vector4 Max( const Vector4& v1, const Vector4& v2 ); + + static void Lerp( const Vector4& v1, const Vector4& v2, float t, Vector4& result ); + static Vector4 Lerp( const Vector4& v1, const Vector4& v2, float t ); + + static void SmoothStep( const Vector4& v1, const Vector4& v2, float t, Vector4& result ); + static Vector4 SmoothStep( const Vector4& v1, const Vector4& v2, float t ); + + static void Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g, Vector4& result ); + static Vector4 Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g ); + + static void CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t, Vector4& result ); + static Vector4 CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t ); + + static void Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t, Vector4& result ); + static Vector4 Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t ); + + static void Reflect( const Vector4& ivec, const Vector4& nvec, Vector4& result ); + static Vector4 Reflect( const Vector4& ivec, const Vector4& nvec ); + + static void Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex, Vector4& result ); + static Vector4 Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex ); + + static void Transform( const Vector2& v, const Quaternion& quat, Vector4& result ); + static Vector4 Transform( const Vector2& v, const Quaternion& quat ); + + static void Transform( const Vector3& v, const Quaternion& quat, Vector4& result ); + static Vector4 Transform( const Vector3& v, const Quaternion& quat ); + + static void Transform( const Vector4& v, const Quaternion& quat, Vector4& result ); + static Vector4 Transform( const Vector4& v, const Quaternion& quat ); + + static void Transform( const Vector4& v, const Matrix& m, Vector4& result ); + static Vector4 Transform( const Vector4& v, const Matrix& m ); + static void Transform( _In_reads_(count) const Vector4* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray ); + + // Constants + static const Vector4 Zero; + static const Vector4 One; + static const Vector4 UnitX; + static const Vector4 UnitY; + static const Vector4 UnitZ; + static const Vector4 UnitW; +}; + +// Binary operators +Vector4 operator+ (const Vector4& V1, const Vector4& V2); +Vector4 operator- (const Vector4& V1, const Vector4& V2); +Vector4 operator* (const Vector4& V1, const Vector4& V2); +Vector4 operator* (const Vector4& V, float S); +Vector4 operator/ (const Vector4& V1, const Vector4& V2); +Vector4 operator* (float S, const Vector4& V); + +//------------------------------------------------------------------------------ +// 4x4 Matrix (assumes right-handed cooordinates) +struct Matrix : public XMFLOAT4X4 +{ + Matrix() : XMFLOAT4X4( 1.f, 0, 0, 0, + 0, 1.f, 0, 0, + 0, 0, 1.f, 0, + 0, 0, 0, 1.f ) {} + Matrix(float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23, + float m30, float m31, float m32, float m33) : XMFLOAT4X4(m00, m01, m02, m03, + m10, m11, m12, m13, + m20, m21, m22, m23, + m30, m31, m32, m33) {} + explicit Matrix( const Vector3& r0, const Vector3& r1, const Vector3& r2 ) : XMFLOAT4X4( r0.x, r0.y, r0.z, 0, + r1.x, r1.y, r1.z, 0, + r2.x, r2.y, r2.z, 0, + 0, 0, 0, 1.f ) {} + explicit Matrix( const Vector4& r0, const Vector4& r1, const Vector4& r2, const Vector4& r3 ) : XMFLOAT4X4( r0.x, r0.y, r0.z, r0.w, + r1.x, r1.y, r1.z, r1.w, + r2.x, r2.y, r2.z, r2.w, + r3.x, r3.y, r3.z, r3.w ) {} + Matrix(const XMFLOAT4X4& M) { memcpy_s(this, sizeof(float)*16, &M, sizeof(XMFLOAT4X4)); } + + explicit Matrix(_In_reads_(16) const float *pArray) : XMFLOAT4X4(pArray) {} + Matrix( CXMMATRIX M ) { XMStoreFloat4x4( this, M ); } + + operator XMMATRIX() const { return XMLoadFloat4x4( this ); } + + // Comparision operators + bool operator == ( const Matrix& M ) const; + bool operator != ( const Matrix& M ) const; + + // Assignment operators + Matrix& operator= (const Matrix& M) { memcpy_s( this, sizeof(float)*16, &M, sizeof(float)*16 ); return *this; } + Matrix& operator= (const XMFLOAT4X4& M) { memcpy_s( this, sizeof(float)*16, &M, sizeof(XMFLOAT4X4) ); return *this; } + Matrix& operator+= (const Matrix& M); + Matrix& operator-= (const Matrix& M); + Matrix& operator*= (const Matrix& M); + Matrix& operator*= (float S); + Matrix& operator/= (float S); + + Matrix& operator/= (const Matrix& M); + // Element-wise divide + + // Urnary operators + Matrix operator+ () const { return *this; } + Matrix operator- () const; + + // Properties + Vector3 Up() const { return Vector3( _21, _22, _23); } + void Up( const Vector3& v ) { _21 = v.x; _22 = v.y; _23 = v.z; } + + Vector3 Down() const { return Vector3( -_21, -_22, -_23); } + void Down( const Vector3& v ) { _21 = -v.x; _22 = -v.y; _23 = -v.z; } + + Vector3 Right() const { return Vector3( _11, _12, _13 ); } + void Right( const Vector3& v ) { _11 = v.x; _12 = v.y; _13 = v.z; } + + Vector3 Left() const { return Vector3( -_11, -_12, -_13 ); } + void Left( const Vector3& v ) { _11 = -v.x; _12 = -v.y; _13 = -v.z; } + + Vector3 Forward() const { return Vector3( -_31, -_32, -_33 ); } + void Forward( const Vector3& v ) { _31 = -v.x; _32 = -v.y; _33 = -v.z; } + + Vector3 Backward() const { return Vector3( _31, _32, _33 ); } + void Backward( const Vector3& v ) { _31 = v.x; _32 = v.y; _33 = v.z; } + + Vector3 Translation() const { return Vector3( _41, _42, _43 ); } + void Translation( const Vector3& v ) { _41 = v.x; _42 = v.y; _43 = v.z; } + + // Matrix operations + bool Decompose( Vector3& scale, Quaternion& rotation, Vector3& translation ); + + Matrix Transpose() const; + void Transpose( Matrix& result ) const; + + Matrix Invert() const; + void Invert( Matrix& result ) const; + + float Determinant() const; + + // Static functions + static Matrix CreateBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& cameraUp, _In_opt_ const Vector3* cameraForward = nullptr ); + + static Matrix CreateConstrainedBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& rotateAxis, + _In_opt_ const Vector3* cameraForward = nullptr, _In_opt_ const Vector3* objectForward = nullptr); + + static Matrix CreateTranslation( const Vector3& position ); + static Matrix CreateTranslation( float x, float y, float z ); + + static Matrix CreateScale( const Vector3& scales ); + static Matrix CreateScale( float xs, float ys, float zs ); + static Matrix CreateScale( float scale ); + + static Matrix CreateRotationX( float radians ); + static Matrix CreateRotationY( float radians ); + static Matrix CreateRotationZ( float radians ); + + static Matrix CreateFromAxisAngle( const Vector3& axis, float angle ); + + static Matrix CreatePerspectiveFieldOfView( float fov, float aspectRatio, float nearPlane, float farPlane ); + static Matrix CreatePerspective( float width, float height, float nearPlane, float farPlane ); + static Matrix CreatePerspectiveOffCenter( float left, float right, float bottom, float top, float nearPlane, float farPlane ); + static Matrix CreateOrthographic( float width, float height, float zNearPlane, float zFarPlane ); + static Matrix CreateOrthographicOffCenter( float left, float right, float bottom, float top, float zNearPlane, float zFarPlane ); + + static Matrix CreateLookAt( const Vector3& position, const Vector3& target, const Vector3& up ); + static Matrix CreateWorld( const Vector3& position, const Vector3& forward, const Vector3& up ); + + static Matrix CreateFromQuaternion( const Quaternion& quat ); + + static Matrix CreateFromYawPitchRoll( float yaw, float pitch, float roll ); + + static Matrix CreateShadow( const Vector3& lightDir, const Plane& plane ); + + static Matrix CreateReflection( const Plane& plane ); + + static void Lerp( const Matrix& M1, const Matrix& M2, float t, Matrix& result ); + static Matrix Lerp( const Matrix& M1, const Matrix& M2, float t ); + + static void Transform( const Matrix& M, const Quaternion& rotation, Matrix& result ); + static Matrix Transform( const Matrix& M, const Quaternion& rotation ); + + // Constants + static const Matrix Identity; +}; + +// Binary operators +Matrix operator+ (const Matrix& M1, const Matrix& M2); +Matrix operator- (const Matrix& M1, const Matrix& M2); +Matrix operator* (const Matrix& M1, const Matrix& M2); +Matrix operator* (const Matrix& M, float S); +Matrix operator/ (const Matrix& M, float S); +Matrix operator/ (const Matrix& M1, const Matrix& M2); + // Element-wise divide +Matrix operator* (float S, const Matrix& M); + + +//----------------------------------------------------------------------------- +// Plane +struct Plane : public XMFLOAT4 +{ + Plane() : XMFLOAT4(0.f, 1.f, 0.f, 0.f) {} + Plane(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {} + Plane(const Vector3& normal, float d) : XMFLOAT4(normal.x, normal.y, normal.z, d) {} + Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3 ); + Plane(const Vector3& point, const Vector3& normal); + explicit Plane(const Vector4& v) : XMFLOAT4(v.x, v.y, v.z, v.w) {} + explicit Plane(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Plane(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Plane(const XMFLOAT4& p) { this->x = p.x; this->y = p.y; this->z = p.z; this->w = p.w; } + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + + // Comparision operators + bool operator == ( const Plane& p ) const; + bool operator != ( const Plane& p ) const; + + // Assignment operators + Plane& operator= (const Plane& p) { x = p.x; y = p.y; z = p.z; w = p.w; return *this; } + Plane& operator= (const XMFLOAT4& p) { x = p.x; y = p.y; z = p.z; w = p.w; return *this; } + + // Properties + Vector3 Normal() const { return Vector3( x, y, z ); } + void Normal( const Vector3& normal ) { x = normal.x; y = normal.y; z = normal.z; } + + float D() const { return w; } + void D(float d) { w = d; } + + // Plane operations + void Normalize(); + void Normalize( Plane& result ) const; + + float Dot( const Vector4& v ) const; + float DotCoordinate( const Vector3& position ) const; + float DotNormal( const Vector3& normal ) const; + + // Static functions + static void Transform( const Plane& plane, const Matrix& M, Plane& result ); + static Plane Transform( const Plane& plane, const Matrix& M ); + + static void Transform( const Plane& plane, const Quaternion& rotation, Plane& result ); + static Plane Transform( const Plane& plane, const Quaternion& rotation ); + // Input quaternion must be the inverse transpose of the transformation +}; + +//------------------------------------------------------------------------------ +// Quaternion +struct Quaternion : public XMFLOAT4 +{ + Quaternion() : XMFLOAT4(0, 0, 0, 1.f) {} + Quaternion( float _x, float _y, float _z, float _w ) : XMFLOAT4(_x, _y, _z, _w) {} + Quaternion( const Vector3& v, float scalar ) : XMFLOAT4( v.x, v.y, v.z, scalar ) {} + explicit Quaternion( const Vector4& v ) : XMFLOAT4( v.x, v.y, v.z, v.w ) {} + explicit Quaternion(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Quaternion(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Quaternion(const XMFLOAT4& q) { this->x = q.x; this->y = q.y; this->z = q.z; this->w = q.w; } + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + + // Comparision operators + bool operator == ( const Quaternion& q ) const; + bool operator != ( const Quaternion& q ) const; + + // Assignment operators + Quaternion& operator= (const Quaternion& q) { x = q.x; y = q.y; z = q.z; w = q.w; return *this; } + Quaternion& operator= (const XMFLOAT4& q) { x = q.x; y = q.y; z = q.z; w = q.w; return *this; } + Quaternion& operator+= (const Quaternion& q); + Quaternion& operator-= (const Quaternion& q); + Quaternion& operator*= (const Quaternion& q); + Quaternion& operator*= (float S); + Quaternion& operator/= (const Quaternion& q); + + // Urnary operators + Quaternion operator+ () const { return *this; } + Quaternion operator- () const; + + // Quaternion operations + float Length() const; + float LengthSquared() const; + + void Normalize(); + void Normalize( Quaternion& result ) const; + + void Conjugate(); + void Conjugate( Quaternion& result ) const; + + void Inverse( Quaternion& result ) const; + + float Dot( const Quaternion& Q ) const; + + // Static functions + static Quaternion CreateFromAxisAngle( const Vector3& axis, float angle ); + static Quaternion CreateFromYawPitchRoll( float yaw, float pitch, float roll ); + static Quaternion CreateFromRotationMatrix( const Matrix& M ); + + static void Lerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ); + static Quaternion Lerp( const Quaternion& q1, const Quaternion& q2, float t ); + + static void Slerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ); + static Quaternion Slerp( const Quaternion& q1, const Quaternion& q2, float t ); + + static void Concatenate( const Quaternion& q1, const Quaternion& q2, Quaternion& result ); + static Quaternion Concatenate( const Quaternion& q1, const Quaternion& q2 ); + + // Constants + static const Quaternion Identity; +}; + +// Binary operators +Quaternion operator+ (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator- (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator* (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator* (const Quaternion& Q, float S); +Quaternion operator/ (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator* (float S, const Quaternion& Q); + +//------------------------------------------------------------------------------ +// Color +struct Color : public XMFLOAT4 +{ + Color() : XMFLOAT4(0, 0, 0, 1.f) {} + Color( float _r, float _g, float _b ) : XMFLOAT4(_r, _g, _b, 1.f) {} + Color( float _r, float _g, float _b, float _a ) : XMFLOAT4(_r, _g, _b, _a) {} + explicit Color( const Vector3& clr ) : XMFLOAT4( clr.x, clr.y, clr.z, 1.f ) {} + explicit Color( const Vector4& clr ) : XMFLOAT4( clr.x, clr.y, clr.z, clr.w ) {} + explicit Color(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Color(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Color(const XMFLOAT4& c) { this->x = c.x; this->y = c.y; this->z = c.z; this->w = c.w; } + + explicit Color( const DirectX::PackedVector::XMCOLOR& Packed ); + // BGRA Direct3D 9 D3DCOLOR packed color + + explicit Color( const DirectX::PackedVector::XMUBYTEN4& Packed ); + // RGBA XNA Game Studio packed color + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + operator const float*() const { return reinterpret_cast(this); } + + // Comparision operators + bool operator == ( const Color& c ) const; + bool operator != ( const Color& c ) const; + + // Assignment operators + Color& operator= (const Color& c) { x = c.x; y = c.y; z = c.z; w = c.w; return *this; } + Color& operator= (const XMFLOAT4& c) { x = c.x; y = c.y; z = c.z; w = c.w; return *this; } + Color& operator+= (const Color& c); + Color& operator-= (const Color& c); + Color& operator*= (const Color& c); + Color& operator*= (float S); + Color& operator/= (const Color& c); + + // Urnary operators + Color operator+ () const { return *this; } + Color operator- () const; + + // Properties + float R() const { return x; } + void R(float r) { x = r; } + + float G() const { return y; } + void G(float g) { y = g; } + + float B() const { return z; } + void B(float b) { z = b; } + + float A() const { return w; } + void A(float a) { w = a; } + + // Color operations + DirectX::PackedVector::XMCOLOR BGRA() const; + DirectX::PackedVector::XMUBYTEN4 RGBA() const; + + Vector3 ToVector3() const; + Vector4 ToVector4() const; + + void Negate(); + void Negate( Color& result ) const; + + void Saturate(); + void Saturate( Color& result ) const; + + void Premultiply(); + void Premultiply( Color& result ) const; + + void AdjustSaturation( float sat ); + void AdjustSaturation( float sat, Color& result ) const; + + void AdjustContrast( float contrast ); + void AdjustContrast( float contrast, Color& result ) const; + + // Static functions + static void Modulate( const Color& c1, const Color& c2, Color& result ); + static Color Modulate( const Color& c1, const Color& c2 ); + + static void Lerp( const Color& c1, const Color& c2, float t, Color& result ); + static Color Lerp( const Color& c1, const Color& c2, float t ); +}; + +// Binary operators +Color operator+ (const Color& C1, const Color& C2); +Color operator- (const Color& C1, const Color& C2); +Color operator* (const Color& C1, const Color& C2); +Color operator* (const Color& C, float S); +Color operator/ (const Color& C1, const Color& C2); +Color operator* (float S, const Color& C); + +//------------------------------------------------------------------------------ +// Ray +class Ray +{ +public: + Vector3 position; + Vector3 direction; + + Ray() : position(0,0,0), direction(0,0,1) {} + Ray( const Vector3& pos, const Vector3& dir ) : position(pos), direction(dir) {} + + // Comparision operators + bool operator == ( const Ray& r ) const; + bool operator != ( const Ray& r ) const; + + // Ray operations + bool Intersects( const BoundingSphere& sphere, _Out_ float& Dist ) const; + bool Intersects( const BoundingBox& box, _Out_ float& Dist ) const; + bool Intersects( const Vector3& tri0, const Vector3& tri1, const Vector3& tri2, _Out_ float& Dist ) const; + bool Intersects( const Plane& plane, _Out_ float& Dist ) const; +}; + +#include "SimpleMath.inl" + +}; // namespace SimpleMath + +}; // namespace DirectX + +//------------------------------------------------------------------------------ +// Support for SimpleMath and Standard C++ Library containers +namespace std +{ + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Vector2& V1, const DirectX::SimpleMath::Vector2& V2) const + { + return ( (V1.x < V2.x) || ((V1.x == V2.x) && (V1.y < V2.y)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Vector3& V1, const DirectX::SimpleMath::Vector3& V2) const + { + return ( (V1.x < V2.x) + || ((V1.x == V2.x) && (V1.y < V2.y)) + || ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z < V2.z)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Vector4& V1, const DirectX::SimpleMath::Vector4& V2) const + { + return ( (V1.x < V2.x) + || ((V1.x == V2.x) && (V1.y < V2.y)) + || ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z < V2.z)) + || ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z) && (V1.w < V2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Matrix& M1, const DirectX::SimpleMath::Matrix& M2) const + { + if (M1._11 != M2._11) return M1._11 < M2._11; + if (M1._12 != M2._12) return M1._12 < M2._12; + if (M1._13 != M2._13) return M1._13 < M2._13; + if (M1._14 != M2._14) return M1._14 < M2._14; + if (M1._21 != M2._21) return M1._21 < M2._21; + if (M1._22 != M2._22) return M1._22 < M2._22; + if (M1._23 != M2._23) return M1._23 < M2._23; + if (M1._24 != M2._24) return M1._24 < M2._24; + if (M1._31 != M2._31) return M1._31 < M2._31; + if (M1._32 != M2._32) return M1._32 < M2._32; + if (M1._33 != M2._33) return M1._33 < M2._33; + if (M1._34 != M2._34) return M1._34 < M2._34; + if (M1._41 != M2._41) return M1._41 < M2._41; + if (M1._42 != M2._42) return M1._42 < M2._42; + if (M1._43 != M2._43) return M1._43 < M2._43; + if (M1._44 != M2._44) return M1._44 < M2._44; + + return false; + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Plane& P1, const DirectX::SimpleMath::Plane& P2) const + { + return ( (P1.x < P2.x) + || ((P1.x == P2.x) && (P1.y < P2.y)) + || ((P1.x == P2.x) && (P1.y == P2.y) && (P1.z < P2.z)) + || ((P1.x == P2.x) && (P1.y == P2.y) && (P1.z == P2.z) && (P1.w < P2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Quaternion& Q1, const DirectX::SimpleMath::Quaternion& Q2) const + { + return ( (Q1.x < Q2.x) + || ((Q1.x == Q2.x) && (Q1.y < Q2.y)) + || ((Q1.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z < Q2.z)) + || ((Q1.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z == Q2.z) && (Q1.w < Q2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Color& C1, const DirectX::SimpleMath::Color& C2) const + { + return ( (C1.x < C2.x) + || ((C1.x == C2.x) && (C1.y < C2.y)) + || ((C1.x == C2.x) && (C1.y == C2.y) && (C1.z < C2.z)) + || ((C1.x == C2.x) && (C1.y == C2.y) && (C1.z == C2.z) && (C1.w < C2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Ray& R1, const DirectX::SimpleMath::Ray& R2) const + { + if (R1.position.x != R2.position.x) return R1.position.x < R2.position.x; + if (R1.position.y != R2.position.y) return R1.position.y < R2.position.y; + if (R1.position.z != R2.position.z) return R1.position.z < R2.position.z; + + if (R1.direction.x != R2.direction.x) return R1.direction.x < R2.direction.x; + if (R1.direction.y != R2.direction.y) return R1.direction.y < R2.direction.y; + if (R1.direction.z != R2.direction.z) return R1.direction.z < R2.direction.z; + + return false; + } + }; + +} // namespace std diff --git a/deps/include/DirectXTK/SimpleMath.inl b/deps/include/DirectXTK/SimpleMath.inl new file mode 100644 index 0000000..dbfb408 --- /dev/null +++ b/deps/include/DirectXTK/SimpleMath.inl @@ -0,0 +1,3409 @@ +//------------------------------------------------------------------------------------- +// SimpleMath.inl -- Simplified C++ Math wrapper for DirectXMath +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#pragma once + +/**************************************************************************** + * + * Vector2 + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Vector2::operator == ( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + return XMVector2Equal( v1, v2 ); +} + +inline bool Vector2::operator != ( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + return XMVector2NotEqual( v1, v2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Vector2& Vector2::operator+= (const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorAdd(v1,v2); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator-= (const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorSubtract(v1,v2); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator*= (const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorMultiply(v1,v2); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVectorScale(v1,S); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.0f ); + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVectorScale(v1, 1.f/S); + XMStoreFloat2( this, X ); + return *this; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Vector2 operator+ (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorAdd(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator- (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorSubtract(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator* (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorMultiply(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator* (const Vector2& V, float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator/ (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorDivide(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator* (float S, const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Vector operations +//------------------------------------------------------------------------------ + +inline bool Vector2::InBounds( const Vector2& Bounds ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &Bounds ); + return XMVector2InBounds( v1, v2 ); +} + +inline float Vector2::Length() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2Length( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector2::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2LengthSq( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector2::Dot( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVector2Dot( v1, v2 ); + return XMVectorGetX( X ); +} + +inline void Vector2::Cross( const Vector2& V, Vector2& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR R = XMVector2Cross( v1, v2 ); + XMStoreFloat2( &result, R ); +} + +inline Vector2 Vector2::Cross( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR R = XMVector2Cross( v1, v2 ); + + Vector2 result; + XMStoreFloat2( &result, R ); + return result; +} + +inline void Vector2::Normalize() +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2Normalize( v1 ); + XMStoreFloat2( this, X ); +} + +inline void Vector2::Normalize( Vector2& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2Normalize( v1 ); + XMStoreFloat2( &result, X ); +} + +inline void Vector2::Clamp( const Vector2& vmin, const Vector2& vmax ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &vmin ); + XMVECTOR v3 = XMLoadFloat2( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat2( this, X ); +} + +inline void Vector2::Clamp( const Vector2& vmin, const Vector2& vmax, Vector2& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &vmin ); + XMVECTOR v3 = XMLoadFloat2( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat2( &result, X ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline float Vector2::Distance( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector2Length( V ); + return XMVectorGetX( X ); +} + +inline float Vector2::DistanceSquared( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector2LengthSq( V ); + return XMVectorGetX( X ); +} + +inline void Vector2::Min( const Vector2& v1, const Vector2& v2, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Min( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Max( const Vector2& v1, const Vector2& v2, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Max( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Lerp( const Vector2& v1, const Vector2& v2, float t, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Lerp( const Vector2& v1, const Vector2& v2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::SmoothStep( const Vector2& v1, const Vector2& v2, float t, Vector2& result ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::SmoothStep( const Vector2& v1, const Vector2& v2, float t ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR x4 = XMLoadFloat2( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR x4 = XMLoadFloat2( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &t1 ); + XMVECTOR x3 = XMLoadFloat2( &v2 ); + XMVECTOR x4 = XMLoadFloat2( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &t1 ); + XMVECTOR x3 = XMLoadFloat2( &v2 ); + XMVECTOR x4 = XMLoadFloat2( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Reflect( const Vector2& ivec, const Vector2& nvec, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Reflect( i, n ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Reflect( const Vector2& ivec, const Vector2& nvec ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Reflect( i, n ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Refract( i, n, refractionIndex ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Refract( i, n, refractionIndex ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Transform( const Vector2& v, const Quaternion& quat, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Transform( const Vector2& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Transform( const Vector2& v, const Matrix& m, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformCoord( v1, M ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Transform( const Vector2& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformCoord( v1, M ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector2::Transform( const Vector2* varray, size_t count, const Matrix& m, Vector2* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector2TransformCoordStream( resultArray, sizeof(XMFLOAT2), varray, sizeof(XMFLOAT2), count, M ); +} + +inline void Vector2::Transform( const Vector2& v, const Matrix& m, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2Transform( v1, M ); + XMStoreFloat4( &result, X ); +} + +_Use_decl_annotations_ +inline void Vector2::Transform( const Vector2* varray, size_t count, const Matrix& m, Vector4* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector2TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT2), count, M ); +} + +inline void Vector2::TransformNormal( const Vector2& v, const Matrix& m, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformNormal( v1, M ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::TransformNormal( const Vector2& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformNormal( v1, M ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector2::TransformNormal( const Vector2* varray, size_t count, const Matrix& m, Vector2* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector2TransformNormalStream( resultArray, sizeof(XMFLOAT2), varray, sizeof(XMFLOAT2), count, M ); +} + + +/**************************************************************************** + * + * Vector3 + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Vector3::operator == ( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + return XMVector3Equal( v1, v2 ); +} + +inline bool Vector3::operator != ( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + return XMVector3NotEqual( v1, v2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Vector3& Vector3::operator+= (const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorAdd(v1,v2); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator-= (const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorSubtract(v1,v2); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator*= (const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorMultiply(v1,v2); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVectorScale(v1,S); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.0f ); + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVectorScale(v1, 1.f/S); + XMStoreFloat3( this, X ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Vector3 Vector3::operator- () const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVectorNegate( v1 ); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Vector3 operator+ (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorAdd(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator- (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorSubtract(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator* (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorMultiply(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator* (const Vector3& V, float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator/ (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorDivide(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator* (float S, const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Vector operations +//------------------------------------------------------------------------------ + +inline bool Vector3::InBounds( const Vector3& Bounds ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &Bounds ); + return XMVector3InBounds( v1, v2 ); +} + +inline float Vector3::Length() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3Length( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector3::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3LengthSq( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector3::Dot( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVector3Dot( v1, v2 ); + return XMVectorGetX( X ); +} + +inline void Vector3::Cross( const Vector3& V, Vector3& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR R = XMVector3Cross( v1, v2 ); + XMStoreFloat3( &result, R ); +} + +inline Vector3 Vector3::Cross( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR R = XMVector3Cross( v1, v2 ); + + Vector3 result; + XMStoreFloat3( &result, R ); + return result; +} + +inline void Vector3::Normalize() +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3Normalize( v1 ); + XMStoreFloat3( this, X ); +} + +inline void Vector3::Normalize( Vector3& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3Normalize( v1 ); + XMStoreFloat3( &result, X ); +} + +inline void Vector3::Clamp( const Vector3& vmin, const Vector3& vmax ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &vmin ); + XMVECTOR v3 = XMLoadFloat3( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat3( this, X ); +} + +inline void Vector3::Clamp( const Vector3& vmin, const Vector3& vmax, Vector3& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &vmin ); + XMVECTOR v3 = XMLoadFloat3( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat3( &result, X ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline float Vector3::Distance( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector3Length( V ); + return XMVectorGetX( X ); +} + +inline float Vector3::DistanceSquared( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector3LengthSq( V ); + return XMVectorGetX( X ); +} + +inline void Vector3::Min( const Vector3& v1, const Vector3& v2, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Min( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Max( const Vector3& v1, const Vector3& v2, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Max( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Lerp( const Vector3& v1, const Vector3& v2, float t, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Lerp( const Vector3& v1, const Vector3& v2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::SmoothStep( const Vector3& v1, const Vector3& v2, float t, Vector3& result ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::SmoothStep( const Vector3& v1, const Vector3& v2, float t ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR x4 = XMLoadFloat3( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR x4 = XMLoadFloat3( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &t1 ); + XMVECTOR x3 = XMLoadFloat3( &v2 ); + XMVECTOR x4 = XMLoadFloat3( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &t1 ); + XMVECTOR x3 = XMLoadFloat3( &v2 ); + XMVECTOR x4 = XMLoadFloat3( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Reflect( const Vector3& ivec, const Vector3& nvec, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Reflect( i, n ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Reflect( const Vector3& ivec, const Vector3& nvec ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Reflect( i, n ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Refract( i, n, refractionIndex ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Refract( i, n, refractionIndex ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Transform( const Vector3& v, const Quaternion& quat, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Transform( const Vector3& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Transform( const Vector3& v, const Matrix& m, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformCoord( v1, M ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Transform( const Vector3& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformCoord( v1, M ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector3::Transform( const Vector3* varray, size_t count, const Matrix& m, Vector3* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector3TransformCoordStream( resultArray, sizeof(XMFLOAT3), varray, sizeof(XMFLOAT3), count, M ); +} + +inline void Vector3::Transform( const Vector3& v, const Matrix& m, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3Transform( v1, M ); + XMStoreFloat4( &result, X ); +} + +_Use_decl_annotations_ +inline void Vector3::Transform( const Vector3* varray, size_t count, const Matrix& m, Vector4* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector3TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT3), count, M ); +} + +inline void Vector3::TransformNormal( const Vector3& v, const Matrix& m, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformNormal( v1, M ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::TransformNormal( const Vector3& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformNormal( v1, M ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector3::TransformNormal( const Vector3* varray, size_t count, const Matrix& m, Vector3* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector3TransformNormalStream( resultArray, sizeof(XMFLOAT3), varray, sizeof(XMFLOAT3), count, M ); +} + + +/**************************************************************************** + * + * Vector4 + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Vector4::operator == ( const Vector4& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + return XMVector4Equal( v1, v2 ); +} + +inline bool Vector4::operator != ( const Vector4& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + return XMVector4NotEqual( v1, v2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Vector4& Vector4::operator+= (const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorAdd(v1,v2); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator-= (const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorSubtract(v1,v2); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator*= (const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorMultiply(v1,v2); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVectorScale(v1,S); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.0f ); + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVectorScale(v1, 1.f/S); + XMStoreFloat4( this, X ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Vector4 Vector4::operator- () const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVectorNegate( v1 ); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Vector4 operator+ (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorAdd(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator- (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorSubtract(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator* (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorMultiply(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator* (const Vector4& V, float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator/ (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorDivide(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator* (float S, const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Vector operations +//------------------------------------------------------------------------------ + +inline bool Vector4::InBounds( const Vector4& Bounds ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &Bounds ); + return XMVector4InBounds( v1, v2 ); +} + +inline float Vector4::Length() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4Length( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector4::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4LengthSq( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector4::Dot( const Vector4& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVector4Dot( v1, v2 ); + return XMVectorGetX( X ); +} + +inline void Vector4::Cross( const Vector4& v1, const Vector4& v2, Vector4& result ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( this ); + XMVECTOR x2 = XMLoadFloat4( &v1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR R = XMVector4Cross( x1, x2, x3 ); + XMStoreFloat4( &result, R ); +} + +inline Vector4 Vector4::Cross( const Vector4& v1, const Vector4& v2 ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( this ); + XMVECTOR x2 = XMLoadFloat4( &v1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR R = XMVector4Cross( x1, x2, x3 ); + + Vector4 result; + XMStoreFloat4( &result, R ); + return result; +} + +inline void Vector4::Normalize() +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4Normalize( v1 ); + XMStoreFloat4( this, X ); +} + +inline void Vector4::Normalize( Vector4& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4Normalize( v1 ); + XMStoreFloat4( &result, X ); +} + +inline void Vector4::Clamp( const Vector4& vmin, const Vector4& vmax ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &vmin ); + XMVECTOR v3 = XMLoadFloat4( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat4( this, X ); +} + +inline void Vector4::Clamp( const Vector4& vmin, const Vector4& vmax, Vector4& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &vmin ); + XMVECTOR v3 = XMLoadFloat4( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat4( &result, X ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline float Vector4::Distance( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector4Length( V ); + return XMVectorGetX( X ); +} + +inline float Vector4::DistanceSquared( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector4LengthSq( V ); + return XMVectorGetX( X ); +} + +inline void Vector4::Min( const Vector4& v1, const Vector4& v2, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Min( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Max( const Vector4& v1, const Vector4& v2, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Max( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Lerp( const Vector4& v1, const Vector4& v2, float t, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Lerp( const Vector4& v1, const Vector4& v2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::SmoothStep( const Vector4& v1, const Vector4& v2, float t, Vector4& result ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::SmoothStep( const Vector4& v1, const Vector4& v2, float t ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR x4 = XMLoadFloat4( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR x4 = XMLoadFloat4( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &t1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR x4 = XMLoadFloat4( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &t1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR x4 = XMLoadFloat4( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Reflect( const Vector4& ivec, const Vector4& nvec, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Reflect( i, n ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Reflect( const Vector4& ivec, const Vector4& nvec ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Reflect( i, n ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Refract( i, n, refractionIndex ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Refract( i, n, refractionIndex ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector2& v, const Quaternion& quat, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector2& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector3& v, const Quaternion& quat, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector3& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector4& v, const Quaternion& quat, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( v1, X, g_XMSelect1110 ); // result.w = v.w + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector4& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( v1, X, g_XMSelect1110 ); // result.w = v.w + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector4& v, const Matrix& m, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector4Transform( v1, M ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector4& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector4Transform( v1, M ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector4::Transform( const Vector4* varray, size_t count, const Matrix& m, Vector4* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector4TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT4), count, M ); +} + + +/**************************************************************************** + * + * Matrix + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Matrix::operator == ( const Matrix& M ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + return ( XMVector4Equal( x1, y1 ) + && XMVector4Equal( x2, y2 ) + && XMVector4Equal( x3, y3 ) + && XMVector4Equal( x4, y4 ) ) != 0; +} + +inline bool Matrix::operator != ( const Matrix& M ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + return ( XMVector4NotEqual( x1, y1 ) + || XMVector4NotEqual( x2, y2 ) + || XMVector4NotEqual( x3, y3 ) + || XMVector4NotEqual( x4, y4 ) ) != 0; +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Matrix& Matrix::operator+= (const Matrix& M) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorAdd( x1, y1 ); + x2 = XMVectorAdd( x2, y2 ); + x3 = XMVectorAdd( x3, y3 ); + x4 = XMVectorAdd( x4, y4 ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator-= (const Matrix& M) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorSubtract( x1, y1 ); + x2 = XMVectorSubtract( x2, y2 ); + x3 = XMVectorSubtract( x3, y3 ); + x4 = XMVectorSubtract( x4, y4 ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator*= (const Matrix& M) +{ + using namespace DirectX; + XMMATRIX M1 = XMLoadFloat4x4( this ); + XMMATRIX M2 = XMLoadFloat4x4( &M ); + XMMATRIX X = XMMatrixMultiply( M1, M2 ); + XMStoreFloat4x4( this, X ); + return *this; +} + +inline Matrix& Matrix::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + x1 = XMVectorScale( x1, S ); + x2 = XMVectorScale( x2, S ); + x3 = XMVectorScale( x3, S ); + x4 = XMVectorScale( x4, S ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.f ); + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + float rs = 1.f / S; + + x1 = XMVectorScale( x1, rs ); + x2 = XMVectorScale( x2, rs ); + x3 = XMVectorScale( x3, rs ); + x4 = XMVectorScale( x4, rs ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator/= (const Matrix& M) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorDivide( x1, y1 ); + x2 = XMVectorDivide( x2, y2 ); + x3 = XMVectorDivide( x3, y3 ); + x4 = XMVectorDivide( x4, y4 ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Matrix Matrix::operator- () const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR v2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR v3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR v4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + v1 = XMVectorNegate( v1 ); + v2 = XMVectorNegate( v2 ); + v3 = XMVectorNegate( v3 ); + v4 = XMVectorNegate( v4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), v1 ); + XMStoreFloat4( reinterpret_cast(&R._21), v2 ); + XMStoreFloat4( reinterpret_cast(&R._31), v3 ); + XMStoreFloat4( reinterpret_cast(&R._41), v4 ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Matrix operator+ (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorAdd( x1, y1 ); + x2 = XMVectorAdd( x2, y2 ); + x3 = XMVectorAdd( x3, y3 ); + x4 = XMVectorAdd( x4, y4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator- (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorSubtract( x1, y1 ); + x2 = XMVectorSubtract( x2, y2 ); + x3 = XMVectorSubtract( x3, y3 ); + x4 = XMVectorSubtract( x4, y4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator* (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMMATRIX m1 = XMLoadFloat4x4( &M1 ); + XMMATRIX m2 = XMLoadFloat4x4( &M2 ); + XMMATRIX X = XMMatrixMultiply( m1, m2 ); + + Matrix R; + XMStoreFloat4x4( &R, X ); + return R; +} + +inline Matrix operator* (const Matrix& M, float S) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorScale( x1, S ); + x2 = XMVectorScale( x2, S ); + x3 = XMVectorScale( x3, S ); + x4 = XMVectorScale( x4, S ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator/ (const Matrix& M, float S) +{ + using namespace DirectX; + assert( S != 0.f ); + + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + float rs = 1.f / S; + + x1 = XMVectorScale( x1, rs ); + x2 = XMVectorScale( x2, rs ); + x3 = XMVectorScale( x3, rs ); + x4 = XMVectorScale( x4, rs ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator/ (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorDivide( x1, y1 ); + x2 = XMVectorDivide( x2, y2 ); + x3 = XMVectorDivide( x3, y3 ); + x4 = XMVectorDivide( x4, y4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator* (float S, const Matrix& M) +{ + using namespace DirectX; + + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorScale( x1, S ); + x2 = XMVectorScale( x2, S ); + x3 = XMVectorScale( x3, S ); + x4 = XMVectorScale( x4, S ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +//------------------------------------------------------------------------------ +// Matrix operations +//------------------------------------------------------------------------------ + +inline bool Matrix::Decompose( Vector3& scale, Quaternion& rotation, Vector3& translation ) +{ + using namespace DirectX; + + XMVECTOR s, r, t; + + if ( !XMMatrixDecompose( &s, &r, &t, *this ) ) + return false; + + XMStoreFloat3( &scale, s ); + XMStoreFloat4( &rotation, r ); + XMStoreFloat3( &translation, t ); + + return true; +} + +inline Matrix Matrix::Transpose() const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + Matrix R; + XMStoreFloat4x4( &R, XMMatrixTranspose( M ) ); + return R; +} + +inline void Matrix::Transpose( Matrix& result ) const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + XMStoreFloat4x4( &result, XMMatrixTranspose( M ) ); +} + +inline Matrix Matrix::Invert() const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + Matrix R; + XMVECTOR det; + XMStoreFloat4x4( &R, XMMatrixInverse( &det, M ) ); + return R; +} + +inline void Matrix::Invert( Matrix& result ) const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + XMVECTOR det; + XMStoreFloat4x4( &result, XMMatrixInverse( &det, M ) ); +} + +inline float Matrix::Determinant() const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + return XMVectorGetX( XMMatrixDeterminant( M ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +_Use_decl_annotations_ +inline Matrix Matrix::CreateBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& cameraUp, const Vector3* cameraForward ) +{ + using namespace DirectX; + XMVECTOR O = XMLoadFloat3( &object ); + XMVECTOR C = XMLoadFloat3( &cameraPosition ); + XMVECTOR Z = XMVectorSubtract( O, C ); + + XMVECTOR N = XMVector3LengthSq( Z ); + if ( XMVector3Less( N, g_XMEpsilon ) ) + { + if ( cameraForward ) + { + XMVECTOR F = XMLoadFloat3( cameraForward ); + Z = XMVectorNegate( F ); + } + else + Z = g_XMNegIdentityR2; + } + else + { + Z = XMVector3Normalize( Z ); + } + + XMVECTOR up = XMLoadFloat3( &cameraUp ); + XMVECTOR X = XMVector3Cross( up, Z ); + X = XMVector3Normalize( X ); + + XMVECTOR Y = XMVector3Cross( Z, X ); + + XMMATRIX M; + M.r[0] = X; + M.r[1] = Y; + M.r[2] = Z; + M.r[3] = XMVectorSetW( O, 1.f ); + + Matrix R; + XMStoreFloat4x4( &R, M ); + return R; +} + +_Use_decl_annotations_ +inline Matrix Matrix::CreateConstrainedBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& rotateAxis, + const Vector3* cameraForward, const Vector3* objectForward ) +{ + using namespace DirectX; + + static const XMVECTORF32 s_minAngle = { 0.99825467075f, 0.99825467075f, 0.99825467075f, 0.99825467075f }; // 1.0 - XMConvertToRadians( 0.1f ); + + XMVECTOR O = XMLoadFloat3( &object ); + XMVECTOR C = XMLoadFloat3( &cameraPosition ); + XMVECTOR faceDir = XMVectorSubtract( O, C ); + + XMVECTOR N = XMVector3LengthSq( faceDir ); + if (XMVector3Less(N, g_XMEpsilon)) + { + if (cameraForward) + { + XMVECTOR F = XMLoadFloat3( cameraForward ); + faceDir = XMVectorNegate( F ); + } + else + faceDir = g_XMNegIdentityR2; + } + else + { + faceDir = XMVector3Normalize( faceDir ); + } + + XMVECTOR Y = XMLoadFloat3( &rotateAxis ); + XMVECTOR X, Z; + + XMVECTOR dot = XMVectorAbs( XMVector3Dot( Y, faceDir ) ); + if ( XMVector3Greater( dot, s_minAngle ) ) + { + if ( objectForward ) + { + Z = XMLoadFloat3( objectForward ); + dot = XMVectorAbs( XMVector3Dot( Y, Z ) ); + if ( XMVector3Greater( dot, s_minAngle ) ) + { + dot = XMVectorAbs( XMVector3Dot( Y, g_XMNegIdentityR2 ) ); + Z = ( XMVector3Greater( dot, s_minAngle ) ) ? g_XMIdentityR0 : g_XMNegIdentityR2; + } + } + else + { + dot = XMVectorAbs( XMVector3Dot( Y, g_XMNegIdentityR2 ) ); + Z = ( XMVector3Greater( dot, s_minAngle ) ) ? g_XMIdentityR0 : g_XMNegIdentityR2; + } + + X = XMVector3Cross( Y, Z ); + X = XMVector3Normalize( X ); + + Z = XMVector3Cross( X, Y ); + Z = XMVector3Normalize( Z ); + } + else + { + X = XMVector3Cross( Y, faceDir ); + X = XMVector3Normalize( X ); + + Z = XMVector3Cross( X, Y ); + Z = XMVector3Normalize( Z ); + } + + XMMATRIX M; + M.r[0] = X; + M.r[1] = Y; + M.r[2] = Z; + M.r[3] = XMVectorSetW( O, 1.f ); + + Matrix R; + XMStoreFloat4x4( &R, M ); + return R; +} + +inline Matrix Matrix::CreateTranslation( const Vector3& position ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixTranslation( position.x, position.y, position.z ) ); + return R; +} + +inline Matrix Matrix::CreateTranslation( float x, float y, float z ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixTranslation( x, y, z ) ); + return R; +} + +inline Matrix Matrix::CreateScale( const Vector3& scales ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixScaling( scales.x, scales.y, scales.z ) ); + return R; +} + +inline Matrix Matrix::CreateScale( float xs, float ys, float zs ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixScaling( xs, ys, zs ) ); + return R; +} + +inline Matrix Matrix::CreateScale( float scale ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixScaling( scale, scale, scale ) ); + return R; +} + +inline Matrix Matrix::CreateRotationX( float radians ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationX( radians ) ); + return R; +} + +inline Matrix Matrix::CreateRotationY( float radians ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationY( radians ) ); + return R; +} + +inline Matrix Matrix::CreateRotationZ( float radians ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationZ( radians ) ); + return R; +} + +inline Matrix Matrix::CreateFromAxisAngle( const Vector3& axis, float angle ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR a = XMLoadFloat3( &axis ); + XMStoreFloat4x4( &R, XMMatrixRotationAxis( a, angle ) ); + return R; +} + +inline Matrix Matrix::CreatePerspectiveFieldOfView( float fov, float aspectRatio, float nearPlane, float farPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixPerspectiveFovRH( fov, aspectRatio, nearPlane, farPlane ) ); + return R; +} + +inline Matrix Matrix::CreatePerspective( float width, float height, float nearPlane, float farPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixPerspectiveRH( width, height, nearPlane, farPlane ) ); + return R; +} + +inline Matrix Matrix::CreatePerspectiveOffCenter( float left, float right, float bottom, float top, float nearPlane, float farPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixPerspectiveOffCenterRH( left, right, bottom, top, nearPlane, farPlane ) ); + return R; +} + +inline Matrix Matrix::CreateOrthographic( float width, float height, float zNearPlane, float zFarPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixOrthographicRH( width, height, zNearPlane, zFarPlane ) ); + return R; +} + +inline Matrix Matrix::CreateOrthographicOffCenter( float left, float right, float bottom, float top, float zNearPlane, float zFarPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixOrthographicOffCenterRH( left, right, bottom, top, zNearPlane, zFarPlane ) ); + return R; +} + +inline Matrix Matrix::CreateLookAt( const Vector3& eye, const Vector3& target, const Vector3& up ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR eyev = XMLoadFloat3( &eye ); + XMVECTOR targetv = XMLoadFloat3( &target ); + XMVECTOR upv = XMLoadFloat3( &up ); + XMStoreFloat4x4( &R, XMMatrixLookAtRH( eyev, targetv, upv ) ); + return R; +} + +inline Matrix Matrix::CreateWorld( const Vector3& position, const Vector3& forward, const Vector3& up ) +{ + using namespace DirectX; + XMVECTOR zaxis = XMVector3Normalize( XMVectorNegate( XMLoadFloat3( &forward ) ) ); + XMVECTOR yaxis = XMLoadFloat3( &up ); + XMVECTOR xaxis = XMVector3Normalize( XMVector3Cross( yaxis, zaxis ) ); + yaxis = XMVector3Cross( zaxis, xaxis ); + + Matrix R; + XMStoreFloat3( reinterpret_cast( &R._11 ), xaxis ); + XMStoreFloat3( reinterpret_cast( &R._21 ), yaxis ); + XMStoreFloat3( reinterpret_cast( &R._31 ), zaxis ); + R._14 = R._24 = R._34 = 0.f; + R._41 = position.x; R._42 = position.y; R._43 = position.z; + R._44 = 1.f; + return R; +} + +inline Matrix Matrix::CreateFromQuaternion( const Quaternion& rotation ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR quatv = XMLoadFloat4( &rotation ); + XMStoreFloat4x4( &R, XMMatrixRotationQuaternion( quatv ) ); + return R; +} + +inline Matrix Matrix::CreateFromYawPitchRoll( float yaw, float pitch, float roll ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationRollPitchYaw( pitch, yaw, roll ) ); + return R; +} + +inline Matrix Matrix::CreateShadow( const Vector3& lightDir, const Plane& plane ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR light = XMLoadFloat3( &lightDir ); + XMVECTOR planev = XMLoadFloat4( &plane ); + XMStoreFloat4x4( &R, XMMatrixShadow( planev, light ) ); + return R; +} + +inline Matrix Matrix::CreateReflection( const Plane& plane ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR planev = XMLoadFloat4( &plane ); + XMStoreFloat4x4( &R, XMMatrixReflect( planev ) ); + return R; +} + +inline void Matrix::Lerp( const Matrix& M1, const Matrix& M2, float t, Matrix& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorLerp( x1, y1, t ); + x2 = XMVectorLerp( x2, y2, t ); + x3 = XMVectorLerp( x3, y3, t ); + x4 = XMVectorLerp( x4, y4, t ); + + XMStoreFloat4( reinterpret_cast(&result._11), x1 ); + XMStoreFloat4( reinterpret_cast(&result._21), x2 ); + XMStoreFloat4( reinterpret_cast(&result._31), x3 ); + XMStoreFloat4( reinterpret_cast(&result._41), x4 ); +} + +inline Matrix Matrix::Lerp( const Matrix& M1, const Matrix& M2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorLerp( x1, y1, t ); + x2 = XMVectorLerp( x2, y2, t ); + x3 = XMVectorLerp( x3, y3, t ); + x4 = XMVectorLerp( x4, y4, t ); + + Matrix result; + XMStoreFloat4( reinterpret_cast(&result._11), x1 ); + XMStoreFloat4( reinterpret_cast(&result._21), x2 ); + XMStoreFloat4( reinterpret_cast(&result._31), x3 ); + XMStoreFloat4( reinterpret_cast(&result._41), x4 ); + return result; +} + +inline void Matrix::Transform( const Matrix& M, const Quaternion& rotation, Matrix& result ) +{ + using namespace DirectX; + XMVECTOR quatv = XMLoadFloat4( &rotation ); + + XMMATRIX M0 = XMLoadFloat4x4( &M ); + XMMATRIX M1 = XMMatrixRotationQuaternion( quatv ); + + XMStoreFloat4x4( &result, XMMatrixMultiply( M0, M1 ) ); +} + +inline Matrix Matrix::Transform( const Matrix& M, const Quaternion& rotation ) +{ + using namespace DirectX; + XMVECTOR quatv = XMLoadFloat4( &rotation ); + + XMMATRIX M0 = XMLoadFloat4x4( &M ); + XMMATRIX M1 = XMMatrixRotationQuaternion( quatv ); + + Matrix result; + XMStoreFloat4x4( &result, XMMatrixMultiply( M0, M1 ) ); + return result; +} + + +/**************************************************************************** + * + * Plane + * + ****************************************************************************/ + +inline Plane::Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3 ) +{ + using namespace DirectX; + XMVECTOR P0 = XMLoadFloat3( &point1 ); + XMVECTOR P1 = XMLoadFloat3( &point2 ); + XMVECTOR P2 = XMLoadFloat3( &point3 ); + XMStoreFloat4( this, XMPlaneFromPoints( P0, P1, P2 ) ); +} + +inline Plane::Plane(const Vector3& point, const Vector3& normal) +{ + using namespace DirectX; + XMVECTOR P = XMLoadFloat3( &point ); + XMVECTOR N = XMLoadFloat3( &normal ); + XMStoreFloat4( this, XMPlaneFromPointNormal( P, N ) ); +} + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Plane::operator == ( const Plane& p ) const +{ + using namespace DirectX; + XMVECTOR p1 = XMLoadFloat4( this ); + XMVECTOR p2 = XMLoadFloat4( &p ); + return XMPlaneEqual( p1, p2 ); +} + +inline bool Plane::operator != ( const Plane& p ) const +{ + using namespace DirectX; + XMVECTOR p1 = XMLoadFloat4( this ); + XMVECTOR p2 = XMLoadFloat4( &p ); + return XMPlaneNotEqual( p1, p2 ); +} + +//------------------------------------------------------------------------------ +// Plane operations +//------------------------------------------------------------------------------ + +inline void Plane::Normalize() +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMStoreFloat4( this, XMPlaneNormalize( p ) ); +} + +inline void Plane::Normalize( Plane& result ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMPlaneNormalize( p ) ); +} + +inline float Plane::Dot( const Vector4& v ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMVECTOR v0 = XMLoadFloat4( &v ); + return XMVectorGetX( XMPlaneDot( p, v0 ) ); +} + +inline float Plane::DotCoordinate( const Vector3& position ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMVECTOR v0 = XMLoadFloat3( &position ); + return XMVectorGetX( XMPlaneDotCoord( p, v0 ) ); +} + +inline float Plane::DotNormal( const Vector3& normal ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMVECTOR n0 = XMLoadFloat3( &normal ); + return XMVectorGetX( XMPlaneDotNormal( p, n0 ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline void Plane::Transform( const Plane& plane, const Matrix& M, Plane& result ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMMATRIX m0 = XMLoadFloat4x4( &M ); + XMStoreFloat4( &result, XMPlaneTransform( p, m0 ) ); +} + +inline Plane Plane::Transform( const Plane& plane, const Matrix& M ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMMATRIX m0 = XMLoadFloat4x4( &M ); + + Plane result; + XMStoreFloat4( &result, XMPlaneTransform( p, m0 ) ); + return result; +} + +inline void Plane::Transform( const Plane& plane, const Quaternion& rotation, Plane& result ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMVECTOR q = XMLoadFloat4( &rotation ); + XMVECTOR X = XMVector3Rotate( p, q ); + X = XMVectorSelect( p, X, g_XMSelect1110 ); // result.d = plane.d + XMStoreFloat4( &result, X ); +} + +inline Plane Plane::Transform( const Plane& plane, const Quaternion& rotation ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMVECTOR q = XMLoadFloat4( &rotation ); + XMVECTOR X = XMVector3Rotate( p, q ); + X = XMVectorSelect( p, X, g_XMSelect1110 ); // result.d = plane.d + + Plane result; + XMStoreFloat4( &result, X ); + return result; +} + + +/**************************************************************************** + * + * Quaternion + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Quaternion::operator == ( const Quaternion& q ) const +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + return XMQuaternionEqual( q1, q2 ); +} + +inline bool Quaternion::operator != ( const Quaternion& q ) const +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + return XMQuaternionNotEqual( q1, q2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Quaternion& Quaternion::operator+= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + XMStoreFloat4( this, XMVectorAdd( q1, q2 ) ); + return *this; +} + +inline Quaternion& Quaternion::operator-= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + XMStoreFloat4( this, XMVectorSubtract( q1, q2 ) ); + return *this; +} + +inline Quaternion& Quaternion::operator*= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + XMStoreFloat4( this, XMQuaternionMultiply( q1, q2 ) ); + return *this; +} + +inline Quaternion& Quaternion::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( this, XMVectorScale( q, S ) ); + return *this; +} + +inline Quaternion& Quaternion::operator/= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + q2 = XMQuaternionInverse( q2 ); + XMStoreFloat4( this, XMQuaternionMultiply( q1, q2 ) ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Quaternion Quaternion::operator- () const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorNegate( q ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Quaternion operator+ (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorAdd( q1, q2 ) ); + return R; +} + +inline Quaternion operator- (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorSubtract( q1, q2 ) ); + return R; +} + +inline Quaternion operator* (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionMultiply( q1, q2 ) ); + return R; +} + +inline Quaternion operator* (const Quaternion& Q, float S) +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( &Q ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorScale( q, S ) ); + return R; +} + +inline Quaternion operator/ (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + q2 = XMQuaternionInverse( q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionMultiply( q1, q2 ) ); + return R; +} + +inline Quaternion operator* (float S, const Quaternion& Q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorScale( q1, S ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Quaternion operations +//------------------------------------------------------------------------------ + +inline float Quaternion::Length() const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + return XMVectorGetX( XMQuaternionLength( q ) ); +} + +inline float Quaternion::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + return XMVectorGetX( XMQuaternionLengthSq( q ) ); +} + +inline void Quaternion::Normalize() +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( this, XMQuaternionNormalize( q ) ); +} + +inline void Quaternion::Normalize( Quaternion& result ) const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMQuaternionNormalize( q ) ); +} + +inline void Quaternion::Conjugate() +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( this, XMQuaternionConjugate( q ) ); +} + +inline void Quaternion::Conjugate( Quaternion& result ) const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMQuaternionConjugate( q ) ); +} + +inline void Quaternion::Inverse( Quaternion& result ) const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMQuaternionInverse( q ) ); +} + +inline float Quaternion::Dot( const Quaternion& q ) const +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + return XMVectorGetX( XMQuaternionDot( q1, q2 ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline Quaternion Quaternion::CreateFromAxisAngle( const Vector3& axis, float angle ) +{ + using namespace DirectX; + XMVECTOR a = XMLoadFloat3( &axis ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionRotationAxis( a, angle ) ); + return R; +} + +inline Quaternion Quaternion::CreateFromYawPitchRoll( float yaw, float pitch, float roll ) +{ + using namespace DirectX; + Quaternion R; + XMStoreFloat4( &R, XMQuaternionRotationRollPitchYaw( pitch, yaw, roll ) ); + return R; +} + +inline Quaternion Quaternion::CreateFromRotationMatrix( const Matrix& M ) +{ + using namespace DirectX; + XMMATRIX M0 = XMLoadFloat4x4( &M ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionRotationMatrix( M0 ) ); + return R; +} + +inline void Quaternion::Lerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + XMVECTOR dot = XMVector4Dot( Q0, Q1 ); + + XMVECTOR R; + if ( XMVector4GreaterOrEqual( dot, XMVectorZero() ) ) + { + R = XMVectorLerp( Q0, Q1, t ); + } + else + { + XMVECTOR tv = XMVectorReplicate( t ); + XMVECTOR t1v = XMVectorReplicate( 1.f - t ); + XMVECTOR X0 = XMVectorMultiply( Q0, t1v ); + XMVECTOR X1 = XMVectorMultiply( Q1, tv ); + R = XMVectorSubtract( X0, X1 ); + } + + XMStoreFloat4( &result, XMQuaternionNormalize( R ) ); +} + +inline Quaternion Quaternion::Lerp( const Quaternion& q1, const Quaternion& q2, float t ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + XMVECTOR dot = XMVector4Dot( Q0, Q1 ); + + XMVECTOR R; + if ( XMVector4GreaterOrEqual( dot, XMVectorZero() ) ) + { + R = XMVectorLerp( Q0, Q1, t ); + } + else + { + XMVECTOR tv = XMVectorReplicate( t ); + XMVECTOR t1v = XMVectorReplicate( 1.f - t ); + XMVECTOR X0 = XMVectorMultiply( Q0, t1v ); + XMVECTOR X1 = XMVectorMultiply( Q1, tv ); + R = XMVectorSubtract( X0, X1 ); + } + + Quaternion result; + XMStoreFloat4( &result, XMQuaternionNormalize( R ) ); + return result; +} + +inline void Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + XMStoreFloat4( &result, XMQuaternionSlerp( Q0, Q1, t ) ); +} + +inline Quaternion Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float t ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + Quaternion result; + XMStoreFloat4( &result, XMQuaternionSlerp( Q0, Q1, t ) ); + return result; +} + +inline void Quaternion::Concatenate( const Quaternion& q1, const Quaternion& q2, Quaternion& result ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + XMStoreFloat4( &result, XMQuaternionMultiply( Q1, Q0 ) ); +} + +inline Quaternion Quaternion::Concatenate( const Quaternion& q1, const Quaternion& q2 ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + Quaternion result; + XMStoreFloat4( &result, XMQuaternionMultiply( Q1, Q0 ) ); + return result; +} + + +/**************************************************************************** + * + * Color + * + ****************************************************************************/ + +inline Color::Color( const DirectX::PackedVector::XMCOLOR& Packed ) +{ + using namespace DirectX; + XMStoreFloat4( this, PackedVector::XMLoadColor( &Packed ) ); +} + +inline Color::Color( const DirectX::PackedVector::XMUBYTEN4& Packed ) +{ + using namespace DirectX; + XMStoreFloat4( this, PackedVector::XMLoadUByteN4( &Packed ) ); +} + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ +inline bool Color::operator == ( const Color& c ) const +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + return XMColorEqual( c1, c2 ); +} + +inline bool Color::operator != ( const Color& c ) const +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + return XMColorNotEqual( c1, c2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Color& Color::operator+= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorAdd( c1, c2 ) ); + return *this; +} + +inline Color& Color::operator-= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorSubtract( c1, c2 ) ); + return *this; +} + +inline Color& Color::operator*= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorMultiply( c1, c2 ) ); + return *this; +} + +inline Color& Color::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMVectorScale( c, S ) ); + return *this; +} + +inline Color& Color::operator/= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorDivide( c1, c2 ) ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Color Color::operator- () const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + Color R; + XMStoreFloat4( &R, XMVectorNegate( c ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Color operator+ (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorAdd( c1, c2 ) ); + return R; +} + +inline Color operator- (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorSubtract( c1, c2 ) ); + return R; +} + +inline Color operator* (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorMultiply( c1, c2 ) ); + return R; +} + +inline Color operator* (const Color& C, float S) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( &C ); + Color R; + XMStoreFloat4( &R, XMVectorScale( c, S ) ); + return R; +} + +inline Color operator/ (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorDivide( c1, c2 ) ); + return R; +} + +inline Color operator* (float S, const Color& C) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C ); + Color R; + XMStoreFloat4( &R, XMVectorScale( c1, S ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Color operations +//------------------------------------------------------------------------------ + +inline DirectX::PackedVector::XMCOLOR Color::BGRA() const +{ + using namespace DirectX; + XMVECTOR clr = XMLoadFloat4( this ); + PackedVector::XMCOLOR Packed; + PackedVector::XMStoreColor( &Packed, clr ); + return Packed; +} + +inline DirectX::PackedVector::XMUBYTEN4 Color::RGBA() const +{ + using namespace DirectX; + XMVECTOR clr = XMLoadFloat4( this ); + PackedVector::XMUBYTEN4 Packed; + PackedVector::XMStoreUByteN4( &Packed, clr ); + return Packed; +} + +inline Vector3 Color::ToVector3() const +{ + return Vector3( x, y, z ); +} + +inline Vector4 Color::ToVector4() const +{ + return Vector4( x, y, z, w ); +} + +inline void Color::Negate() +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMColorNegative( c) ); +} + +inline void Color::Negate( Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMColorNegative( c ) ); +} + +inline void Color::Saturate() +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMVectorSaturate( c ) ); +} + +inline void Color::Saturate( Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMVectorSaturate( c ) ); +} + +inline void Color::Premultiply() +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMVECTOR a = XMVectorSplatW( c ); + a = XMVectorSelect( g_XMIdentityR3, a, g_XMSelect1110 ); + XMStoreFloat4( this, XMVectorMultiply( c, a ) ); +} + +inline void Color::Premultiply( Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMVECTOR a = XMVectorSplatW( c ); + a = XMVectorSelect( g_XMIdentityR3, a, g_XMSelect1110 ); + XMStoreFloat4( &result, XMVectorMultiply( c, a ) ); +} + +inline void Color::AdjustSaturation( float sat ) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMColorAdjustSaturation( c, sat ) ); +} + +inline void Color::AdjustSaturation( float sat, Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMColorAdjustSaturation( c, sat ) ); +} + +inline void Color::AdjustContrast( float contrast ) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMColorAdjustContrast( c, contrast ) ); +} + +inline void Color::AdjustContrast( float contrast, Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMColorAdjustContrast( c, contrast ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline void Color::Modulate( const Color& c1, const Color& c2, Color& result ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + XMStoreFloat4( &result, XMColorModulate( C0, C1 ) ); +} + +inline Color Color::Modulate( const Color& c1, const Color& c2 ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + + Color result; + XMStoreFloat4( &result, XMColorModulate( C0, C1 ) ); + return result; +} + +inline void Color::Lerp( const Color& c1, const Color& c2, float t, Color& result ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + XMStoreFloat4( &result, XMVectorLerp( C0, C1, t ) ); +} + +inline Color Color::Lerp( const Color& c1, const Color& c2, float t ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + + Color result; + XMStoreFloat4( &result, XMVectorLerp( C0, C1, t ) ); + return result; +} + + +/**************************************************************************** + * + * Ray + * + ****************************************************************************/ + +//----------------------------------------------------------------------------- +// Comparision operators +//------------------------------------------------------------------------------ +inline bool Ray::operator == ( const Ray& r ) const +{ + using namespace DirectX; + XMVECTOR r1p = XMLoadFloat3( &position ); + XMVECTOR r2p = XMLoadFloat3( &r.position ); + XMVECTOR r1d = XMLoadFloat3( &direction ); + XMVECTOR r2d = XMLoadFloat3( &r.direction ); + return XMVector3Equal( r1p, r2p ) && XMVector3Equal( r1d, r2d ); +} + +inline bool Ray::operator != ( const Ray& r ) const +{ + using namespace DirectX; + XMVECTOR r1p = XMLoadFloat3( &position ); + XMVECTOR r2p = XMLoadFloat3( &r.position ); + XMVECTOR r1d = XMLoadFloat3( &direction ); + XMVECTOR r2d = XMLoadFloat3( &r.direction ); + return XMVector3NotEqual( r1p, r2p ) && XMVector3NotEqual( r1d, r2d ); +} + +//----------------------------------------------------------------------------- +// Ray operators +//------------------------------------------------------------------------------ + +inline bool Ray::Intersects( const BoundingSphere& sphere, _Out_ float& Dist ) const +{ + return sphere.Intersects( position, direction, Dist ); +} + +inline bool Ray::Intersects( const BoundingBox& box, _Out_ float& Dist ) const +{ + return box.Intersects( position, direction, Dist ); +} + +inline bool Ray::Intersects( const Vector3& tri0, const Vector3& tri1, const Vector3& tri2, _Out_ float& Dist ) const +{ + return DirectX::TriangleTests::Intersects( position, direction, tri0, tri1, tri2, Dist ); +} + +inline bool Ray::Intersects( const Plane& plane, _Out_ float& Dist ) const +{ + using namespace DirectX; + + XMVECTOR p = XMLoadFloat4( &plane ); + XMVECTOR dir = XMLoadFloat3( &direction ); + + XMVECTOR nd = XMPlaneDotNormal( p, dir ); + + if ( XMVector3LessOrEqual( XMVectorAbs( nd ), g_RayEpsilon ) ) + { + Dist = 0.f; + return false; + } + else + { + // t = -(dot(n,origin) + D) / dot(n,dir) + XMVECTOR pos = XMLoadFloat3( &position ); + XMVECTOR v = XMPlaneDotNormal( p, pos ); + v = XMVectorAdd( v, XMVectorSplatW(p) ); + v = XMVectorDivide( v, nd ); + float dist = - XMVectorGetX( v ); + if (dist < 0) + { + Dist = 0.f; + return false; + } + else + { + Dist = dist; + return true; + } + } +} diff --git a/deps/include/DirectXTK/SpriteBatch.h b/deps/include/DirectXTK/SpriteBatch.h new file mode 100644 index 0000000..c21dee0 --- /dev/null +++ b/deps/include/DirectXTK/SpriteBatch.h @@ -0,0 +1,121 @@ +//-------------------------------------------------------------------------------------- +// File: SpriteBatch.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include +#include +#include +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + enum SpriteSortMode + { + SpriteSortMode_Deferred, + SpriteSortMode_Immediate, + SpriteSortMode_Texture, + SpriteSortMode_BackToFront, + SpriteSortMode_FrontToBack, + }; + + + enum SpriteEffects + { + SpriteEffects_None = 0, + SpriteEffects_FlipHorizontally = 1, + SpriteEffects_FlipVertically = 2, + SpriteEffects_FlipBoth = SpriteEffects_FlipHorizontally | SpriteEffects_FlipVertically, + }; + + + class SpriteBatch + { + public: + explicit SpriteBatch(_In_ ID3D11DeviceContext* deviceContext); + SpriteBatch(SpriteBatch&& moveFrom); + SpriteBatch& operator= (SpriteBatch&& moveFrom); + virtual ~SpriteBatch(); + + // Begin/End a batch of sprite drawing operations. + void XM_CALLCONV Begin(SpriteSortMode sortMode = SpriteSortMode_Deferred, _In_opt_ ID3D11BlendState* blendState = nullptr, _In_opt_ ID3D11SamplerState* samplerState = nullptr, _In_opt_ ID3D11DepthStencilState* depthStencilState = nullptr, _In_opt_ ID3D11RasterizerState* rasterizerState = nullptr, + _In_opt_ std::function setCustomShaders = nullptr, FXMMATRIX transformMatrix = MatrixIdentity); + void __cdecl End(); + + // Draw overloads specifying position, origin and scale as XMFLOAT2. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Draw overloads specifying position, origin and scale via the first two components of an XMVECTOR. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, FXMVECTOR origin = g_XMZero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Draw overloads specifying position as a RECT. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Rotation mode to be applied to the sprite transformation + void __cdecl SetRotation( DXGI_MODE_ROTATION mode ); + DXGI_MODE_ROTATION __cdecl GetRotation() const; + + // Set viewport for sprite transformation + void __cdecl SetViewport( const D3D11_VIEWPORT& viewPort ); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + static const XMMATRIX MatrixIdentity; + static const XMFLOAT2 Float2Zero; + + // Prevent copying. + SpriteBatch(SpriteBatch const&) DIRECTX_CTOR_DELETE + SpriteBatch& operator= (SpriteBatch const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/deps/include/DirectXTK/SpriteFont.h b/deps/include/DirectXTK/SpriteFont.h new file mode 100644 index 0000000..e1e65a8 --- /dev/null +++ b/deps/include/DirectXTK/SpriteFont.h @@ -0,0 +1,89 @@ +//-------------------------------------------------------------------------------------- +// File: SpriteFont.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "SpriteBatch.h" + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + + +namespace DirectX +{ + class SpriteFont + { + public: + struct Glyph; + + SpriteFont(_In_ ID3D11Device* device, _In_z_ wchar_t const* fileName); + SpriteFont(_In_ ID3D11Device* device, _In_reads_bytes_(dataSize) uint8_t const* dataBlob, _In_ size_t dataSize); + SpriteFont(_In_ ID3D11ShaderResourceView* texture, _In_reads_(glyphCount) Glyph const* glyphs, _In_ size_t glyphCount, _In_ float lineSpacing); + + SpriteFont(SpriteFont&& moveFrom); + SpriteFont& operator= (SpriteFont&& moveFrom); + virtual ~SpriteFont(); + + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color = Colors::White, float rotation = 0, FXMVECTOR origin = g_XMZero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + XMVECTOR XM_CALLCONV MeasureString(_In_z_ wchar_t const* text) const; + + // Spacing properties + float __cdecl GetLineSpacing() const; + void __cdecl SetLineSpacing(float spacing); + + // Font properties + wchar_t __cdecl GetDefaultCharacter() const; + void __cdecl SetDefaultCharacter(wchar_t character); + + bool __cdecl ContainsCharacter(wchar_t character) const; + + // Custom layout/rendering + Glyph const* __cdecl FindGlyph(wchar_t character) const; + void GetSpriteSheet( ID3D11ShaderResourceView** texture ) const; + + // Describes a single character glyph. + struct Glyph + { + uint32_t Character; + RECT Subrect; + float XOffset; + float YOffset; + float XAdvance; + }; + + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + static const XMFLOAT2 Float2Zero; + + // Prevent copying. + SpriteFont(SpriteFont const&) DIRECTX_CTOR_DELETE + SpriteFont& operator= (SpriteFont const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/deps/include/DirectXTK/VertexTypes.h b/deps/include/DirectXTK/VertexTypes.h new file mode 100644 index 0000000..4204d0b --- /dev/null +++ b/deps/include/DirectXTK/VertexTypes.h @@ -0,0 +1,333 @@ +//-------------------------------------------------------------------------------------- +// File: VertexTypes.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + // Vertex struct holding position and color information. + struct VertexPositionColor + { + VertexPositionColor() DIRECTX_CTOR_DEFAULT + + VertexPositionColor(XMFLOAT3 const& position, XMFLOAT4 const& color) + : position(position), + color(color) + { } + + VertexPositionColor(FXMVECTOR position, FXMVECTOR color) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat4(&this->color, color); + } + + XMFLOAT3 position; + XMFLOAT4 color; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position and texture mapping information. + struct VertexPositionTexture + { + VertexPositionTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionTexture(XMFLOAT3 const& position, XMFLOAT2 const& textureCoordinate) + : position(position), + textureCoordinate(textureCoordinate) + { } + + VertexPositionTexture(FXMVECTOR position, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position and normal vector. + struct VertexPositionNormal + { + VertexPositionNormal() DIRECTX_CTOR_DEFAULT + + VertexPositionNormal(XMFLOAT3 const& position, XMFLOAT3 const& normal) + : position(position), + normal(normal) + { } + + VertexPositionNormal(FXMVECTOR position, FXMVECTOR normal) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, color, and texture mapping information. + struct VertexPositionColorTexture + { + VertexPositionColorTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionColorTexture(XMFLOAT3 const& position, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + color(color), + textureCoordinate(textureCoordinate) + { } + + VertexPositionColorTexture(FXMVECTOR position, FXMVECTOR color, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat4(&this->color, color); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT4 color; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, and color information. + struct VertexPositionNormalColor + { + VertexPositionNormalColor() DIRECTX_CTOR_DEFAULT + + VertexPositionNormalColor(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color) + : position(position), + normal(normal), + color(color) + { } + + VertexPositionNormalColor(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR color) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->color, color); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 color; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, and texture mapping information. + struct VertexPositionNormalTexture + { + VertexPositionNormalTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionNormalTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + textureCoordinate(textureCoordinate) + { } + + VertexPositionNormalTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, color, and texture mapping information. + struct VertexPositionNormalColorTexture + { + VertexPositionNormalColorTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionNormalColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + color(color), + textureCoordinate(textureCoordinate) + { } + + VertexPositionNormalColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR color, CXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->color, color); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 color; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 4; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, + // tangent, color (RGBA), and texture mapping information + struct VertexPositionNormalTangentColorTexture + { + VertexPositionNormalTangentColorTexture() DIRECTX_CTOR_DEFAULT + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 tangent; + uint32_t color; + XMFLOAT2 textureCoordinate; + + VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, uint32_t rgba, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + tangent(tangent), + color(rgba), + textureCoordinate(textureCoordinate) + { + } + + VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, uint32_t rgba, CXMVECTOR textureCoordinate) + : color(rgba) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->tangent, tangent); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + tangent(tangent), + textureCoordinate(textureCoordinate) + { + SetColor( color ); + } + + VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, CXMVECTOR color, CXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->tangent, tangent); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + + SetColor( color ); + } + + void __cdecl SetColor( XMFLOAT4 const& icolor ) { SetColor( XMLoadFloat4( &icolor ) ); } + void XM_CALLCONV SetColor( FXMVECTOR icolor ); + + static const int InputElementCount = 5; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, + // tangent, color (RGBA), texture mapping information, and skinning weights + struct VertexPositionNormalTangentColorTextureSkinning : public VertexPositionNormalTangentColorTexture + { + VertexPositionNormalTangentColorTextureSkinning() DIRECTX_CTOR_DEFAULT + + uint32_t indices; + uint32_t weights; + + VertexPositionNormalTangentColorTextureSkinning(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, uint32_t rgba, + XMFLOAT2 const& textureCoordinate, XMUINT4 const& indices, XMFLOAT4 const& weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,rgba,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + VertexPositionNormalTangentColorTextureSkinning(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, uint32_t rgba, CXMVECTOR textureCoordinate, + XMUINT4 const& indices, CXMVECTOR weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,rgba,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + VertexPositionNormalTangentColorTextureSkinning(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, XMFLOAT4 const& color, + XMFLOAT2 const& textureCoordinate, XMUINT4 const& indices, XMFLOAT4 const& weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,color,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + VertexPositionNormalTangentColorTextureSkinning(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, CXMVECTOR color, CXMVECTOR textureCoordinate, + XMUINT4 const& indices, CXMVECTOR weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,color,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + void __cdecl SetBlendIndices( XMUINT4 const& iindices ); + + void __cdecl SetBlendWeights( XMFLOAT4 const& iweights ) { SetBlendWeights( XMLoadFloat4( &iweights ) ); } + void XM_CALLCONV SetBlendWeights( FXMVECTOR iweights ); + + static const int InputElementCount = 7; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; +} diff --git a/deps/include/DirectXTK/WICTextureLoader.h b/deps/include/DirectXTK/WICTextureLoader.h new file mode 100644 index 0000000..5e96d3c --- /dev/null +++ b/deps/include/DirectXTK/WICTextureLoader.h @@ -0,0 +1,154 @@ +//-------------------------------------------------------------------------------------- +// File: WICTextureLoader.h +// +// Function for loading a WIC image and creating a Direct3D 11 runtime texture for it +// (auto-generating mipmaps if possible) +// +// Note: Assumes application has already called CoInitializeEx +// +// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for +// auto-gen mipmap support. +// +// Note these functions are useful for images created as simple 2D textures. For +// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. +// For a full-featured DDS file reader, writer, and texture processing pipeline see +// the 'Texconv' sample and the 'DirectXTex' library. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (_WIN32_WINNT <= _WIN32_WINNT_WIN8) +#error WIC is not supported on Windows Phone 8.0 +#endif + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +namespace DirectX +{ + // Standard version + HRESULT __cdecl CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + HRESULT __cdecl CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + // Standard version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromMemory( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromFile( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + // Extended version + HRESULT __cdecl CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + HRESULT __cdecl CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + // Extended version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromMemoryEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromFileEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); +} \ No newline at end of file diff --git a/deps/include/DirectXTK/XboxDDSTextureLoader.h b/deps/include/DirectXTK/XboxDDSTextureLoader.h new file mode 100644 index 0000000..91e8728 --- /dev/null +++ b/deps/include/DirectXTK/XboxDDSTextureLoader.h @@ -0,0 +1,61 @@ +//-------------------------------------------------------------------------------------- +// File: XboxDDSTextureLoader.h +// +// Functions for loading a DDS texture using the XBOX extended header and creating a +// Direct3D11.X runtime resource for it via the CreatePlacement APIs +// +// Note these functions will not load standard DDS files. Use the DDSTextureLoader +// module in the DirectXTex package or as part of the DirectXTK library to load +// these files which use standard Direct3D 11 resource creation APIs. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if !defined(_XBOX_ONE) || !defined(_TITLE) +#error This module only supports Xbox One exclusive apps +#endif + +#include + +#include + +namespace Xbox +{ + enum DDS_ALPHA_MODE + { + DDS_ALPHA_MODE_UNKNOWN = 0, + DDS_ALPHA_MODE_STRAIGHT = 1, + DDS_ALPHA_MODE_PREMULTIPLIED = 2, + DDS_ALPHA_MODE_OPAQUE = 3, + DDS_ALPHA_MODE_CUSTOM = 4, + }; + + HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D11DeviceX* d3dDevice, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Outptr_ void** grfxMemory, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr, + _In_ bool forceSRGB = false + ); + + HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11DeviceX* d3dDevice, + _In_z_ const wchar_t* szFileName, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Outptr_ void** grfxMemory, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr, + _In_ bool forceSRGB = false + ); +} \ No newline at end of file diff --git a/deps/lib/msvc12/x64/DirectXTK.lib b/deps/lib/msvc12/x64/DirectXTK.lib new file mode 100644 index 0000000..8d4ea09 Binary files /dev/null and b/deps/lib/msvc12/x64/DirectXTK.lib differ diff --git a/deps/lib/msvc12/x64/DirectXTKd.lib b/deps/lib/msvc12/x64/DirectXTKd.lib new file mode 100644 index 0000000..c4d6738 Binary files /dev/null and b/deps/lib/msvc12/x64/DirectXTKd.lib differ diff --git a/include/Core/BGFXRenderer.h b/include/Core/BGFXRenderer.h deleted file mode 100755 index aa61bf2..0000000 --- a/include/Core/BGFXRenderer.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef BGFXRenderer_h__ -#define BGFXRenderer_h__ - -#include -#include - -#include "Util/Rectangle.h" -#include "Core/Camera.h" -#include "Core/RenderQueue.h" - -namespace dd -{ - -class BGFXRenderer -{ -public: - GLFWwindow* Window() const { return m_Window; } - Rectangle Resolution() const { return m_Resolution; } - void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; } - bool Fullscreen() { return m_Fullscreen; } - void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; } - bool VSYNC() const { return m_VSYNC; } - void SetVSYNC(bool vsync) { m_VSYNC = vsync; } - //void SetViewport(const Rectangle& viewport) { m_Viewport = viewport; } - //void SetScissor(const Rectangle& scissor) { m_Scissor = scissor; } - const dd::Camera* Camera() const { return m_Camera; } - void SetCamera(const dd::Camera* camera) - { - if (camera == nullptr) { - m_Camera = m_DefaultCamera.get(); - } else { - m_Camera = camera; - } - } - - void Initialize() - { - // Initialize GLFW - if (!glfwInit()) { - LOG_ERROR("GLFW: Initialization failed"); - exit(EXIT_FAILURE); - } - - // Create a window - GLFWmonitor* monitor = nullptr; - if (m_Fullscreen) { - monitor = glfwGetPrimaryMonitor(); - } - glfwWindowHint(GLFW_SAMPLES, 8); - m_Window = glfwCreateWindow(m_Resolution.Width, m_Resolution.Height, "daydream", monitor, nullptr); - if (!m_Window) { - LOG_ERROR("GLFW: Failed to create window"); - exit(EXIT_FAILURE); - } - //glfwMakeContextCurrent(m_Window); - - // Initialize GLEW -// if (glewInit() != GLEW_OK) { -// LOG_ERROR("GLEW: Initialization failed"); -// exit(EXIT_FAILURE); -// } - //LOG_ERROR("STUFF"); - - // Initialize bgfx - bgfx::glfwSetWindow(m_Window); - bgfx::init(bgfx::RendererType::OpenGL, BGFX_PCI_ID_NONE, 0, nullptr, nullptr); - bgfx::reset(m_Resolution.Width, m_Resolution.Height, BGFX_RESET_NONE); - bgfx::setDebug(BGFX_DEBUG_TEXT); - bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x303030ff, 1.0f, 0); - - std::stringstream ss; - ss << bgfx::getRendererName(bgfx::getRendererType()); -#ifdef DEBUG - ss << " DEBUG"; -#endif - LOG_INFO(ss.str().c_str()); - glfwSetWindowTitle(m_Window, ss.str().c_str()); - } - - void Draw(RenderQueueCollection& rq) - { - bgfx::touch(0); - - bgfx::dbgTextClear(); - bgfx::dbgTextPrintf(0, 1, 0x4f, "daydream"); - - bgfx::frame(); - } - -private: - Rectangle m_Resolution = Rectangle(1280, 720); - bool m_Fullscreen = false; - bool m_VSYNC = false; - std::unique_ptr m_DefaultCamera = nullptr; - const dd::Camera* m_Camera = nullptr; - - GLFWwindow* m_Window = nullptr; -}; - -} - -#endif diff --git a/include/Core/Engine.h b/include/Core/Engine.h index 3b78600..6c7201f 100755 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -21,12 +21,12 @@ #include #include "ResourceManager.h" -#include "OBJ.h" -#include "Model.h" -#include "Texture.h" +#include "Rendering/OBJ.h" +#include "Rendering/Model.h" +#include "Rendering/Texture.h" #include "EventBroker.h" -#include "RenderQueue.h" -#include "Renderer.h" +#include "Rendering/RenderQueue.h" +#include "Rendering/Renderer.h" #include "InputManager.h" //TODO: Remove includes that are only here for the temporary draw solution. #include "World.h" @@ -59,6 +59,7 @@ #include "Game/LifebuoySystem.h" #include "Game/ProjectileSystem.h" #include "Game/KrakenSystem.h" +#include "Game/WaterSystem.h" #include "Game/Bricks/CPowerUpBrick.h" #include "Game/BrickComponents.h" @@ -164,7 +165,7 @@ public: m_World->ComponentFactory.Register(); m_World->SystemFactory.Register( - [this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); }); + [this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); }); m_World->AddSystem(); m_World->SystemFactory.Register( [this]() { return new Systems::PadSystem(m_World.get(), m_EventBroker); }); @@ -193,6 +194,9 @@ public: m_World->SystemFactory.Register( [this]() { return new Systems::KrakenSystem(m_World.get(), m_EventBroker); }); m_World->AddSystem(); + m_World->SystemFactory.Register( + [this]() { return new Systems::WaterSystem(m_World.get(), m_EventBroker); }); + m_World->AddSystem(); m_World->ComponentFactory.Register(); m_World->ComponentFactory.Register(); @@ -351,11 +355,10 @@ public: { ModelJob job; job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0; - job.DiffuseTexture = (texGroup.Texture) ? *texGroup.Texture : 0; - job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0; - job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0; - job.VAO = model->VAO; - job.ElementBuffer = model->ElementBuffer; + job.DiffuseTexture = texGroup.Texture.get(); + job.NormalTexture = texGroup.NormalMap.get(); + job.SpecularTexture = texGroup.SpecularMap.get(); + job.Model = model; job.StartIndex = texGroup.StartIndex; job.EndIndex = texGroup.EndIndex; job.ModelMatrix = modelMatrix * model->m_Matrix; @@ -379,14 +382,13 @@ public: { SpriteJob job; job.TextureID = texture->ResourceID; - job.DiffuseTexture = *texture; - job.NormalTexture = *normalTexture; - job.SpecularTexture = *specularTexture; + job.DiffuseTexture = texture; + job.NormalTexture = normalTexture; + job.SpecularTexture = specularTexture; job.ModelMatrix = modelMatrix; job.Color = color; job.Depth = depth; - m_RendererQueue.Forward.Add(job); } diff --git a/include/Core/RenderQueue.h b/include/Core/RenderQueue.h index 3bdf0c7..b2c1df1 100755 --- a/include/Core/RenderQueue.h +++ b/include/Core/RenderQueue.h @@ -23,8 +23,8 @@ #include #include "Core/Util/Rectangle.h" -#include "Core/Texture.h" -#include "Core/Model.h" +#include "Rendering/Texture.h" +#include "Rendering/Model.h" namespace dd { @@ -78,20 +78,6 @@ struct ModelJob : RenderJob } }; -struct BlendMapModelJob : ModelJob -{ - GLuint BlendMapTextureRed; - GLuint BlendMapTextureRedNormal; - GLuint BlendMapTextureRedSpecular; - GLuint BlendMapTextureGreen; - GLuint BlendMapTextureGreenNormal; - GLuint BlendMapTextureGreenSpecular; - GLuint BlendMapTextureBlue; - GLuint BlendMapTextureBlueNormal; - GLuint BlendMapTextureBlueSpecular; - float TextureRepeat; -}; - struct SpriteJob : RenderJob { unsigned int ShaderID; diff --git a/include/Core/StaticSystem.h b/include/Core/StaticSystem.h new file mode 100644 index 0000000..a35c5a7 --- /dev/null +++ b/include/Core/StaticSystem.h @@ -0,0 +1,34 @@ +#ifndef DD_STATICSYSTEM_H__ +#define DD_STATICSYSTEM_H__ + +#include + +namespace dd +{ + +class StaticSystem +{ +private: + StaticSystem(); + +public: + template + static T* Get() + { + return static_cast(Instances.at(typeid(T).hash_code())); + } + + template + static void Set(T* ptr) + { + Instances[typeid(T).hash_code()] = static_cast(ptr); + } + + +private: + static std::unordered_map Instances; +}; + +} + +#endif \ No newline at end of file diff --git a/include/GUI/Frame.h b/include/GUI/Frame.h index 8eaedb9..28a94d7 100644 --- a/include/GUI/Frame.h +++ b/include/GUI/Frame.h @@ -9,9 +9,9 @@ #include "Core/EKeyDown.h" #include "Core/EKeyUp.h" #include "Core/ResourceManager.h" -#include "Core/Renderer.h" -#include "Core/RenderQueue.h" -#include "Core/Texture.h" +#include "Rendering/Renderer.h" +#include "Rendering/RenderQueue.h" +#include "Rendering/Texture.h" #include "Input/EInputCommand.h" namespace dd diff --git a/include/GUI/TextureFrame.h b/include/GUI/TextureFrame.h index 1bc340d..e400791 100644 --- a/include/GUI/TextureFrame.h +++ b/include/GUI/TextureFrame.h @@ -2,7 +2,7 @@ #define GUI_TextureFrame_h__ #include "GUI/Frame.h" -#include "Core/Texture.h" +#include "Rendering/Texture.h" namespace dd { @@ -29,7 +29,7 @@ public: job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle(); job.Viewport = Rectangle(Left(), Top(), Width, Height); job.TextureID = m_FadeTexture->ResourceID; - job.DiffuseTexture = *m_FadeTexture; + job.DiffuseTexture = m_FadeTexture; job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a); job.Name = Name(); rq.GUI.Add(job); @@ -41,7 +41,7 @@ public: job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle(); job.Viewport = Rectangle(Left(), Top(), Width, Height); job.TextureID = m_Texture->ResourceID; - job.DiffuseTexture = *m_Texture; + job.DiffuseTexture = m_Texture; job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade); job.Name = Name(); rq.GUI.Add(job); diff --git a/include/Game/CProjectile.h b/include/Game/CProjectile.h index 6161b6f..ea5eee1 100644 --- a/include/Game/CProjectile.h +++ b/include/Game/CProjectile.h @@ -15,7 +15,7 @@ namespace Components struct Projectile : Component { - + float Speed = 5; }; } diff --git a/include/Game/EClusterClear.h b/include/Game/EClusterClear.h index 79cd9c4..0d9379e 100644 --- a/include/Game/EClusterClear.h +++ b/include/Game/EClusterClear.h @@ -12,7 +12,7 @@ namespace Events struct ClusterClear : Event { - + int ClusterCleared; }; } diff --git a/include/Game/EInkBlaster.h b/include/Game/EInkBlaster.h index 03058ca..8ec42e3 100644 --- a/include/Game/EInkBlaster.h +++ b/include/Game/EInkBlaster.h @@ -17,6 +17,7 @@ struct InkBlaster : Event { Components::Transform* Transform; int Shots; + float Speed = 5; }; } diff --git a/include/Game/EKrakenDefeated.h b/include/Game/EKrakenDefeated.h new file mode 100644 index 0000000..30cffaf --- /dev/null +++ b/include/Game/EKrakenDefeated.h @@ -0,0 +1,26 @@ +// +// Created by Adniklastrator on 2015-10-19. +// + +#ifndef DAYDREAM_EKRAKENDEFEATED_H +#define DAYDREAM_EKRAKENDEFEATED_H + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace Events +{ + +struct KrakenDefeated : Event +{ + EntityID Kraken; + EntityID Hitter; +}; + +} + +} + +#endif //DAYDREAM_EKRAKENDEFEATED_H diff --git a/include/Game/EKrakenHit.h b/include/Game/EKrakenHit.h new file mode 100644 index 0000000..7024395 --- /dev/null +++ b/include/Game/EKrakenHit.h @@ -0,0 +1,26 @@ +// +// Created by Adniklastrator on 2015-10-19. +// + +#ifndef DAYDREAM_EKRAKENHIT_H +#define DAYDREAM_EKRAKENHIT_H + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace Events +{ + +struct KrakenHit : Event +{ + EntityID Kraken; + EntityID Hitter; +}; + +} + +} + +#endif //DAYDREAM_EKRAKENHIT_H diff --git a/include/Game/ERaiseWater.h b/include/Game/ERaiseWater.h index 2697723..3ccf199 100644 --- a/include/Game/ERaiseWater.h +++ b/include/Game/ERaiseWater.h @@ -16,6 +16,7 @@ namespace Events struct RaiseWater : Event { float Amount; + float Speed; }; } diff --git a/include/Game/ERaiseWaterWall.h b/include/Game/ERaiseWaterWall.h new file mode 100644 index 0000000..872b97d --- /dev/null +++ b/include/Game/ERaiseWaterWall.h @@ -0,0 +1,26 @@ +// +// Created by Administrator on 2015-10-20. +// + +#ifndef DAYDREAM_ERAISEWATERWALL_H +#define DAYDREAM_ERAISEWATERWALL_H + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace Events +{ + +struct RaiseWaterWall : Event +{ + float Amount; + float Speed; +}; + +} + +} + +#endif //DAYDREAM_ERAISEWATERWALL_H diff --git a/include/Game/ERelevantObjectCreated.h b/include/Game/ERelevantObjectCreated.h new file mode 100644 index 0000000..b9f392b --- /dev/null +++ b/include/Game/ERelevantObjectCreated.h @@ -0,0 +1,27 @@ +// +// Created by Administrator on 2015-10-20. +// + +#ifndef DAYDREAM_ERELEVANTOBJECTCREATED_H +#define DAYDREAM_ERELEVANTOBJECTCREATED_H + +#include "Core/EventBroker.h" +#include "Core/Entity.h" + +namespace dd +{ + +namespace Events +{ + +struct RelevantObjectCreated : Event +{ + std::string ObjectName; + EntityID ObjectID; +}; + +} + +} + +#endif //DAYDREAM_ERELEVANTOBJECTCREATED_H diff --git a/include/Game/EStageCleared.h b/include/Game/EStageCleared.h index 1de7bb5..5b01afb 100644 --- a/include/Game/EStageCleared.h +++ b/include/Game/EStageCleared.h @@ -17,6 +17,7 @@ struct StageCleared : Event { int ClearedStage = 0; int StageCluster = 0; + int StagesInCluster = 6; }; } diff --git a/include/Game/EStartedNewLevel.h b/include/Game/EStartedNewLevel.h new file mode 100644 index 0000000..58593ba --- /dev/null +++ b/include/Game/EStartedNewLevel.h @@ -0,0 +1,22 @@ +// +// Created by Administrator on 2015-10-19. +// + +#ifndef DAYDREAM_ESTARTEDNEWLEVEL_H +#define DAYDREAM_ESTARTEDNEWLEVEL_H + +#include "Core/EventBroker.h" +#include "Core/Entity.h" + +namespace dd +{ +namespace Events +{ +struct StartedNewLevel : Event +{ + +}; +} +} + +#endif //DAYDREAM_ESTARTEDNEWLEVEL_H diff --git a/include/Game/KrakenSystem.h b/include/Game/KrakenSystem.h index fb836e8..6c21d60 100644 --- a/include/Game/KrakenSystem.h +++ b/include/Game/KrakenSystem.h @@ -17,13 +17,18 @@ #include "Physics/CCircleShape.h" #include "Physics/CPhysics.h" #include "Physics/EContact.h" +#include "Physics/ESetImpulse.h" +#include "Physics/ECreateParticleSequence.h" #include "Game/EPause.h" #include "Game/EResume.h" #include "Game/EKrakenAppear.h" #include "Game/EKrakenAttack.h" +#include "Game/EKrakenHit.h" +#include "Game/EKrakenDefeated.h" #include "Game/EBrickGenerating.h" #include "Game/CTravels.h" #include "Game/CKraken.h" +#include "Game/CBall.h" #include "Sound/CCollisionSound.h" //#include "Core/Camera.h" Camera Component @@ -69,12 +74,16 @@ private: dd::EventRelay m_EContact; dd::EventRelay m_EKrakenAppear; dd::EventRelay m_EKrakenAttack; + dd::EventRelay m_EKrakenHit; + dd::EventRelay m_EKrakenDefeated; dd::EventRelay m_EBrickGenerating; bool OnPause(const dd::Events::Pause &event); bool OnResume(const dd::Events::Resume &event); bool OnContact(const dd::Events::Contact &event); bool OnKrakenAppear(const dd::Events::KrakenAppear &event); bool OnKrakenAttack(const dd::Events::KrakenAttack &event); + bool OnKrakenHit(const dd::Events::KrakenHit &event); + bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event); bool OnBrickGenerating(const dd::Events::BrickGenerating &event); void GetBrickSet(); }; diff --git a/include/Game/LevelSystem.h b/include/Game/LevelSystem.h index 83b3fd1..47c60c1 100755 --- a/include/Game/LevelSystem.h +++ b/include/Game/LevelSystem.h @@ -33,7 +33,9 @@ #include "Game/BrickComponents.h" +#include "Game/ERelevantObjectCreated.h" #include "Game/EStageCleared.h" +#include "Game/EArrivedAtNewStage.h" #include "Game/ELifeLost.h" #include "Game/EResetBall.h" #include "Game/EScoreEvent.h" @@ -52,7 +54,9 @@ #include "Game/ECreatePowerUp.h" #include "Game/EPowerUpTaken.h" +#include "Game/CKraken.h" #include "Game/EKrakenAppear.h" +#include "Game/EKrakenDefeated.h" #include "Game/EBrickGenerating.h" #include "Physics/CPhysics.h" @@ -147,6 +151,7 @@ private: int m_NumberOfBricks; int m_Rows = 6; int m_Lines = 7; + int m_StagesInCluster = 6; float m_SpaceToEdge = 0.25f; glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4); float m_NotResettingTheStage = 5.f; @@ -177,10 +182,12 @@ private: dd::EventRelay m_ECreatePowerUp; dd::EventRelay m_EPowerUpTaken; dd::EventRelay m_EStageCleared; + dd::EventRelay m_EArrivedAtNewStage; dd::EventRelay m_EPause; dd::EventRelay m_EResume; dd::EventRelay m_EHitPad; dd::EventRelay m_EBrickGenerating; + dd::EventRelay m_EKrakenDefeated; bool OnContact(const dd::Events::Contact &event); bool OnScoreEvent(const dd::Events::ScoreEvent &event); @@ -189,11 +196,13 @@ private: bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event); bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event); bool OnStageCleared(const dd::Events::StageCleared &event); + bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event); bool OnPause(const dd::Events::Pause &event); bool OnResume(const dd::Events::Resume &event); bool OnHitPad(const dd::Events::HitPad &event); bool OnBrickGenerating(const dd::Events::BrickGenerating &event); void GetBrickSet(int Set); + bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event); void GetNextLevel(); void SetBrokenModel(EntityID entity); diff --git a/include/Game/PadSystem.h b/include/Game/PadSystem.h index fadda7a..e799045 100755 --- a/include/Game/PadSystem.h +++ b/include/Game/PadSystem.h @@ -36,6 +36,7 @@ #include "Game/EResetBall.h" #include "Game/EResetAll.h" #include "Game/ERaiseWater.h" +#include "Game/ERaiseWaterWall.h" #include "Game/EMultiBall.h" #include "Game/ELifebuoy.h" #include "Game/EStickyPad.h" @@ -120,6 +121,7 @@ private: dd::EventRelay m_EResetBall; dd::EventRelay m_EResetAll; dd::EventRelay m_ERaiseWater; + dd::EventRelay m_ERaiseWaterWall; dd::EventRelay m_EPause; dd::EventRelay m_EResume; dd::EventRelay m_EKrakenAttack; @@ -135,6 +137,8 @@ private: bool OnResetBall(const dd::Events::ResetBall &event); bool OnResetAll(const dd::Events::ResetAll &event); bool OnRaiseWater(const dd::Events::RaiseWater &event); + bool OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event); + bool RaisePad(float amount, float speed); bool OnPause(const dd::Events::Pause &event); bool OnResume(const dd::Events::Resume &event); bool OnKrakenAttack(const dd::Events::KrakenAttack &event); diff --git a/include/Game/ProjectileSystem.h b/include/Game/ProjectileSystem.h index 9cf0f81..9491113 100644 --- a/include/Game/ProjectileSystem.h +++ b/include/Game/ProjectileSystem.h @@ -53,6 +53,7 @@ private: bool m_InkBlaster = false; bool m_SquidLoaded = false; int m_Shots = 0; + float m_InkBlasterSpeed = 5; EntityID m_InkBlastTemplate; EntityID m_AttachedSquid; diff --git a/include/Game/WaterSystem.h b/include/Game/WaterSystem.h new file mode 100644 index 0000000..91fe459 --- /dev/null +++ b/include/Game/WaterSystem.h @@ -0,0 +1,72 @@ +// +// Created by Adniklastrator on 2015-10-20. +// + +#ifndef DAYDREAM_WATERSYSTEM_H +#define DAYDREAM_WATERSYSTEM_H + + +#include "Core/System.h" +#include "Core/CTransform.h" +#include "Core/CTemplate.h" +#include "Core/EventBroker.h" +#include "Core/World.h" +#include "Transform/EMove.h" +#include "Physics/CWaterVolume.h" +#include "Physics/CRectangleShape.h" +#include "Game/EPause.h" +#include "Game/EResume.h" +#include "Game/ERelevantObjectCreated.h" +#include "Game/ERaiseWater.h" +#include "Game/ERaiseWaterWall.h" +#include "Game/EArrivedAtNewStage.h" +#include "Game/EStageCleared.h" + + +namespace dd +{ + +namespace Systems +{ + +class WaterSystem : public System +{ +public: + WaterSystem(World* world, std::shared_ptr eventBroker) + : System(world, eventBroker) + { } + + + void Initialize() override; + void Update(double dt) override; + void UpdateEntity(double dt, EntityID entity, EntityID parent) override; + + bool IsPaused() const { return m_Pause; } + void SetPause(const bool& pause) { m_Pause = pause; } + +private: + bool m_Pause = false; + EntityID m_BottomWall = 0; + + dd::EventRelay m_EPause; + dd::EventRelay m_EResume; + dd::EventRelay m_ERelevantObjectCreated; + dd::EventRelay m_EStageCleared; + dd::EventRelay m_EArrivedAtNewStage; + dd::EventRelay m_ERaiseWater; + dd::EventRelay m_ERaiseWaterWall; + + bool OnPause(const dd::Events::Pause &event); + bool OnResume(const dd::Events::Resume &event); + bool OnRelevantObjectCreated(const dd::Events::RelevantObjectCreated &event); + bool OnStageCleared(const dd::Events::StageCleared &event); + bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event); + bool OnRaiseWater(const dd::Events::RaiseWater &event); + bool OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event); +}; + +} + +} + +#endif //DAYDREAM_WATERSYSTEM_H diff --git a/include/PrecompiledHeader.h b/include/PrecompiledHeader.h index 2e12525..d82f1dc 100644 --- a/include/PrecompiledHeader.h +++ b/include/PrecompiledHeader.h @@ -27,7 +27,13 @@ // OpenGL #include #define GLFW_INCLUDE_GLU +#define NOMINMAX #include +#ifdef BUILD_RENDERER_DIRECTX + #define GLFW_EXPOSE_NATIVE_WIN32 + #define GLFW_EXPOSE_NATIVE_WGL + #include +#endif #include #include "Core/Util/GLError.h" diff --git a/include/Rendering/BaseRenderer.h b/include/Rendering/BaseRenderer.h new file mode 100644 index 0000000..6ec23d8 --- /dev/null +++ b/include/Rendering/BaseRenderer.h @@ -0,0 +1,64 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef DD_BASERENDERER_H__ +#define DD_BASERENDERER_H__ + +#include "Core/Util/Rectangle.h" +#include "Core/ResourceManager.h" +#include "Rendering/Camera.h" +#include "Rendering/RenderQueue.h" + +namespace dd +{ + +class BaseRenderer +{ +public: + GLFWwindow* Window() const { return m_Window; } + Rectangle Resolution() const { return m_Resolution; } + void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; } + bool Fullscreen() { return m_Fullscreen; } + void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; } + bool VSYNC() const { return m_VSYNC; } + void SetVSYNC(bool vsync) { m_VSYNC = vsync; } + const dd::Camera* Camera() const { return m_Camera; } + void SetCamera(const dd::Camera* camera) + { + if (camera == nullptr) { + m_Camera = m_DefaultCamera.get(); + } else { + m_Camera = camera; + } + } + + virtual void Initialize() = 0; + virtual void Draw(RenderQueueCollection& rq) = 0; + +protected: + Rectangle m_Resolution = Rectangle(1280, 720); + bool m_Fullscreen = false; + bool m_VSYNC = false; + std::unique_ptr m_DefaultCamera = nullptr; + const dd::Camera* m_Camera = nullptr; + GLFWwindow* m_Window = nullptr; +}; + +} + +#endif // Renderer_h__ diff --git a/include/Rendering/BaseTexture.h b/include/Rendering/BaseTexture.h new file mode 100644 index 0000000..7e9ed04 --- /dev/null +++ b/include/Rendering/BaseTexture.h @@ -0,0 +1,45 @@ + +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef BaseTexture_h__ +#define BaseTexture_h__ + +#include +#include +#include + +#include "Core/ResourceManager.h" +#include "Rendering/PNG.h" + +namespace dd +{ + +class BaseTexture : public Resource +{ + friend class ResourceManager; + +public: + unsigned int Width = 0; + unsigned int Height = 0; +}; + + +} + +#endif diff --git a/include/Rendering/CPointLight.h b/include/Rendering/CPointLight.h index a44afd7..c473f5f 100644 --- a/include/Rendering/CPointLight.h +++ b/include/Rendering/CPointLight.h @@ -20,7 +20,7 @@ #define Components_PointLight_h__ #include "Core/Component.h" -#include "Core/Color.h" +#include "Rendering/Color.h" namespace dd { diff --git a/include/Core/Camera.h b/include/Rendering/Camera.h similarity index 100% rename from include/Core/Camera.h rename to include/Rendering/Camera.h index 28fe340..e2c404a 100644 --- a/include/Core/Camera.h +++ b/include/Rendering/Camera.h @@ -65,15 +65,15 @@ public: float FarClip() const { return m_FarClip; } void SetFarClip(float val); -private: - void UpdateViewMatrix(); - void UpdateProjectionMatrix(); - float m_AspectRatio; float m_FOV; float m_NearClip; float m_FarClip; +private: + void UpdateViewMatrix(); + void UpdateProjectionMatrix(); + glm::vec3 m_Position; glm::quat m_Orientation; diff --git a/include/Core/Color.h b/include/Rendering/Color.h similarity index 100% rename from include/Core/Color.h rename to include/Rendering/Color.h diff --git a/include/Rendering/DirectX/Rendering/Model.h b/include/Rendering/DirectX/Rendering/Model.h new file mode 100644 index 0000000..d35ddf4 --- /dev/null +++ b/include/Rendering/DirectX/Rendering/Model.h @@ -0,0 +1,32 @@ +#ifndef Model_h__ +#define Model_h__ + +#include + +#include + +#include "Rendering/RawModel.h" +#include "Core/StaticSystem.h" +#include "Rendering/Renderer.h" + +namespace dd +{ + +class Model : public RawModel +{ + friend class ResourceManager; + +private: + Model(std::string fileName); + +public: + ~Model(); + + ID3D11Buffer* VertexBuffer = nullptr; + ID3D11Buffer* IndexBuffer = nullptr; + unsigned int NumVertices; +}; + +} + +#endif // Model_h__ diff --git a/include/Rendering/DirectX/Rendering/Renderer.h b/include/Rendering/DirectX/Rendering/Renderer.h new file mode 100644 index 0000000..9c7d322 --- /dev/null +++ b/include/Rendering/DirectX/Rendering/Renderer.h @@ -0,0 +1,86 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef DD_RENDERER_H__ +#define DD_RENDERER_H__ + +#include +#pragma comment (lib, "d3d11.lib") +#include +using namespace DirectX::SimpleMath; +//#pragma comment (lib, "DirectXTK.lib") + +#include "Rendering/BaseRenderer.h" + +namespace dd +{ + +class Model; +class ShaderProgram; + +class Renderer : public BaseRenderer +{ +public: + ~Renderer(); + + void Initialize() override; + void Draw(RenderQueueCollection& rq) override; + + D3D11_RASTERIZER_DESC m_RasterDesc; + + IDXGISwapChain* m_SwapChain = nullptr; + ID3D11Device* m_Device = nullptr; + ID3D11RasterizerState* m_RasterState = nullptr; + ID3D11DeviceContext* m_DeviceContext = nullptr; + ID3D11RenderTargetView* m_BackBuffer = nullptr; + ID3D11DepthStencilView* m_DepthBuffer = nullptr; + ID3D11SamplerState* m_SamplerState = nullptr; + +private: + struct ConstantBufferStruct + { + Matrix MVP; + Matrix ModelMatrix; + Matrix ViewMatrix; + Matrix ProjectionMatrix; + Matrix InverseTransposeViewModel; + Vector4 Color; + Vector4 LightPositions[10]; + Vector4 LightColors[10]; + float LightRadii[10]; + unsigned int NumLights; + float paddingBitch; + } constantBufferStruct; + + ShaderProgram* m_ForwardShaderProgram = nullptr; + ShaderProgram* m_GUIShaderProgram = nullptr; + ID3D11Buffer* constantBuffer = nullptr; + + Model* m_UnitQuad = nullptr; + Texture* m_WhiteSphereTexture = nullptr; + + static DirectX::SimpleMath::Matrix GLMtoDXModelView(glm::mat4 m); + static DirectX::SimpleMath::Matrix GLMtoDXProjection(glm::mat4 m); + void setDefaultRasterState(); + void setGUIRasterState(); + static bool DepthSort(const std::shared_ptr &i, const std::shared_ptr &j) { return (i->Depth < j->Depth); } +}; + +} + +#endif // Renderer_h__ \ No newline at end of file diff --git a/include/Rendering/DirectX/Rendering/ShaderProgram.h b/include/Rendering/DirectX/Rendering/ShaderProgram.h new file mode 100644 index 0000000..66d2168 --- /dev/null +++ b/include/Rendering/DirectX/Rendering/ShaderProgram.h @@ -0,0 +1,42 @@ +#ifndef ShaderProgram_h__ +#define ShaderProgram_h__ + +#include + +#include +#include +#pragma comment (lib, "D3DCompiler.lib") + +#include "Core/StaticSystem.h" +#include "Rendering/Renderer.h" + +namespace dd +{ + +class ShaderProgram +{ +public: + ShaderProgram(); + ~ShaderProgram(); + + void CompileVertexShader(std::wstring filename); + void CompilePixelShader(std::wstring filename); + + HRESULT CreateInputLayout(D3D11_INPUT_ELEMENT_DESC* ied, UINT numElements); + ID3D11InputLayout* GetInputLayout() const { return m_InputLayout; } + + void Bind(); + void Unbind(); + +private: + ID3D10Blob* m_VertexShaderBlob; + ID3D11VertexShader* m_VertexShader; + ID3D10Blob* m_PixelShaderBlob; + ID3D11PixelShader* m_PixelShader; + + ID3D11InputLayout* m_InputLayout; +}; + +} + +#endif // ShaderProgram_h__ diff --git a/include/Rendering/DirectX/Rendering/Texture.h b/include/Rendering/DirectX/Rendering/Texture.h new file mode 100644 index 0000000..67db0ee --- /dev/null +++ b/include/Rendering/DirectX/Rendering/Texture.h @@ -0,0 +1,50 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef Texture_h__ +#define Texture_h__ + +#include + +#include "Rendering/BaseTexture.h" +#include "Core/StaticSystem.h" +#include "Rendering/Renderer.h" + +namespace dd +{ + +class Texture : public BaseTexture +{ + friend class ResourceManager; + +private: + Texture(std::string path); + +public: + ~Texture(); + + operator ID3D11Texture2D*() { return m_Texture; } + + ID3D11Texture2D* m_Texture = nullptr; + ID3D11ShaderResourceView* m_ShaderResourceView = nullptr; +private: +}; + +} + +#endif diff --git a/include/Core/Image.h b/include/Rendering/Image.h old mode 100755 new mode 100644 similarity index 100% rename from include/Core/Image.h rename to include/Rendering/Image.h diff --git a/include/Core/OBJ.h b/include/Rendering/OBJ.h similarity index 99% rename from include/Core/OBJ.h rename to include/Rendering/OBJ.h index 955dc5d..130a2bd 100644 --- a/include/Core/OBJ.h +++ b/include/Rendering/OBJ.h @@ -30,7 +30,7 @@ #include #include -#include "ResourceManager.h" +#include "Core/ResourceManager.h" namespace dd { diff --git a/include/Rendering/OpenGL/Rendering/Model.h b/include/Rendering/OpenGL/Rendering/Model.h new file mode 100644 index 0000000..2f78a45 --- /dev/null +++ b/include/Rendering/OpenGL/Rendering/Model.h @@ -0,0 +1,52 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef Model_h__ +#define Model_h__ + +#include "Rendering/RawModel.h" + +namespace dd +{ + +class Model : public RawModel +{ + friend class ResourceManager; + +private: + Model(std::string fileName); + +public: + ~Model(); + + GLuint VAO; + GLuint ElementBuffer; + +private: + GLuint VertexBuffer; + GLuint DiffuseVertexColorBuffer; + GLuint SpecularVertexColorBuffer; + GLuint NormalBuffer; + GLuint TangentNormalsBuffer; + GLuint BiTangentNormalsBuffer; + GLuint TextureCoordBuffer; +}; + +} + +#endif // Model_h__ \ No newline at end of file diff --git a/include/Core/Renderer.h b/include/Rendering/OpenGL/Rendering/Renderer.h similarity index 76% rename from include/Core/Renderer.h rename to include/Rendering/OpenGL/Rendering/Renderer.h index 1f02cd7..c806d0e 100755 --- a/include/Core/Renderer.h +++ b/include/Rendering/OpenGL/Rendering/Renderer.h @@ -19,7 +19,11 @@ #ifndef DD_RENDERER_H__ #define DD_RENDERER_H__ -#include "Util/Rectangle.h" +#include "Rendering/BaseRenderer.h" +#include "Core/Util/Rectangle.h" +#include "Rendering/Camera.h" +#include "Rendering/RenderQueue.h" +#include "Rendering/ShaderProgram.h" #include "Core/System.h" #include "Core/CTransform.h" #include "Core/CTemplate.h" @@ -28,46 +32,22 @@ #include "Core/ResourceManager.h" #include "Core/ConfigFile.h" #include "Game/EScreenShake.h" -#include "Camera.h" -#include "RenderQueue.h" -#include "ShaderProgram.h" +#include "Rendering/Model.h" +#include "Rendering/Texture.h" namespace dd { -class Renderer +class Renderer : public BaseRenderer { public: - GLFWwindow* Window() const { return m_Window; } - Rectangle Resolution() const { return m_Resolution; } - void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; } - bool Fullscreen() { return m_Fullscreen; } - void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; } - bool VSYNC() const { return m_VSYNC; } - void SetVSYNC(bool vsync) { m_VSYNC = vsync; } - const dd::Camera* Camera() const { return m_Camera; } - void SetCamera(const dd::Camera* camera) - { - if (camera == nullptr) { - m_Camera = m_DefaultCamera.get(); - } else { - m_Camera = camera; - } - } - void Initialize(); - void Draw(RenderQueueCollection& rq); + void Initialize() override; + void Draw(RenderQueueCollection& rq) override; void PlaceCamera(glm::vec3 position); private: - Rectangle m_Resolution = Rectangle(1280, 720); - bool m_Fullscreen = false; - bool m_VSYNC = false; - std::unique_ptr m_DefaultCamera = nullptr; - const dd::Camera* m_Camera = nullptr; - int m_GLVersion[2]; std::string m_GLVendor; - GLFWwindow* m_Window = nullptr; ShaderProgram* m_SpDeferred1; ShaderProgram* m_SpDeferred2; @@ -80,6 +60,7 @@ private: GLuint m_ScreenQuad = 0; Model* m_UnitSphere = nullptr; Model* m_UnitQuad = nullptr; + Texture* m_ErrorTexture; Texture* m_StandardNormal; Texture* m_StandardSpecular; Texture* m_WhiteSphereTexture; diff --git a/include/Core/ShaderProgram.h b/include/Rendering/OpenGL/Rendering/ShaderProgram.h similarity index 98% rename from include/Core/ShaderProgram.h rename to include/Rendering/OpenGL/Rendering/ShaderProgram.h index 6eaa220..758b5d4 100644 --- a/include/Core/ShaderProgram.h +++ b/include/Rendering/OpenGL/Rendering/ShaderProgram.h @@ -27,7 +27,7 @@ #include #include -#include "ResourceManager.h" +#include "Core/ResourceManager.h" namespace dd { diff --git a/include/Core/Texture.h b/include/Rendering/OpenGL/Rendering/Texture.h similarity index 80% rename from include/Core/Texture.h rename to include/Rendering/OpenGL/Rendering/Texture.h index f7cfd69..18522cf 100644 --- a/include/Core/Texture.h +++ b/include/Rendering/OpenGL/Rendering/Texture.h @@ -19,17 +19,12 @@ #ifndef Texture_h__ #define Texture_h__ -#include -#include -#include - -#include "ResourceManager.h" -#include "PNG.h" +#include "Rendering/BaseTexture.h" namespace dd { -class Texture : public Resource +class Texture : public BaseTexture { friend class ResourceManager; @@ -41,16 +36,9 @@ public: void Bind(GLenum textureUnit = GL_TEXTURE0); - operator GLuint() const { return m_Texture; } - - unsigned int Width = 0; - unsigned int Height = 0; - -private: GLuint m_Texture = 0; }; - } #endif // Texture_h__ diff --git a/include/Core/PNG.h b/include/Rendering/PNG.h similarity index 100% rename from include/Core/PNG.h rename to include/Rendering/PNG.h diff --git a/include/Core/Model.h b/include/Rendering/RawModel.h similarity index 81% rename from include/Core/Model.h rename to include/Rendering/RawModel.h index 4de5d91..624c5a0 100644 --- a/include/Core/Model.h +++ b/include/Rendering/RawModel.h @@ -16,8 +16,8 @@ along with Daydream Engine. If not, see . */ -#ifndef Model_h__ -#define Model_h__ +#ifndef RawModel_h__ +#define RawModel_h__ #include #include @@ -34,21 +34,21 @@ #include #include "Core/ResourceManager.h" -#include "Core/Texture.h" -#include "Core/Skeleton.h" +#include "Rendering/Texture.h" +#include "Rendering/Skeleton.h" namespace dd { -class Model : public Resource +class RawModel : public Resource { friend class ResourceManager; -private: - Model(std::string fileName); +protected: + RawModel(std::string fileName); public: - ~Model(); + ~RawModel(); struct Vertex { @@ -75,17 +75,11 @@ public: unsigned int EndIndex; }; - GLuint VAO; - GLuint ElementBuffer; std::vector TextureGroups; - std::vector> texture; - glm::mat4 GetMatrix(); - std::vector Vertices; std::vector m_Vertices; std::vector m_Indices; Skeleton* m_Skeleton = nullptr; - glm::mat4 m_Matrix; private: @@ -98,17 +92,9 @@ private: std::vector BiTangentNormals; std::vector TextureCoords; - GLuint VertexBuffer; - GLuint DiffuseVertexColorBuffer; - GLuint SpecularVertexColorBuffer; - GLuint NormalBuffer; - GLuint TangentNormalsBuffer; - GLuint BiTangentNormalsBuffer; - GLuint TextureCoordBuffer; - void CreateSkeleton(std::vector> &boneInfo, std::map &boneNameMapping, aiNode* node, int parentID); }; } -#endif // Model_h__ \ No newline at end of file +#endif \ No newline at end of file diff --git a/include/Rendering/RenderQueue.h b/include/Rendering/RenderQueue.h new file mode 100644 index 0000000..5dcd030 --- /dev/null +++ b/include/Rendering/RenderQueue.h @@ -0,0 +1,198 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef RenderQueue_h__ +#define RenderQueue_h__ + +#include +#include + +#include "Core/Util/Rectangle.h" + +namespace dd +{ + +class Model; +class Skeleton; +class Texture; +class RenderQueue; + +struct RenderJob +{ + friend class RenderQueue; + + float Depth; + +protected: + uint64_t Hash; + + virtual void CalculateHash() = 0; + + bool operator<(const RenderJob& rhs) + { + return this->Hash < rhs.Hash; + } +}; + +struct ModelJob : RenderJob +{ + unsigned int ShaderID = 0; + unsigned int TextureID = 0; + + glm::mat4 ModelMatrix; + const Texture* DiffuseTexture; + const Texture* NormalTexture; + const Texture* SpecularTexture; + float Shininess = 0.f; + glm::vec4 Color; + const dd::Model* Model = nullptr; + unsigned int StartIndex = 0; + unsigned int EndIndex = 0; + + // Animation + dd::Skeleton* Skeleton = nullptr; + bool NoRootMotion = true; + std::string AnimationName; + double AnimationTime = 0; + + void CalculateHash() override + { + Hash = TextureID; + } +}; + +struct SpriteJob : RenderJob +{ + unsigned int ShaderID = 0; + unsigned int TextureID = 0; + + glm::mat4 ModelMatrix; + const Texture* DiffuseTexture = nullptr; + const Texture* NormalTexture = nullptr; + const Texture* SpecularTexture = nullptr; + glm::vec4 Color; + + void CalculateHash() override + { + Hash = TextureID; + } +}; + +struct PointLightJob : RenderJob +{ + glm::vec3 Position; + glm::vec3 SpecularColor = glm::vec3(1, 1, 1); + glm::vec3 DiffuseColor = glm::vec3(1, 1, 1); + float Radius = 1.f; + + void CalculateHash() override + { + Hash = 0; + } +}; + +struct FrameJob : SpriteJob +{ + Rectangle Scissor; + Rectangle Viewport; + std::string Name; + + void CalculateHash() override + { + Hash = 0; + } +}; + +struct WaterParticleJob : RenderJob +{ + glm::vec3 Position; + glm::vec4 Color; + glm::mat4 ModelMatrix; + + void CalculateHash() override + { + Hash = 0; + } +}; + +class RenderQueue +{ +public: + template + void Add(T &job) + { + job.CalculateHash(); + Jobs.push_back(std::shared_ptr(new T(job))); + m_Size++; + } + + void Sort() + { + Jobs.sort(); + } + + void Clear() + { + Jobs.clear(); + m_Size = 0; + } + + int Size() const { return m_Size; } + std::list>::const_iterator begin() + { + return Jobs.begin(); + } + + std::list>::const_iterator end() + { + return Jobs.end(); + } + + std::list> Jobs; + +private: + int m_Size = 0; +}; + +struct RenderQueueCollection +{ + RenderQueue Deferred; + RenderQueue Forward; + RenderQueue Lights; + RenderQueue GUI; + + void Clear() + { + Deferred.Clear(); + Forward.Clear(); + Lights.Clear(); + GUI.Clear(); + } + + void Sort() + { + Deferred.Sort(); + Forward.Sort(); + Lights.Sort(); + GUI.Sort(); + } +}; + +} + +#endif // RenderQueue_h__ \ No newline at end of file diff --git a/include/Core/Skeleton.h b/include/Rendering/Skeleton.h similarity index 100% rename from include/Core/Skeleton.h rename to include/Rendering/Skeleton.h diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index 6b87e9b..b1b3121 100755 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -53,6 +53,16 @@ file(GLOB SOURCE_FILES_Rendering "Rendering/*.cpp" ) source_group(Rendering FILES ${SOURCE_FILES_Rendering}) +file(GLOB SOURCE_FILES_Rendering_OpenGL + "${INCLUDE_PATH}/Rendering/OpenGL/Rendering/*.h" + "Rendering/OpenGL/*.cpp" +) +source_group(Rendering\\OpenGL FILES ${SOURCE_FILES_Rendering_OpenGL}) +file(GLOB SOURCE_FILES_Rendering_DirectX + "${INCLUDE_PATH}/Rendering/DirectX/Rendering/*.h" + "Rendering/DirectX/*.cpp" +) +source_group(Rendering\\DirectX FILES ${SOURCE_FILES_Rendering_DirectX}) file(GLOB SOURCE_FILES_Transform "${INCLUDE_PATH}/Transform/*.h" @@ -61,8 +71,8 @@ file(GLOB SOURCE_FILES_Transform source_group(Transform FILES ${SOURCE_FILES_Transform}) file(GLOB SOURCE_FILES_Physics - "${INCLUDE_PATH}/Physics/*.h" - "Physics/*.cpp" + "${INCLUDE_PATH}/Physics/*.h" + "Physics/*.cpp" ) source_group(Physics FILES ${SOURCE_FILES_Physics}) @@ -102,14 +112,7 @@ set(SOURCE_FILES ${SOURCE_FILES_GUI} ) -if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - set(STATIC_LIBRARY_FLAGS "${STATIC_LIBRARY_FLAGS}") -endif() - -add_library(game ${SOURCE_FILES}) -target_link_libraries(game +set(LIBRARIES ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLFW_LIBRARIES} @@ -118,7 +121,33 @@ target_link_libraries(game ${PNG_LIBRARIES} ${X11_LIBRARIES} ${OPENAL_LIBRARY} - ${liquidfun_LIBRARIES} + ${liquidfun_LIBRARIES} +) + +if(BUILD_RENDERER_OPENGL) + set(SOURCE_FILES ${SOURCE_FILES} + ${SOURCE_FILES_Rendering_OpenGL} + ) +endif() +# Compiling for DirectX target +if(BUILD_RENDERER_DIRECTX) + set(SOURCE_FILES ${SOURCE_FILES} + ${SOURCE_FILES_Rendering_DirectX} + ) + set(LIBRARIES ${LIBRARIES} + ${CMAKE_LIBRARY_PATH}/DirectXTK.lib + ) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") + set(STATIC_LIBRARY_FLAGS "${STATIC_LIBRARY_FLAGS}") +endif() + +add_library(game ${SOURCE_FILES}) +target_link_libraries(game + ${LIBRARIES} ) add_executable(breakout @@ -126,14 +155,6 @@ add_executable(breakout ) target_link_libraries(breakout game - ${OPENGL_LIBRARIES} - ${GLEW_LIBRARIES} - ${GLFW_LIBRARIES} - ${Boost_LIBRARIES} - ${assimp_LIBRARIES} - ${PNG_LIBRARIES} - ${X11_LIBRARIES} - ${OPENAL_LIBRARY} - ${liquidfun_LIBRARIES} + ${LIBRARIES} ) diff --git a/src/game/Core/BGFXRenderer.cpp b/src/game/Core/BGFXRenderer.cpp deleted file mode 100644 index 411ec42..0000000 --- a/src/game/Core/BGFXRenderer.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "PrecompiledHeader.h" -#include "Core/BGFXRenderer.h" - diff --git a/src/game/Core/StaticSystem.cpp b/src/game/Core/StaticSystem.cpp new file mode 100644 index 0000000..b8ce759 --- /dev/null +++ b/src/game/Core/StaticSystem.cpp @@ -0,0 +1,22 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#include "PrecompiledHeader.h" +#include "Core/StaticSystem.h" + +std::unordered_map dd::StaticSystem::Instances; diff --git a/src/game/Game/KrakenSystem.cpp b/src/game/Game/KrakenSystem.cpp index 61f7088..fbf6058 100644 --- a/src/game/Game/KrakenSystem.cpp +++ b/src/game/Game/KrakenSystem.cpp @@ -11,8 +11,11 @@ void dd::Systems::KrakenSystem::Initialize() m_RandomGenerator = std::mt19937(rd()); EVENT_SUBSCRIBE_MEMBER(m_EPause, &KrakenSystem::OnPause); EVENT_SUBSCRIBE_MEMBER(m_EResume, &KrakenSystem::OnResume); + EVENT_SUBSCRIBE_MEMBER(m_EContact, &KrakenSystem::OnContact); EVENT_SUBSCRIBE_MEMBER(m_EKrakenAppear, &KrakenSystem::OnKrakenAppear); EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &KrakenSystem::OnKrakenAttack); + EVENT_SUBSCRIBE_MEMBER(m_EKrakenHit, &KrakenSystem::OnKrakenHit); + EVENT_SUBSCRIBE_MEMBER(m_EKrakenDefeated, &KrakenSystem::OnKrakenDefeated); EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &KrakenSystem::OnBrickGenerating); EntityID ent = m_World->CreateEntity(); @@ -59,7 +62,7 @@ void dd::Systems::KrakenSystem::Update(double dt) void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) { - if (IsPaused()) { + if (IsPaused() || !m_KrakenBattle) { return; } @@ -68,6 +71,11 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI auto kraken = m_World->GetComponent(entity); if (kraken != nullptr) { + auto transform = m_World->GetComponent(entity); + if (transform->Position.y < -10) { + m_World->RemoveEntity(entity); + return; + } Events::KrakenAttack krakenAttack; switch (kraken->CurrentAction) { @@ -77,9 +85,9 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI m_KrakenTimer = 0; std::uniform_real_distribution dist(1, 2.999f); float random = dist(m_RandomGenerator); - std::cout << random << std::endl; + //std::cout << random << std::endl; kraken->CurrentAction = random; - std::cout << kraken->CurrentAction << std::endl; + //std::cout << kraken->CurrentAction << std::endl; } break; case 2: // Grabbing @@ -126,6 +134,42 @@ bool dd::Systems::KrakenSystem::OnResume(const dd::Events::Resume &event) return true; } +bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event) +{ + Components::Kraken* kraken1 = m_World->GetComponent(event.Entity1); + Components::Kraken* kraken2 = m_World->GetComponent(event.Entity2); + Components::Kraken* kraken; + + if (kraken1 != nullptr && kraken2 != nullptr) { + return false; + } + + EntityID krakenEntity, otherEntitiy; + + //Which is the ball? + if (kraken1 != nullptr) { + krakenEntity = event.Entity1; + otherEntitiy = event.Entity2; + kraken = kraken1; + } + else if (kraken2 != nullptr) { + krakenEntity = event.Entity2; + otherEntitiy = event.Entity1; + kraken = kraken2; + } + else { + return false; + } + + auto ball = m_World->GetComponent(otherEntitiy); + if (ball != nullptr) { + Events::KrakenHit e; + e.Kraken = krakenEntity; + e.Hitter = otherEntitiy; + EventBroker->Publish(e); + } +} + bool dd::Systems::KrakenSystem::OnKrakenAppear(const dd::Events::KrakenAppear &event) { auto ent = m_World->CloneEntity(m_KrakenTemplate); @@ -144,6 +188,103 @@ bool dd::Systems::KrakenSystem::OnKrakenAttack(const dd::Events::KrakenAttack &e return true; } +bool dd::Systems::KrakenSystem::OnKrakenHit(const dd::Events::KrakenHit &event) +{ + auto kraken = m_World->GetComponent(event.Kraken); + //kraken->Health--; + //std::cout << kraken->Health << std::endl; + kraken->Health = -1; + if (kraken->Health < 0) { + Events::KrakenDefeated e; + e.Kraken = event.Kraken; + e.Hitter = event.Hitter; + EventBroker->Publish(e); + } + return false; +} + +bool dd::Systems::KrakenSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event) +{ + m_KrakenBattle = false; + + auto kraken = m_World->GetComponent(event.Kraken); + auto physicsComponent = m_World->GetComponent(event.Kraken); + /*physicsComponent->CollisionType = CollisionType::Type::Dynamic; + physicsComponent->GravityScale = 1.f; + physicsComponent->Mask = static_cast(CollisionLayer::Water | CollisionLayer::Wall); + physicsComponent->Calculate = false;*/ + + auto transformComponentBrick = m_World->GetComponent(event.Kraken); + auto transformComponentHitter = m_World->GetComponent(event.Hitter); + + + auto brickModel = m_World->GetComponent(event.Kraken); + + auto cTransform = m_World->GetComponent(event.Kraken); + /*cTransform->Position = cTransform->Position + transformComponentBrick->Position; + glm::vec2 ballToBrick = 4.f * glm::normalize(glm::vec2(cTransform->Position.x - transformComponentHitter->Position.x, cTransform->Position.y - transformComponentHitter->Position.y)); + cTransform->Velocity = glm::vec3(ballToBrick.x, ballToBrick.y, 0.f); + + std::uniform_real_distribution dist(-1.5f, 1.5f); + int impulseStrength = dist(m_RandomGenerator); + + Events::SetImpulse i; + i.Entity = event.Kraken; + i.Impulse = glm::vec2(impulseStrength, 0.f); + i.Point = glm::vec2(cTransform->Position.x, cTransform->Position.y + 0.5f); + EventBroker->Publish(i);*/ + + auto cModel = m_World->GetComponent(event.Kraken); + cModel->Color = brickModel->Color; + cModel->Color *= 0.5f; + + /*m_World->RemoveComponent(event.Kraken); + m_World->SetEntityParent(event.Kraken, 0); + m_World->CommitEntity(event.Kraken);*/ + + //Particle trail + Events::CreateParticleSequence trail; + trail.parent = event.Kraken; + trail.AlphaValues.push_back(1.f); + trail.AlphaValues.push_back(0.f); + trail.ScaleValues.push_back(glm::vec3(0.08f)); + trail.ScaleValues.push_back(glm::vec3(0.f)); + trail.RadiusDistribution = 1; + trail.EmitterLifeTime = 2.f; + trail.ParticleLifeTime = 1.f; + trail.ParticlesPerTick = 1; + trail.SpawnRate = 0.1f; + trail.Speed = 10.f; + trail.EmittingAngle = glm::half_pi(); + trail.SpriteFile = "Textures/Particles/FadeBall.png"; + trail.Color = brickModel->Color; + //p.Spread = ... + EventBroker->Publish(trail); + + //ParticlePoof + Events::CreateParticleSequence poof; + poof.EmitterLifeTime = 4; + poof.EmittingAngle = glm::half_pi(); + poof.Spread = 0.5f; + poof.NumberOfTicks = 1; + poof.ParticleLifeTime = 1.5f; + poof.ParticlesPerTick = 1; + poof.Position = cTransform->Position; + poof.ScaleValues.clear(); + poof.ScaleValues.push_back(glm::vec3(0.5f)); + poof.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f)); + poof.SpriteFile = "Textures/Particles/Cloud_Particle.png"; + poof.Color = brickModel->Color; + poof.AlphaValues.clear(); + poof.AlphaValues.push_back(1.f); + poof.AlphaValues.push_back(0.f); + poof.Speed = 10; + EventBroker->Publish(poof); + + + return true; +} + bool dd::Systems::KrakenSystem::OnBrickGenerating(const dd::Events::BrickGenerating &event) { return true; diff --git a/src/game/Game/LevelSystem.cpp b/src/game/Game/LevelSystem.cpp index b0ea481..c0ccd72 100755 --- a/src/game/Game/LevelSystem.cpp +++ b/src/game/Game/LevelSystem.cpp @@ -18,10 +18,12 @@ void dd::Systems::LevelSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost); EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken); EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared); + EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &LevelSystem::OnArrivedAtNewStage); EVENT_SUBSCRIBE_MEMBER(m_EPause, &LevelSystem::OnPause); EVENT_SUBSCRIBE_MEMBER(m_EResume, &LevelSystem::OnResume); EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &LevelSystem::OnHitPad); EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &LevelSystem::OnBrickGenerating); + EVENT_SUBSCRIBE_MEMBER(m_EKrakenDefeated, &LevelSystem::OnKrakenDefeated); m_GodMode = ResourceManager::Load("Config.ini")->GetValue("Cheat.GodMode", false); @@ -60,7 +62,7 @@ void dd::Systems::LevelSystem::Initialize() travels->CurrentlyTraveling = false; auto model = m_World->AddComponent(t_halfPipe); model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj"; - model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f); + model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 1.f); m_World->CommitEntity(t_halfPipe); auto t_halfPipe2 = m_World->CloneEntity(t_halfPipe); @@ -84,16 +86,7 @@ void dd::Systems::LevelSystem::Initialize() }*/ // auto particleEmitter= m_World->AddComponent(Pe); - //Water test - { - auto t_waterBody = m_World->CreateEntity(); - auto transform = m_World->AddComponent(t_waterBody); - transform->Position = glm::vec3(0.f, -3.5f, -10.f); - transform->Scale = glm::vec3(7.0f, 1.5f, 1.f); - auto water = m_World->AddComponent(t_waterBody); - auto body = m_World->AddComponent(t_waterBody); - m_World->CommitEntity(t_waterBody); - } + //ParticleTest @@ -114,7 +107,7 @@ void dd::Systems::LevelSystem::Initialize() particleEmitter->Spread = glm::pi()*2; particleEmitter->EmittingAngle = glm::pi(); particleEmitter->LifeTime = 50; - + { auto Pt = m_World->CreateEntity(Pe); auto PtTransform = m_World->AddComponent(Pt); @@ -134,13 +127,13 @@ void dd::Systems::LevelSystem::Initialize() //TODO: Why does the ball not collide with these bricks? //BottomBox { - auto BottomWall = m_World->CreateEntity(); + EntityID BottomWall = m_World->CreateEntity(); auto transform = m_World->AddComponent(BottomWall); auto wall = m_World->AddComponent(BottomWall); transform->Position = glm::vec3(0.f, -6.f, -10.f); transform->Scale = glm::vec3(20.f, 0.5f, 1.f); - //std::shared_ptr sprite = m_World->AddComponent(BottomWall); - //sprite->SpriteFile = "Textures/Core/ErrorTexture.png"; + std::shared_ptr sprite = m_World->AddComponent(BottomWall); + sprite->SpriteFile = "Textures/Core/ErrorTexture.png"; std::shared_ptr rectangleShape = m_World->AddComponent(BottomWall); rectangleShape->Dimensions = glm::vec2(20.f, 0.5f); std::shared_ptr physics = m_World->AddComponent(BottomWall); @@ -152,6 +145,8 @@ void dd::Systems::LevelSystem::Initialize() physics->Mask = static_cast(CollisionLayer::LifeBuoy); } m_World->CommitEntity(BottomWall); + + m_World->SetProperty(BottomWall, "Name", "BottomWall"); } { @@ -301,6 +296,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID } else if (brick->Type == InkBlasterBrick) { Events::InkBlaster e; e.Shots = 5; + e.Speed = 7; EventBroker->Publish(e); } else if(brick->Type == KrakenAttackBrick) { Events::KrakenAttack e; @@ -321,6 +317,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID Events::StageCleared ec; ec.ClearedStage = m_CurrentLevel; ec.StageCluster = m_CurrentCluster; + ec.StagesInCluster = m_StagesInCluster; EventBroker->Publish(ec); } else { if (ball != nullptr && MultiBalls() > 0) { @@ -443,7 +440,7 @@ EntityID dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spac } else if (typeInt == KrakenAttackBrick) { cBrick->Type = KrakenAttackBrick; auto type = m_World->AddComponent(brick); - model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f); + model->Color = glm::vec4(0.f, 0.5f, 1.0f, 1.0f); } else if (typeInt == Kraken) { Events::KrakenAppear e; e.Position = transform->Position; @@ -509,14 +506,14 @@ void dd::Systems::LevelSystem::GetBrickSet(int set) // m is magenta. // d is dark. // Feel free to make your own. - glm::vec4 w = glm::vec4(1, 1, 1, 0); - glm::vec4 r = glm::vec4(1, 0, 0, 0); - glm::vec4 g = glm::vec4(0, 1, 0, 0); - glm::vec4 b = glm::vec4(0, 0, 1, 0); - glm::vec4 y = glm::vec4(1, 1, 0, 0); - glm::vec4 c = glm::vec4(0, 1, 1, 0); - glm::vec4 m = glm::vec4(1, 0, 1, 0); - glm::vec4 d = glm::vec4(0, 0, 0, 0); + glm::vec4 w = glm::vec4(1, 1, 1, 1); + glm::vec4 r = glm::vec4(1, 0, 0, 1); + glm::vec4 g = glm::vec4(0, 1, 0, 1); + glm::vec4 b = glm::vec4(0, 0, 1, 1); + glm::vec4 y = glm::vec4(1, 1, 0, 1); + glm::vec4 c = glm::vec4(0, 1, 1, 1); + glm::vec4 m = glm::vec4(1, 0, 1, 1); + glm::vec4 d = glm::vec4(0, 0, 0, 1); if (set == 1) { level = @@ -688,6 +685,7 @@ void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBr Events::InkBlaster e; e.Transform = transformComponentBrick; e.Shots = 5; + e.Speed = 7; EventBroker->Publish(e); } else { @@ -710,8 +708,6 @@ void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBr auto brickChildren = m_World->GetEntityChildren(entityBrick); for (auto b : brickChildren) { - - auto cTransform = m_World->GetComponent(b); cTransform->Position = cTransform->Position + transformComponentBrick->Position; glm::vec2 ballToBrick = 4.f * glm::normalize(glm::vec2(cTransform->Position.x - transformComponentHitter->Position.x, cTransform->Position.y - transformComponentHitter->Position.y)); @@ -837,6 +833,16 @@ bool dd::Systems::LevelSystem::OnPowerUpTaken(const dd::Events::PowerUpTaken &ev return true; } +bool dd::Systems::LevelSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event) +{ + SetNumberOfBricks(NumberOfBricks() - 1); + m_LooseBricks--; + + std::cout << m_LooseBricks << std::endl; + + return true; +} + bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &event) { if (!m_Cleared) { @@ -848,12 +854,13 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev es.Score = 500; EventBroker->Publish(es); m_CurrentLevel++; - if (m_CurrentLevel < 6) { + if (m_CurrentLevel <= event.StagesInCluster) { GetNextLevel(); CreateLevel(12); //NextLevelDistance } else { // Win Events::ClusterClear e; + e.ClusterCleared = m_CurrentCluster; EventBroker->Publish(e); Events::Pause p; @@ -864,6 +871,12 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev return true; } +bool dd::Systems::LevelSystem::OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event) +{ + m_Cleared = false; + return true; +} + void dd::Systems::LevelSystem::GetNextLevel() { std::array level; @@ -889,14 +902,14 @@ void dd::Systems::LevelSystem::GetNextLevel() // m is magenta. // d is dark. // Feel free to make your own. - glm::vec4 w = glm::vec4(1, 1, 1, 0); - glm::vec4 r = glm::vec4(1, 0, 0, 0); - glm::vec4 g = glm::vec4(0, 1, 0, 0); - glm::vec4 b = glm::vec4(0, 0, 1, 0); - glm::vec4 y = glm::vec4(1, 1, 0, 0); - glm::vec4 c = glm::vec4(0, 1, 1, 0); - glm::vec4 m = glm::vec4(1, 0, 1, 0); - glm::vec4 d = glm::vec4(0, 0, 0, 0); + glm::vec4 w = glm::vec4(1, 1, 1, 1); + glm::vec4 r = glm::vec4(1, 0, 0, 1); + glm::vec4 g = glm::vec4(0, 1, 0, 1); + glm::vec4 b = glm::vec4(0, 0, 1, 1); + glm::vec4 y = glm::vec4(1, 1, 0, 1); + glm::vec4 c = glm::vec4(0, 1, 1, 1); + glm::vec4 m = glm::vec4(1, 0, 1, 1); + glm::vec4 d = glm::vec4(0, 0, 0, 1); //glm::vec4 p4 = glm::vec4(asd.f / 255.f, asd.f / 255.f, sad.f / 255.f, 1.f); glm::vec4 br = glm::vec4(143.f / 255.f, 98.f / 255.f, 0.f / 255.f, 1.f); diff --git a/src/game/Game/LevelSystem.cpp.orig b/src/game/Game/LevelSystem.cpp.orig new file mode 100644 index 0000000..ddbc96d --- /dev/null +++ b/src/game/Game/LevelSystem.cpp.orig @@ -0,0 +1,1179 @@ +// +// Created by Adniklastrator on 2015-09-09. +// + + +#include "PrecompiledHeader.h" +#include "Game/LevelSystem.h" + + +void dd::Systems::LevelSystem::Initialize() +{ + std::random_device rd; + m_RandomGenerator = std::mt19937(rd()); + EVENT_SUBSCRIBE_MEMBER(m_EContact, &LevelSystem::OnContact); + EVENT_SUBSCRIBE_MEMBER(m_EScoreEvent, &LevelSystem::OnScoreEvent); + EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &LevelSystem::OnMultiBall); + EVENT_SUBSCRIBE_MEMBER(m_ECreatePowerUp, &LevelSystem::OnCreatePowerUp); + EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost); + EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken); + EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared); + EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &LevelSystem::OnArrivedAtNewStage); + EVENT_SUBSCRIBE_MEMBER(m_EPause, &LevelSystem::OnPause); + EVENT_SUBSCRIBE_MEMBER(m_EResume, &LevelSystem::OnResume); + EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &LevelSystem::OnHitPad); + EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &LevelSystem::OnBrickGenerating); + EVENT_SUBSCRIBE_MEMBER(m_EKrakenDefeated, &LevelSystem::OnKrakenDefeated); + + m_GodMode = ResourceManager::Load("Config.ini")->GetValue("Cheat.GodMode", false); + + //PointLightTest + { + auto t_Light = m_World->CreateEntity(); + auto transform = m_World->AddComponent(t_Light); + transform->Position = glm::vec3(-3.f, 6.f, -5.f); + auto pl = m_World->AddComponent(t_Light); + pl->Radius = 20.f; + pl->Diffuse = glm::vec3(0.8f, 0.7f, 0.05f); + auto model = m_World->AddComponent(t_Light); + model->ModelFile = "Models/Core/UnitSphere.obj"; + m_World->CommitEntity(t_Light); + } + { + auto t_Light = m_World->CreateEntity(); + auto transform = m_World->AddComponent(t_Light); + transform->Position = glm::vec3(3.f, -5.f, -5.f); + auto pl = m_World->AddComponent(t_Light); + pl->Radius = 15.f; + pl->Diffuse = glm::vec3(0.1f, 0.5f, 0.8f); + auto model = m_World->AddComponent(t_Light); + model->ModelFile = "Models/Core/UnitSphere.obj"; + m_World->CommitEntity(t_Light); + } + + //Halfpipe background test model. + { + auto t_halfPipe = m_World->CreateEntity(); + auto transform = m_World->AddComponent(t_halfPipe); + auto background = m_World->AddComponent(t_halfPipe); + transform->Position = glm::vec3(0.f, 0.f, -15.f); + transform->Scale = glm::vec3(6.f, 6.f, 10.f); + auto travels = m_World->AddComponent(t_halfPipe); + travels->CurrentlyTraveling = false; + auto model = m_World->AddComponent(t_halfPipe); + model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj"; + model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f); + m_World->CommitEntity(t_halfPipe); + + auto t_halfPipe2 = m_World->CloneEntity(t_halfPipe); + auto transform2 = m_World->GetComponent(t_halfPipe); + transform2->Position = glm::vec3(0.f, 34.6f, -15.f); //Halfpipe Value + } + + //Background + + /*{ + auto background = m_World->CreateEntity(); + auto transform = m_World->AddComponent(background); + auto travels = m_World->AddComponent(background); + travels->CurrentlyTraveling = false; + auto backgroundComponent = m_World->AddComponent(background); + transform->Position = glm::vec3(0.f, 0.f, -30.f); + transform->Scale = glm::vec3(2681.f / 50.f, 1080.f / 50.f, 1.f); + auto sprite = m_World->AddComponent(background); + sprite->SpriteFile = "Textures/Background.png"; + m_World->CommitEntity(background); + }*/ + + // auto particleEmitter= m_World->AddComponent(Pe); + + + //ParticleTest + + + /*{ + auto Pe = m_World->CreateEntity(); + auto transform = m_World->AddComponent(Pe); + auto particleEmitter= m_World->AddComponent(Pe); + auto emitteSprite = m_World->AddComponent(Pe); + + transform->Position = glm::vec3(0.f, 0.f, -10.f); + emitteSprite->SpriteFile = "Textures/Test/Brick_Normal.png"; + particleEmitter->GravityScale = 0.0f; + particleEmitter->SpawnRate = 1.f; + particleEmitter->NumberOfTicks = 2; + particleEmitter->Speed = 1.f; + particleEmitter->ParticlesPerTick = 5; + particleEmitter->Spread = glm::pi()*2; + particleEmitter->EmittingAngle = glm::pi(); + particleEmitter->LifeTime = 50; + + { + auto Pt = m_World->CreateEntity(Pe); + auto PtTransform = m_World->AddComponent(Pt); + auto PtSprite = m_World->AddComponent(Pt); + auto PtParticle = m_World->AddComponent(Pt); + auto PtTemplate = m_World->AddComponent(Pt); + + //PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f); + PtTransform->Position = transform->Position; + PtSprite->SpriteFile = "Textures/Background.png"; + PtParticle->LifeTime = 3.f; + PtParticle->Flags = static_cast(ParticleFlags::Type::Powder | ParticleFlags::Type::ParticleContactFilter | ParticleFlags::Type::FixtureContactFilter); + } + m_World->CommitEntity(Pe); + }*/ + + //TODO: Why does the ball not collide with these bricks? + //BottomBox + { + EntityID BottomWall = m_World->CreateEntity(); + auto transform = m_World->AddComponent(BottomWall); + auto wall = m_World->AddComponent(BottomWall); + transform->Position = glm::vec3(0.f, -6.f, -10.f); + transform->Scale = glm::vec3(20.f, 0.5f, 1.f); + std::shared_ptr sprite = m_World->AddComponent(BottomWall); + sprite->SpriteFile = "Textures/Core/ErrorTexture.png"; + std::shared_ptr rectangleShape = m_World->AddComponent(BottomWall); + rectangleShape->Dimensions = glm::vec2(20.f, 0.5f); + std::shared_ptr physics = m_World->AddComponent(BottomWall); + physics->CollisionType = CollisionType::Type::Static; + physics->Category = CollisionLayer::Wall; + if (m_GodMode) { + physics->Mask = static_cast(CollisionLayer::LifeBuoy | CollisionLayer::Ball); + } else { + physics->Mask = static_cast(CollisionLayer::LifeBuoy); + } + m_World->CommitEntity(BottomWall); + + m_World->SetProperty(BottomWall, "Name", "BottomWall"); + } + + { + auto topWall = m_World->CreateEntity(); + std::shared_ptr transform = m_World->AddComponent(topWall); + transform->Position = glm::vec3(0.f, 6.f, -10.f); + transform->Scale = glm::vec3(20.f, 0.5f, 1.f); + + auto wall = m_World->AddComponent(topWall); + + //std::shared_ptr sprite = m_World->AddComponent(topWall); + //sprite->SpriteFile = "Textures/Core/ErrorTexture.png"; + + std::shared_ptr rectangleShape = m_World->AddComponent(topWall); + rectangleShape->Dimensions = glm::vec2(20.f, 0.5f); + + std::shared_ptr physics = m_World->AddComponent(topWall); + physics->CollisionType = CollisionType::Type::Static; + physics->Category = CollisionLayer::Wall; + physics->Mask = static_cast(CollisionLayer::Ball | CollisionLayer::Brick); + + m_World->CommitEntity(topWall); + } + + { + auto leftWall = m_World->CreateEntity(); + std::shared_ptr transform = m_World->AddComponent( + leftWall); + transform->Position = glm::vec3(-4.f, 1.f, -10.f); + transform->Scale = glm::vec3(0.5f, 20.f, 1.f); + + auto wall = m_World->AddComponent(leftWall); + + //std::shared_ptr sprite = m_World->AddComponent(leftWall); + //sprite->SpriteFile = "Textures/Core/ErrorTexture.png"; + + std::shared_ptr rectangleShape = m_World->AddComponent(leftWall); + rectangleShape->Dimensions = glm::vec2(0.5f, 20.f); + + std::shared_ptr physics = m_World->AddComponent(leftWall); + physics->CollisionType = CollisionType::Type::Static; + physics->Category = CollisionLayer::Wall; + physics->Mask = static_cast(CollisionLayer::Ball | CollisionLayer::Brick); + + m_World->CommitEntity(leftWall); + } + + { + auto rightWall = m_World->CreateEntity(); + std::shared_ptr transform = m_World->AddComponent( + rightWall); + transform->Position = glm::vec3(4.f, 1.f, -10.f); + transform->Scale = glm::vec3(0.5f, 20.f, 1.f); + + auto wall = m_World->AddComponent(rightWall); + + //std::shared_ptr sprite = m_World->AddComponent(rightWall); + //sprite->SpriteFile = "Textures/Core/ErrorTexture.png"; + + std::shared_ptr rectangleShape = m_World->AddComponent(rightWall); + rectangleShape->Dimensions = glm::vec2(0.5f, 20.f); + + std::shared_ptr physics = m_World->AddComponent(rightWall); + physics->CollisionType = CollisionType::Type::Static; + physics->Category = CollisionLayer::Wall; + physics->Mask = static_cast(CollisionLayer::Ball | CollisionLayer::Brick); + + m_World->CommitEntity(rightWall); + } + + m_BrickTemplate = m_World->CreateEntity(); + std::shared_ptr transform = m_World->AddComponent(m_BrickTemplate); + auto model = m_World->AddComponent(m_BrickTemplate); + std::shared_ptr cBrick = m_World->AddComponent(m_BrickTemplate); + std::shared_ptr cRec = m_World->AddComponent(m_BrickTemplate); + cRec->Dimensions = glm::vec2(0.9f, 0.35f); + std::shared_ptr cPhys = m_World->AddComponent(m_BrickTemplate); + std::shared_ptr cTemplate = m_World->AddComponent(m_BrickTemplate); + + auto travels = m_World->AddComponent(m_BrickTemplate); + travels->CurrentlyTraveling = false; + + cPhys->CollisionType = CollisionType::Type::Static; + cPhys->GravityScale = 0.f; + cPhys->Category = CollisionLayer::Type::Brick; + cPhys->Mask = static_cast(CollisionLayer::Type::Ball | CollisionLayer::Type::Projectile | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy); + + model->ModelFile = "Models/Brick/WhiteBrick.obj"; + transform->Position = glm::vec3(50, 50, -10); + //sound + auto collisionSound = m_World->AddComponent(m_BrickTemplate); + collisionSound->FilePath = "Sounds/Brick/shortbrickbreak.wav"; + m_World->CommitEntity(m_BrickTemplate); + return; +} + +void dd::Systems::LevelSystem::Update(double dt) +{ + if (!m_Initialized) { + GetNextLevel(); + CreateLevel(0); + m_Initialized = true; + } +} + +void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) +{ + if (IsPaused()) { + return; + } + auto templateCheck = m_World->GetComponent(entity); + if (templateCheck != nullptr){ return; } + + // Check the background. + auto background = m_World->GetComponent(entity); + if (background != nullptr) { + auto transform = m_World->GetComponent(entity); + if (transform->Position.y <= -34.6) { //Halfpipe Value. + transform->Position.y = 34.6; + Events::Move e; + e.Entity = entity; + e.GoalPosition = glm::vec3(transform->Position.x, 34.6 + background->distanceLeftToCorrectTravelPosition, transform->Position.z); + e.Speed = 6.0f; + e.Queue = false; + EventBroker->Publish(e); + } + } + + auto brick = m_World->GetComponent(entity); + if (brick != nullptr) { + auto transform = m_World->GetComponent(entity); + //Removes bricks that falls out of the stage. + if (transform->Position.y < -10) { + if (brick->Type == StandardBrick) { + } else if (brick->Type == MultiBallBrick) { + Events::MultiBall e; + e.padTransform = transform; + EventBroker->Publish(e); + } else if (brick->Type == LifebuoyBrick) { + Events::Lifebuoy e; + e.Transform = transform; + EventBroker->Publish(e); + } else if (brick->Type == StickyBrick) { + Events::StickyPad e; + e.Times = 3; + EventBroker->Publish(e); + } else if (brick->Type == InkBlasterBrick) { + Events::InkBlaster e; + e.Shots = 5; + e.Speed = 5; + EventBroker->Publish(e); + } else if(brick->Type == KrakenAttackBrick) { + Events::KrakenAttack e; + e.ChargeUpdate = 0; + e.KrakenStrength = 0.1; + e.PlayerStrength = 0.05; + EventBroker->Publish(e); + } + m_LooseBricks--; + m_World->RemoveEntity(entity); + } + } + + auto ball = m_World->GetComponent(entity); + + if (NumberOfBricks() <= 0 && m_LooseBricks <= 0 && !Restarting()) { + if (MultiBalls() <= 0 && PowerUps() <= 0) { + Events::StageCleared ec; + ec.ClearedStage = m_CurrentLevel; + ec.StageCluster = m_CurrentCluster; + ec.StagesInCluster = m_StagesInCluster; + EventBroker->Publish(ec); + } else { + if (ball != nullptr && MultiBalls() > 0) { + Events::MultiBallLost e; + EventBroker->Publish(e); + m_World->RemoveEntity(entity); + } else { + auto powerUp = m_World->GetComponent(entity); + if (powerUp != nullptr) { + SetPowerUps(PowerUps() - 1); + m_World->RemoveEntity(entity); + } else { + if (brick != nullptr) { + m_LooseBricks--; + m_World->RemoveEntity(entity); + } + } + } + } + } +} + +bool dd::Systems::LevelSystem::OnPause(const dd::Events::Pause &event) +{ + /*if (event.Type != "LevelSystem" && event.Type != "All") { + return false; + }*/ + + m_Pause = true; + + return true; +} + +bool dd::Systems::LevelSystem::OnResume(const dd::Events::Resume &event) +{ + /*if (event.Type != "LevelSystem" && event.Type != "All") { + return false; + }*/ + m_Pause = false; + return true; +} + +void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 spacesBetweenBricks, float spaceToEdge) +{ + SetNumberOfBricks(rows * lines); + //std::cout << "You're only doing this once, right?" << std::endl; + int num = Lines(); + for (int i = 0; i < rows; i++) { + num--; + for (int j = 0; j < Lines(); j++) { + CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, 0, num, 1, glm::vec4(0, 0, 0, 0)); + } + if (num == 1) + num = Lines(); + } + + SetNumberOfBricks(rows * lines); + SetRestarting(false); + return; +} + +void dd::Systems::LevelSystem::CreateLevel(int aboveBasicLevel) +{ + std::cout << "Loading level: " << m_CurrentLevel << std::endl; + SetNumberOfBricks(Rows() * Lines()); + int num = Lines(); + int getter = 0; + + for (int i = 0; i < Rows(); i++) { + num--; + for (int j = 0; j < Lines(); j++) { + CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), aboveBasicLevel, num, m_Bricks[getter], m_Colors[getter]); + getter++; + } + if (num == 1) { + num = Lines(); + } + } + m_LooseBricks = NumberOfBricks(); + SetRestarting(false); +} + +EntityID dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int aboveLevel, int num, int typeInt, glm::vec4 colorVec) +{ + if (typeInt == EmptyBrickSpace) { + SetNumberOfBricks(NumberOfBricks() - 1); + return NULL; + } + auto brick = m_World->CloneEntity(m_BrickTemplate); + m_World->RemoveComponent(brick); + auto transform = m_World->GetComponent(brick); + auto cBrick = m_World->GetComponent(brick); + auto model = m_World->GetComponent(brick); + + float x = line * spacesBetweenBricks.x; + float y = row * spacesBetweenBricks.y; + transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y + aboveLevel, -10.f); + + if (typeInt == StandardBrick) { + cBrick->Type = StandardBrick; + auto type = m_World->AddComponent(brick); + model->Color = colorVec; + SetBrokenModel(brick); + } else if (typeInt == MultiBallBrick) { + cBrick->Type = MultiBallBrick; + auto type = m_World->AddComponent(brick); + model->ModelFile = "Models/Brick/IceBrick.obj"; + } else if (typeInt == LifebuoyBrick) { + cBrick->Type = LifebuoyBrick; + auto type = m_World->AddComponent(brick); + model->ModelFile = "Models/Brick/LifeBuoyBrick.obj"; + } else if (typeInt == StickyBrick) { + cBrick->Type = StickyBrick; + auto type = m_World->AddComponent(brick); + model->ModelFile = "Models/Brick/StickyBrick.obj"; + } else if (typeInt == InkBlasterBrick) { + cBrick->Type = InkBlasterBrick; + auto type = m_World->AddComponent(brick); + model->Color = glm::vec4(0.1f, 0.1f, 0.1f, 1.0f); + } else if (typeInt == KrakenAttackBrick) { + cBrick->Type = KrakenAttackBrick; + auto type = m_World->AddComponent(brick); + model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f); + } else if (typeInt == Kraken) { + Events::KrakenAppear e; + e.Position = transform->Position; + e.Health = 10; + EventBroker->Publish(e); + m_World->RemoveEntity(brick); + return brick; + } + + cBrick->Score = 10 * num; + return brick; +} + +bool dd::Systems::LevelSystem::OnBrickGenerating(const dd::Events::BrickGenerating &event) +{ + GetBrickSet(event.Set); + LOG_DEBUG("This is happening."); + + int rows = 2; + int lines = 7; + int getter = 0; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < lines; j++) { + auto ent = CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), -4, 1, m_BrickSet[getter], m_ColorSet[getter]); + if (ent != NULL) { + auto transform = m_World->GetComponent(ent); + Events::Move e; + e.GoalPosition = transform->Position; + transform->Position = event.Origin; + e.Entity = ent; + e.Speed = 6; + e.Queue = false; + EventBroker->Publish(e); + m_LooseBricks++; + SetNumberOfBricks(NumberOfBricks() + 1); + } + getter++; + } + } + return true; +} + +void dd::Systems::LevelSystem::GetBrickSet(int set) +{ + std::array level; + std::array color; + // Level array indicates type of brick. + // 0 is empty space. + // 1 is standard brick. + // 2 is multiball brick. + // 3 is lifebuoy brick. + // 4 is sticky brick. + // 5 is ink blaster brick. + // 6 is kraken attack brick. + + // color array determines the color of standard bricks. + // w is white. + // r is red. + // g is green. + // b is blue. + // y is yellow. + // c is cyan. + // m is magenta. + // d is dark. + // Feel free to make your own. + glm::vec4 w = glm::vec4(1, 1, 1, 0); + glm::vec4 r = glm::vec4(1, 0, 0, 0); + glm::vec4 g = glm::vec4(0, 1, 0, 0); + glm::vec4 b = glm::vec4(0, 0, 1, 0); + glm::vec4 y = glm::vec4(1, 1, 0, 0); + glm::vec4 c = glm::vec4(0, 1, 1, 0); + glm::vec4 m = glm::vec4(1, 0, 1, 0); + glm::vec4 d = glm::vec4(0, 0, 0, 0); + + if (set == 1) { + level = + {1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1 }; + color = + {r, r, r, r, r, r, r, + r, r, r, r, r, r, r }; + } + else if (set == 2) { + level = + {2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2 }; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w }; + } + else if (set == 3) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 }; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w }; + } + else if (set == 4) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 }; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w }; + } + else if (set == 5) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 }; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w }; + } + else if (set == 6) { + level = + {0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 }; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w }; + } + + std::copy(std::begin(level), std::end(level), std::begin(m_BrickSet)); + std::copy(std::begin(color), std::end(color), std::begin(m_ColorSet)); +} + + +void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity) +{ + +} + +bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event) +{ + EntityID entityBrick; + EntityID entityBall; + EntityID entityShot = 0; + auto ball = m_World->GetComponent(event.Entity2); + auto brick = m_World->GetComponent(event.Entity1); + if (brick != nullptr) { + entityBrick = event.Entity1; + } else { + brick = m_World->GetComponent(event.Entity2); + if (brick != nullptr) { + entityBrick = event.Entity2; + } else { + return false; + } + } + if (ball != nullptr) { + entityBall = event.Entity2; + } else { + ball = m_World->GetComponent(event.Entity1); + if (ball != nullptr) { + entityBall = event.Entity1; + } else { + auto shot = m_World->GetComponent(event.Entity1); + if (shot != nullptr) { + entityShot = event.Entity1; + } else { + shot = m_World->GetComponent(event.Entity2); + if (shot != nullptr) { + entityShot = event.Entity2; + } else { + return false; + } + } + } + } + + brick = m_World->GetComponent(entityBrick); + if (brick == nullptr) { + return false; + } + + if (entityShot != 0) { + // For when a brick gets shot. + brick->Removed = true; + m_World->RemoveEntity(entityShot); + BrickHit(entityShot, entityBrick, 1); + //ep.Radius = 0.05; + + return true; + } + + if (!Restarting() && !brick->Removed) { + brick->Removed = true; + + // Hit brick with ball code. + ball->Combo += 1; + Events::ComboEvent ec; + ec.Combo = ball->Combo; + ec.Ball = entityBall; + EventBroker->Publish(ec); + + BrickHit(entityBall, entityBrick, ball->Combo); + } + + return true; +} + +void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBrick, int combo) +{ + auto brick = m_World->GetComponent(entityBrick); + auto physicsComponent = m_World->GetComponent(entityBrick); + //physicsComponent->CollisionType = CollisionType::Type::Dynamic; + //physicsComponent->GravityScale = 1.f; + //physicsComponent->Mask = static_cast(CollisionLayer::Water | CollisionLayer::Wall); + + auto transformComponentBrick = m_World->GetComponent(entityBrick); + auto transformComponentHitter = m_World->GetComponent(entityHitter); + + + auto brickModel = m_World->GetComponent(entityBrick); + + // Check if the brick is any kind of special. + auto multi = m_World->GetComponent(entityBrick); + if (multi != nullptr) { + Events::MultiBall e; + e.padTransform = transformComponentBrick; + EventBroker->Publish(e); + } + else { + auto buoy = m_World->GetComponent(entityBrick); + if (buoy != nullptr) { + Events::Lifebuoy e; + e.Transform = transformComponentBrick; + EventBroker->Publish(e); + } + else { + auto sticky = m_World->GetComponent(entityBrick); + if (sticky != nullptr) { + Events::StickyPad e; + e.Transform = transformComponentBrick; + e.Times = 3; + EventBroker->Publish(e); + } + else { + auto ink = m_World->GetComponent(entityBrick); + if (ink != nullptr) { + Events::InkBlaster e; + e.Transform = transformComponentBrick; + e.Shots = 5; + e.Speed = 5; + EventBroker->Publish(e); + } + else { + auto kraken = m_World->GetComponent(entityBrick); + if (kraken != nullptr) { + Events::KrakenAttack e; + e.ChargeUpdate = 0; + e.KrakenStrength = 0.1; + e.PlayerStrength = 0.05; + EventBroker->Publish(e); + } + else { + + } + } + } + } + } + + auto brickChildren = m_World->GetEntityChildren(entityBrick); + for (auto b : brickChildren) + { + auto cTransform = m_World->GetComponent(b); + cTransform->Position = cTransform->Position + transformComponentBrick->Position; + glm::vec2 ballToBrick = 4.f * glm::normalize(glm::vec2(cTransform->Position.x - transformComponentHitter->Position.x, cTransform->Position.y - transformComponentHitter->Position.y)); + cTransform->Velocity = glm::vec3(ballToBrick.x, ballToBrick.y, 0.f); + + std::uniform_real_distribution dist(-1.5f, 1.5f); + int impulseStrength = dist(m_RandomGenerator); + + Events::SetImpulse i; + i.Entity = b; + i.Impulse = glm::vec2(impulseStrength, 0.f); + i.Point = glm::vec2(cTransform->Position.x, cTransform->Position.y + 0.5f); + EventBroker->Publish(i); + + auto cModel = m_World->GetComponent(b); + cModel->Color = brickModel->Color; + cModel->Color *= 0.5f; + + m_World->RemoveComponent(b); + m_World->SetEntityParent(b, 0); + m_World->CommitEntity(b); + + //Particle trail + Events::CreateParticleSequence trail; + trail.parent = b; + trail.AlphaValues.push_back(1.f); + trail.AlphaValues.push_back(0.f); + trail.ScaleValues.push_back(glm::vec3(0.08f)); + trail.ScaleValues.push_back(glm::vec3(0.f)); + trail.RadiusDistribution = 1; + trail.EmitterLifeTime = 2.f; + trail.ParticleLifeTime = 1.f; + trail.ParticlesPerTick = 1; + trail.SpawnRate = 0.1f; + trail.Speed = 10.f; + trail.EmittingAngle = glm::half_pi(); + trail.SpriteFile = "Textures/Particles/FadeBall.png"; + trail.Color = brickModel->Color; + //p.Spread = ... + EventBroker->Publish(trail); + + //ParticlePoof + Events::CreateParticleSequence poof; + poof.EmitterLifeTime = 4; + poof.EmittingAngle = glm::half_pi(); + poof.Spread = 0.5f; + poof.NumberOfTicks = 1; + poof.ParticleLifeTime = 1.5f; + poof.ParticlesPerTick = 1; + poof.Position = cTransform->Position; + poof.ScaleValues.clear(); + poof.ScaleValues.push_back(glm::vec3(0.5f)); + poof.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f)); + poof.SpriteFile = "Textures/Particles/Cloud_Particle.png"; + poof.Color = brickModel->Color; + poof.AlphaValues.clear(); + poof.AlphaValues.push_back(1.f); + poof.AlphaValues.push_back(0.f); + poof.Speed = 10; + EventBroker->Publish(poof); + } + + + SetNumberOfBricks(NumberOfBricks() - 1); + Events::ScoreEvent es; + es.Score = brick->Score * combo; + EventBroker->Publish(es); + + m_LooseBricks--; + m_World->RemoveEntity(entityBrick); +} + +bool dd::Systems::LevelSystem::OnScoreEvent(const dd::Events::ScoreEvent &event) +{ + SetScore(Score() += event.Score); + + return true; +} + +bool dd::Systems::LevelSystem::OnMultiBall(const dd::Events::MultiBall &event) +{ + SetMultiBalls(MultiBalls()+2); + return true; +} + +bool dd::Systems::LevelSystem::OnMultiBallLost(const dd::Events::MultiBallLost &event) +{ + SetMultiBalls(MultiBalls()-1); + if (MultiBalls() < 0) { + SetMultiBalls(0); + } + return true; +} + +bool dd::Systems::LevelSystem::OnCreatePowerUp(const dd::Events::CreatePowerUp &event) +{ + SetPowerUps(PowerUps() + 1); + auto powerUp = m_World->CreateEntity(); + std::shared_ptr transform = m_World->AddComponent(powerUp); + auto model = m_World->AddComponent(powerUp); + std::shared_ptr cRec = m_World->AddComponent(powerUp); + std::shared_ptr cPhys = m_World->AddComponent(powerUp); + cPhys->CollisionType = CollisionType::Type::Dynamic; + cPhys->Category = CollisionLayer::Type::PowerUp; + cPhys->Mask = CollisionLayer::Type::Pad; + + std::shared_ptr cPow = m_World->AddComponent(powerUp); + + transform->Position = event.Position; + transform->Scale = glm::vec3(0.2, 0.2, 0.2); + transform->Velocity = glm::vec3(0, -4, 0); + + model->ModelFile = "Models/Test/Ball/Ballopus.obj"; + + m_World->CommitEntity(powerUp); + + return true; +} + +bool dd::Systems::LevelSystem::OnPowerUpTaken(const dd::Events::PowerUpTaken &event) +{ + SetPowerUps(PowerUps() - 1); + return true; +} + +bool dd::Systems::LevelSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event) +{ + SetNumberOfBricks(NumberOfBricks() - 1); + m_LooseBricks--; + + std::cout << m_LooseBricks << std::endl; + + return true; +} + +bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &event) +{ + if (!m_Cleared) { + m_Cleared = true; + SetRestarting(true); + Events::ResetBall e; + EventBroker->Publish(e); + Events::ScoreEvent es; + es.Score = 500; + EventBroker->Publish(es); + m_CurrentLevel++; + if (m_CurrentLevel <= event.StagesInCluster) { + GetNextLevel(); + CreateLevel(12); //NextLevelDistance + } else { + // Win + Events::ClusterClear e; + e.ClusterCleared = m_CurrentCluster; + EventBroker->Publish(e); + + Events::Pause p; + p.Type = "All"; + EventBroker->Publish(p); + } + } + return true; +} + +bool dd::Systems::LevelSystem::OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event) +{ + m_Cleared = false; + return true; +} + +void dd::Systems::LevelSystem::GetNextLevel() +{ + std::array level; + std::array color; + // Level array indicates type of brick. + // 0 is empty space. + // 1 is standard brick. + // 2 is multiball brick. + // 3 is lifebuoy brick. + // 4 is sticky brick. + // 5 is ink blaster brick. + // 6 is kraken attack brick. + + // 100 is KRAKEN! + + // color array determines the color of standard bricks. + // w is white. + // r is red. + // g is green. + // b is blue. + // y is yellow. + // c is cyan. + // m is magenta. + // d is dark. + // Feel free to make your own. + glm::vec4 w = glm::vec4(1, 1, 1, 0); + glm::vec4 r = glm::vec4(1, 0, 0, 0); + glm::vec4 g = glm::vec4(0, 1, 0, 0); + glm::vec4 b = glm::vec4(0, 0, 1, 0); + glm::vec4 y = glm::vec4(1, 1, 0, 0); + glm::vec4 c = glm::vec4(0, 1, 1, 0); + glm::vec4 m = glm::vec4(1, 0, 1, 0); + glm::vec4 d = glm::vec4(0, 0, 0, 0); + + //glm::vec4 p4 = glm::vec4(asd.f / 255.f, asd.f / 255.f, sad.f / 255.f, 1.f); + glm::vec4 br = glm::vec4(143.f / 255.f, 98.f / 255.f, 0.f / 255.f, 1.f); + + glm::vec4 lb1 = glm::vec4(115.f / 255.f, 232.f / 255.f, 236.f / 255.f, 1.f); + glm::vec4 lb2 = glm::vec4(107.f / 255.f, 214.f / 255.f, 218.f / 255.f, 1.f); + glm::vec4 lb3 = glm::vec4(91.f / 255.f, 183.f / 255.f, 186.f / 255.f, 1.f); + glm::vec4 lb4 = glm::vec4(70.f / 255.f, 153.f / 255.f, 156.f / 255.f, 1.f); + + glm::vec4 p1 = glm::vec4(255.f / 255.f, 184.f / 255.f, 254.f / 255.f, 1.f); + glm::vec4 p2 = glm::vec4(255.f / 255.f, 81.f / 255.f, 253.f / 255.f, 1.f); + glm::vec4 p3 = glm::vec4(189.f / 255.f, 0.f / 255.f, 187.f / 255.f, 1.f); + glm::vec4 p4 = glm::vec4(125.f / 255.f, 0.f / 255.f, 147.f / 255.f, 1.f); + + + if (m_CurrentCluster == 0) { + if (m_CurrentLevel == 1) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1}; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w}; + } else if (m_CurrentLevel == 2) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 100, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0}; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w}; + } else if (m_CurrentLevel == 3) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0}; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w}; + } else if (m_CurrentLevel == 4) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1}; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w}; + } else if (m_CurrentLevel == 5) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0}; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w}; + } else if (m_CurrentLevel == 6) { + level = + {0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0}; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w}; + } + } else if (m_CurrentCluster == 1) { + if (m_CurrentLevel == 1) { + level = + {0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 2, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0}; + color = + {w, w, w, w, w, w, w, + lb4, lb4, lb4, lb4, lb4, lb4, lb4, + lb3, lb3, lb3, lb3, lb3, lb3, lb3, + lb2, lb2, lb2, lb2, lb2, lb2, lb2, + lb1, lb1, lb1, lb1, lb1, lb1, lb1, + w, w, w, w, w, w, w}; + } else if (m_CurrentLevel == 2) { + level = + {0, 0, 1, 0, 1, 0, 0, + 0, 1, 0, 1, 0, 1, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 3, 0, 0, 0, + 1, 1, 1, 0, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 1}; + color = + {w, w, r, w, r, w, w, + w, w, w, r, w, w, w, + w, w, r, w, r, w, w, + w, w, w, w, w, w, w, + w, r, w, w, w, r, w, + r, w, w, w, w, w, r}; + } else if (m_CurrentLevel == 3) { + level = + {0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 4, 1, 1, 1, + 0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0}; + color = + {g, g, g, g, g, g, g, + g, g, g, g, g, g, g, + g, g, g, g, g, g, g, + g, g, g, w, g, g, g, + w, w, w, br, w, w, w, + w, w, br, br, br, w, w}; + } else if (m_CurrentLevel == 4) { + level = + {0, 0, 1, 0, 1, 0, 0, + 0, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 0, + 0, 0, 1, 5, 1, 0, 0, + 0, 0, 0, 1, 0, 0, 0}; + color = + {w, w, p1, w, p1, w, w, + w, p2, p3, p2, p3, p2, w, + p1, p2, p3, p4, p3, p2, p1, + w, p1, p2, p3, p2, p1, w, + w, w, p1, w, p1, w, w, + w, w, w, p1, w, w, w}; + } else if (m_CurrentLevel == 5) { + level = + {0, 1, 0, 0, 0, 1, 0, + 1, 4, 1, 1, 1, 3, 1, + 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, + 1, 5, 1, 6, 1, 2, 1, + 0, 1, 0, 0, 0, 1, 0}; + color = + {w, p3, w, w, w, r, w, + p2, w, p1, g, w, w, w, + w, p4, w, g, w, r, w, + w, br, w, g, w, lb1, w, + y, w, y, d, b, w, b, + w, br, w, w, w, lb1, w}; + } + else if (m_CurrentLevel == 6) { + level = + {0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 100, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0}; + color = + {w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w, + w, w, w, w, w, w, w}; + } + } else if (m_CurrentCluster == 3) { + + } + + std::copy(std::begin(level), std::end(level), std::begin(m_Bricks)); + std::copy(std::begin(color), std::end(color), std::begin(m_Colors)); +} + +bool dd::Systems::LevelSystem::OnHitPad(const dd::Events::HitPad &event) +{ + m_Cleared = false; + return true; +} + +void dd::Systems::LevelSystem::SetBrokenModel(EntityID entity) +{ + std::uniform_int_distribution dist(0, 2); + int index = dist(m_RandomGenerator); + + switch (index) + { + case 0: + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/1/WhiteBrickBreak1.obj", glm::vec3(-0.29912f, 0.0082f, 0.f), glm::vec2(0.281f, 0.351f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/1/WhiteBrickBreak2.obj", glm::vec3(0.07597f, -0.02899f, 0.f), glm::vec2(0.559f, 0.351f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/1/WhiteBrickBreak3.obj", glm::vec3(0.3227f, 0.05632, 0.f), glm::vec2(0.25f, 0.25f)); + break; + + case 1: + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/2/WhiteBrickBreak1.obj", glm::vec3(-0.3236f, 0.0159f, 0.f), glm::vec2(0.237f, 0.327f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/2/WhiteBrickBreak2.obj", glm::vec3(0.07645f, 0.03131f, 0.f), glm::vec2(0.594f, 0.211f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/2/WhiteBrickBreak3.obj", glm::vec3(0.09468f, -0.11792f, 0.f), glm::vec2(0.692f, 0.112f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/2/WhiteBrickBreak4.obj", glm::vec3(0.33957f, 0.13079f, 0.f), glm::vec2(0.208f, 0.085f)); + break; + + case 2: + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/3/WhiteBrickBreak1.obj", glm::vec3(-0.34882f, 0.0564f, 0.f), glm::vec2(0.175f, 0.228f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/3/WhiteBrickBreak2.obj", glm::vec3(0.0678f, 0.07679f, 0.f), glm::vec2(0.699f, 0.183f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/3/WhiteBrickBreak3.obj", glm::vec3(-0.11862f, -0.10342, 0.f), glm::vec2(0.563f, 0.164f)); + CreateBrokenModelPart(entity, "Models/Brick/BrickBreak/3/WhiteBrickBreak4.obj", glm::vec3(0.31479f, -0.06351f, 0.f), glm::vec2(0.261f, 0.21f)); + break; + + default: + LOG_INFO("Something went wrong with the random generator in SetBrokenModel"); + break; + } +} + +void dd::Systems::LevelSystem::CreateBrokenModelPart(EntityID Parent, std::string ModelPath, glm::vec3 RelativePosition, glm::vec2 Hitbox) +{ + auto ent = m_World->CreateEntity(Parent); + auto cTemplate = m_World->AddComponent(ent); + auto cTransform = m_World->AddComponent(ent); + + cTransform->Position = RelativePosition; + + auto cModel = m_World->AddComponent(ent); + cModel->ModelFile = ModelPath; + + auto cRec = m_World->AddComponent(ent); + cRec->Dimensions = Hitbox; + + auto cPhys = m_World->AddComponent(ent); + cPhys->CollisionType = CollisionType::Type::Dynamic; + cPhys->GravityScale = 1.f; + cPhys->Category = CollisionLayer::Type::Brick; + cPhys->Mask = static_cast(CollisionLayer::Type::Wall); +} diff --git a/src/game/Game/PadSystem.cpp b/src/game/Game/PadSystem.cpp index a0d3ec5..eb8b921 100755 --- a/src/game/Game/PadSystem.cpp +++ b/src/game/Game/PadSystem.cpp @@ -30,6 +30,7 @@ void dd::Systems::PadSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &PadSystem::OnResetBall); EVENT_SUBSCRIBE_MEMBER(m_EResetAll, &PadSystem::OnResetAll); EVENT_SUBSCRIBE_MEMBER(m_ERaiseWater, &PadSystem::OnRaiseWater); + EVENT_SUBSCRIBE_MEMBER(m_ERaiseWaterWall, &PadSystem::OnRaiseWaterWall); EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause); EVENT_SUBSCRIBE_MEMBER(m_EResume, &PadSystem::OnResume); EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack); @@ -74,6 +75,17 @@ void dd::Systems::PadSystem::Initialize() m_StickTransform = transform; m_StickyAim = sticky; + + /*{ + auto entChild = m_World->CreateEntity(ent); + std::shared_ptr transform = m_World->AddComponent(entChild); + transform->Position = glm::vec3(0.f, 12.5f, 0.f); + + transform->Scale = glm::vec3(0.1f, 25.f, 0.1f); + std::shared_ptr sprite = m_World->AddComponent(entChild); + sprite->SpriteFile = "Models/Brick/White.png"; + sprite->Color = glm::vec4(0.f, 0.5f, 0.f, 0.5f); + }*/ } m_ResetBall = true; @@ -218,8 +230,14 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) { } else if (val == GLFW_KEY_W) { Events::RaiseWater e; e.Amount = 0.2; + e.Speed = 0.2; EventBroker->Publish(e); - } else if (val == GLFW_KEY_A) { + } else if (val == GLFW_KEY_Q) { + Events::RaiseWaterWall e; + e.Amount = 0.2; + e.Speed = 0.2; + EventBroker->Publish(e); + } else if (val == GLFW_KEY_A) { Events::ResetAll e; EventBroker->Publish(e); } else if (val == GLFW_KEY_M) { @@ -266,6 +284,7 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) { } else if (val == GLFW_KEY_I) { Events::InkBlaster e; e.Shots = 5; + e.Speed = 7; EventBroker->Publish(e); } else if (val == GLFW_KEY_K) { Events::KrakenAttack e; @@ -415,21 +434,29 @@ bool dd::Systems::PadSystem::OnResetAll(const dd::Events::ResetAll &event) } bool dd::Systems::PadSystem::OnRaiseWater(const dd::Events::RaiseWater &event) +{ + RaisePad(event.Amount, event.Speed); + + return true; +} + +bool dd::Systems::PadSystem::OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event) +{ + RaisePad(event.Amount, event.Speed); + + return true; +} + +bool dd::Systems::PadSystem::RaisePad(float amount, float speed) { auto transform = Transform(); - glm::vec3 raise = glm::vec3(0, event.Amount, 0); - transform->Position += raise; - - { - auto t_waterBody = m_World->CreateEntity(); - auto transform = m_World->AddComponent(t_waterBody); - transform->Position = glm::vec3(0.f, -3.5f, -10.f); - transform->Scale = glm::vec3(7.0f, event.Amount * 1.6f, 1.f); - auto water = m_World->AddComponent(t_waterBody); - auto body = m_World->AddComponent(t_waterBody); - m_World->CommitEntity(t_waterBody); - } - + glm::vec3 raise = glm::vec3(0, amount, 0); + Events::Move e; + e.Entity = m_Entity; + e.GoalPosition = transform->Position + raise; + e.Speed = speed; + e.Queue = true; + EventBroker->Publish(e); return true; } diff --git a/src/game/Game/ProjectileSystem.cpp b/src/game/Game/ProjectileSystem.cpp index 81cd5e6..eba7b43 100644 --- a/src/game/Game/ProjectileSystem.cpp +++ b/src/game/Game/ProjectileSystem.cpp @@ -100,6 +100,7 @@ bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &e { m_InkBlaster = true; m_Shots = event.Shots; + m_InkBlasterSpeed = event.Speed; return true; } @@ -117,9 +118,11 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto if (m_InkBlaster && m_SquidLoaded) { auto ent = m_World->CloneEntity(m_InkBlastTemplate); m_World->RemoveComponent(ent); + auto projectile = m_World->GetComponent(ent); + projectile->Speed = m_InkBlasterSpeed; auto transform = m_World->GetComponent(ent); transform->Position = event.Position; - transform->Velocity = glm::vec3(0, 7, 0); + transform->Velocity = glm::vec3(0, projectile->Speed, 0); m_Shots--; if (m_Shots <= 0) { auto ball = m_World->GetComponent(m_AttachedSquid); diff --git a/src/game/Game/ProjectileSystem.cpp.orig b/src/game/Game/ProjectileSystem.cpp.orig new file mode 100644 index 0000000..69b3667 --- /dev/null +++ b/src/game/Game/ProjectileSystem.cpp.orig @@ -0,0 +1,151 @@ +// +// Created by Adniklastrator on 2015-10-08. +// + + +#include "PrecompiledHeader.h" +#include "Game/ProjectileSystem.h" + + +void dd::Systems::ProjectileSystem::Initialize() +{ + EVENT_SUBSCRIBE_MEMBER(m_EContact, &ProjectileSystem::OnContact); + EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause); + EVENT_SUBSCRIBE_MEMBER(m_EResume, &ProjectileSystem::OnResume); + EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster); + EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad); + EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton); + + //Ink Blast + { + auto ent = m_World->CreateEntity(); + m_World->SetProperty(ent, "Name", "Projectile"); + std::shared_ptr ctransform = m_World->AddComponent(ent); + + auto circleShape = m_World->AddComponent(ent); + auto inkBlastTemplate = m_World->AddComponent(ent); + circleShape->Radius = 0.1f; + auto physics = m_World->AddComponent(ent); + physics->CollisionType = CollisionType::Type::Dynamic; + physics->Category = CollisionLayer::Type::Projectile; + physics->Mask = static_cast(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall); + physics->Calculate = true; + ctransform->Position = glm::vec3(0.f, 0.f, -10.f); + ctransform->Scale = glm::vec3(0.6f, 0.6f, 0.6f); +// auto cModel = m_World->AddComponent(ent); +// cModel->ModelFile = "Models/Test/Ball/Sid.obj"; + auto cSprite = m_World->AddComponent(ent); + cSprite->SpriteFile = "Textures/Particles/OilShot.png"; + auto projectile = m_World->AddComponent(ent); + + m_World->CommitEntity(ent); + + m_InkBlastTemplate = ent; + } + + return; +} + +void dd::Systems::ProjectileSystem::Update(double dt) +{ + if (m_Pause) { + return; + } +} + +void dd::Systems::ProjectileSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) +{ + if (IsPaused()) { + return; + } + auto templateCheck = m_World->GetComponent(entity); + if (templateCheck != nullptr){ return; } + + auto shot = m_World->GetComponent(entity); + if (shot != nullptr) { + auto transform = m_World->GetComponent(entity); + if (transform->Position.y > 8) { + m_World->RemoveEntity(entity); + } + } +} + +bool dd::Systems::ProjectileSystem::OnPause(const dd::Events::Pause &event) +{ + /*if (event.Type != "ProjectileSystem" && event.Type != "All") { + return false; + }*/ + + m_Pause = true; + + return true; +} + +bool dd::Systems::ProjectileSystem::OnResume(const dd::Events::Resume &event) +{ + /*if (event.Type != "ProjectileSystem" && event.Type != "All") { + return false; + }*/ + m_Pause = false; + return true; +} + +bool dd::Systems::ProjectileSystem::OnContact(const dd::Events::Contact &event) +{ + + return true; +} + +bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event) +{ + m_InkBlaster = true; + m_Shots = event.Shots; + m_InkBlasterSpeed = event.Speed; + return true; +} + +bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event) +{ + if (m_InkBlaster) { + m_SquidLoaded = true; + m_AttachedSquid = event.Ball; + } + return true; +} + +bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event) +{ + if (m_InkBlaster && m_SquidLoaded) { + auto ent = m_World->CloneEntity(m_InkBlastTemplate); + m_World->RemoveComponent(ent); + auto projectile = m_World->GetComponent(ent); + projectile->Speed = m_InkBlasterSpeed; + auto transform = m_World->GetComponent(ent); + transform->Position = event.Position; +<<<<<<< HEAD + transform->Velocity = glm::vec3(0, projectile->Speed, 0); +======= + transform->Velocity = glm::vec3(0, 7, 0); +>>>>>>> origin/master + m_Shots--; + if (m_Shots <= 0) { + auto ball = m_World->GetComponent(m_AttachedSquid); + m_InkBlaster = false; + m_SquidLoaded = false; + ball->InkBlaster = false; + ball->Sticky = false; + ball->Waiting = true; + + { + Events::InkBlasterOver e; + e.Ball = m_AttachedSquid; + EventBroker->Publish(e); + } + { + Events::ActionButton e; + EventBroker->Publish(e); + } + } + } + return true; +} diff --git a/src/game/Game/TravellingSystem.cpp b/src/game/Game/TravellingSystem.cpp index 13dc89b..f6985e2 100644 --- a/src/game/Game/TravellingSystem.cpp +++ b/src/game/Game/TravellingSystem.cpp @@ -97,7 +97,7 @@ bool dd::Systems::TravellingSystem::OnResume(const dd::Events::Resume &event) bool dd::Systems::TravellingSystem::OnStageCleared(const dd::Events::StageCleared &event) { - if (event.ClearedStage < 5) { + if (event.ClearedStage < event.StagesInCluster) { m_Travelling = true; } return true; diff --git a/src/game/Game/WaterSystem.cpp b/src/game/Game/WaterSystem.cpp new file mode 100644 index 0000000..39a5b8c --- /dev/null +++ b/src/game/Game/WaterSystem.cpp @@ -0,0 +1,124 @@ +// +// Created by Adniklastrator on 2015-10-20. +// + +#include "PrecompiledHeader.h" +#include "Game/WaterSystem.h" + +void dd::Systems::WaterSystem::Initialize() +{ + EVENT_SUBSCRIBE_MEMBER(m_EPause, &WaterSystem::OnPause); + EVENT_SUBSCRIBE_MEMBER(m_EResume, &WaterSystem::OnResume); + EVENT_SUBSCRIBE_MEMBER(m_ERelevantObjectCreated, &WaterSystem::OnRelevantObjectCreated); + EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &WaterSystem::OnStageCleared); + EVENT_SUBSCRIBE_MEMBER(m_ERaiseWater, &WaterSystem::OnRaiseWater); + EVENT_SUBSCRIBE_MEMBER(m_ERaiseWaterWall, &WaterSystem::OnRaiseWaterWall); + + //Water test + { + auto t_waterBody = m_World->CreateEntity(); + auto transform = m_World->AddComponent(t_waterBody); + transform->Position = glm::vec3(0.f, -3.5f, -10.f); + transform->Scale = glm::vec3(7.0f, 1.5f, 1.f); + auto water = m_World->AddComponent(t_waterBody); + auto body = m_World->AddComponent(t_waterBody); + m_World->CommitEntity(t_waterBody); + } +} + +void dd::Systems::WaterSystem::Update(double dt) +{ + if (m_Pause) { + return; + } + +} + +void dd::Systems::WaterSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) +{ + if (m_Pause) { + return; + } + + auto templateCheck = m_World->GetComponent(entity); + if (templateCheck != nullptr){ return; } + + if (m_BottomWall == 0) { + for (auto it = m_World->GetEntities()->begin(); it != m_World->GetEntities()->end(); it++) { + if (m_World->GetProperty(it->first, "Name") == "BottomWall") { + m_BottomWall = entity; + break; + } + } + } +} + +bool dd::Systems::WaterSystem::OnPause(const dd::Events::Pause &event) +{ + /*if (event.Type != "WaterSystem" && event.Type != "All") { + return false; + }*/ + m_Pause = true; + return true; +} +bool dd::Systems::WaterSystem::OnResume(const dd::Events::Resume &event) +{ + /*if (event.Type != "WaterSystem" && event.Type != "All") { + return false; + }*/ + m_Pause = false; + return true; +} + +bool dd::Systems::WaterSystem::OnRelevantObjectCreated(const dd::Events::RelevantObjectCreated &event) +{ + if (event.ObjectName == "BottomWall") { + m_BottomWall = event.ObjectID; + } + return true; +} + +bool dd::Systems::WaterSystem::OnStageCleared(const dd::Events::StageCleared &event) +{ + + return true; +} + +bool dd::Systems::WaterSystem::OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event) +{ + + return true; +} + +bool dd::Systems::WaterSystem::OnRaiseWater(const dd::Events::RaiseWater &event) +{ + { + auto t_waterBody = m_World->CreateEntity(); + auto transform = m_World->AddComponent(t_waterBody); + transform->Position = glm::vec3(0.f, -3.5f, -10.f); + transform->Scale = glm::vec3(7.0f, event.Amount * 1.6f, 1.f); + auto water = m_World->AddComponent(t_waterBody); + auto body = m_World->AddComponent(t_waterBody); + m_World->CommitEntity(t_waterBody); + } + + return true; +} + +bool dd::Systems::WaterSystem::OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event) +{ + auto transform = m_World->GetComponent(m_BottomWall); + if (transform != nullptr) { + glm::vec3 raise = glm::vec3(0, event.Amount, 0); + Events::Move e; + e.Entity = m_BottomWall; + e.GoalPosition = transform->Position + raise; + e.Queue = true; + e.Speed = 0.2; + EventBroker->Publish(e); + } else { + LOG_ERROR("There is no BottomWall in WaterSystem"); + } + + return true; +} \ No newline at end of file diff --git a/src/game/Core/Camera.cpp b/src/game/Rendering/Camera.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/game/Core/Camera.cpp rename to src/game/Rendering/Camera.cpp index 4c1577d..65e9010 --- a/src/game/Core/Camera.cpp +++ b/src/game/Rendering/Camera.cpp @@ -17,7 +17,7 @@ */ #include "PrecompiledHeader.h" -#include "Core/Camera.h" +#include "Rendering/Camera.h" dd::Camera::Camera(float aspectRatio, float yFOV, float nearClip, float farClip) { @@ -85,12 +85,8 @@ void dd::Camera::UpdateProjectionMatrix() // m_NearClip, // m_FarClip // ); - m_ProjectionMatrix = glm::perspective( - m_FOV, - m_AspectRatio, - m_NearClip, - m_FarClip - ); + + m_ProjectionMatrix = glm::perspective(m_FOV, m_AspectRatio, m_NearClip, m_FarClip); } void dd::Camera::UpdateViewMatrix() diff --git a/src/game/Rendering/DirectX/Model.cpp b/src/game/Rendering/DirectX/Model.cpp new file mode 100644 index 0000000..17b5fef --- /dev/null +++ b/src/game/Rendering/DirectX/Model.cpp @@ -0,0 +1,20 @@ +#include "PrecompiledHeader.h" +#include "Rendering/Model.h" + +dd::Model::Model(std::string fileName) + : dd::RawModel(fileName) +{ + D3D11_BUFFER_DESC vbd = { 0 }; + vbd.ByteWidth = sizeof(RawModel::Vertex) * m_Vertices.size(); + vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER; + D3D11_SUBRESOURCE_DATA vsrd = { m_Vertices.data(), 0, 0 }; + StaticSystem::Get()->m_Device->CreateBuffer(&vbd, &vsrd, &VertexBuffer); + + D3D11_BUFFER_DESC ibd = { 0 }; + ibd.ByteWidth = sizeof(unsigned int) * m_Indices.size(); + ibd.BindFlags = D3D11_BIND_INDEX_BUFFER; + D3D11_SUBRESOURCE_DATA idata = { 0 }; + idata.pSysMem = m_Indices.data(); + StaticSystem::Get()->m_Device->CreateBuffer(&ibd, &idata, &IndexBuffer); +} + diff --git a/src/game/Rendering/DirectX/Renderer.cpp b/src/game/Rendering/DirectX/Renderer.cpp new file mode 100644 index 0000000..67447a0 --- /dev/null +++ b/src/game/Rendering/DirectX/Renderer.cpp @@ -0,0 +1,429 @@ +#include "PrecompiledHeader.h" +#include "Rendering/Renderer.h" + +#include "Rendering/Model.h" +#include "Rendering/Skeleton.h" +#include "Rendering/ShaderProgram.h" + +void dd::Renderer::Initialize() +{ + StaticSystem::Set(this); + + // Initialize GLFW + if (!glfwInit()) { + LOG_ERROR("GLFW: Initialization failed"); + exit(EXIT_FAILURE); + } + + // Create a window + GLFWmonitor* monitor = nullptr; + if (m_Fullscreen) { + monitor = glfwGetPrimaryMonitor(); + } + glfwWindowHint(GLFW_SAMPLES, 8); + m_Window = glfwCreateWindow(m_Resolution.Width, m_Resolution.Height, "Squidout! (DirectX 11)", monitor, nullptr); + if (!m_Window) { + LOG_ERROR("GLFW: Failed to create window"); + exit(EXIT_FAILURE); + } + //glfwMakeContextCurrent(m_Window); + + // Create default camera + m_DefaultCamera = std::unique_ptr(new dd::Camera((float)m_Resolution.Width / m_Resolution.Height, 45.f, 0.01f, 5000.f)); + m_DefaultCamera->SetPosition(glm::vec3(0, 0, 0)); + if (m_Camera == nullptr) { + m_Camera = m_DefaultCamera.get(); + } + + DXGI_SWAP_CHAIN_DESC scd = { 0 }; + scd.BufferCount = 1; + scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + scd.OutputWindow = glfwGetWin32Window(m_Window); + scd.SampleDesc.Count = 4; + scd.Windowed = TRUE; + scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + + D3D11CreateDeviceAndSwapChain( + NULL, + D3D_DRIVER_TYPE_HARDWARE, + NULL, + NULL, + NULL, + NULL, + D3D11_SDK_VERSION, + &scd, + &m_SwapChain, + &m_Device, + NULL, + &m_DeviceContext); + + // Set the back buffer render target + ID3D11Texture2D* pBackBuffer; + m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pBackBuffer); + m_Device->CreateRenderTargetView(pBackBuffer, NULL, &m_BackBuffer); + pBackBuffer->Release(); + // Depth buffer + D3D11_TEXTURE2D_DESC texd = { }; + texd.Width = m_Resolution.Width; + texd.Height = m_Resolution.Height; + texd.ArraySize = 1; + texd.MipLevels = 1; + texd.SampleDesc.Count = 4; + texd.Format = DXGI_FORMAT_D32_FLOAT; + texd.BindFlags = D3D11_BIND_DEPTH_STENCIL; + ID3D11Texture2D* pDepthBuffer; + m_Device->CreateTexture2D(&texd, NULL, &pDepthBuffer); + D3D11_DEPTH_STENCIL_VIEW_DESC dsvd = { }; + dsvd.Format = DXGI_FORMAT_D32_FLOAT; + dsvd.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS; + m_Device->CreateDepthStencilView(pDepthBuffer, &dsvd, &m_DepthBuffer); + pDepthBuffer->Release(); + // Set back and depth buffer + m_DeviceContext->OMSetRenderTargets(1, &m_BackBuffer, m_DepthBuffer); + + // Rasterizer settings + setDefaultRasterState(); + + D3D11_BLEND_DESC blend = { 0 }; + for (int i = 0; i < 1; i++) { + blend.RenderTarget[i].BlendEnable = true; + blend.RenderTarget[i].BlendOp = D3D11_BLEND_OP_ADD; + blend.RenderTarget[i].SrcBlend = D3D11_BLEND_SRC_ALPHA; + blend.RenderTarget[i].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blend.RenderTarget[i].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blend.RenderTarget[i].SrcBlendAlpha = D3D11_BLEND_ONE; + blend.RenderTarget[i].DestBlendAlpha = D3D11_BLEND_ZERO; + blend.RenderTarget[i].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + } + ID3D11BlendState* blendState; + m_Device->CreateBlendState(&blend, &blendState); + m_DeviceContext->OMSetBlendState(blendState, nullptr, 0xffffffff); + + + D3D11_INPUT_ELEMENT_DESC VertexIED[] = { + {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 1, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"COLOR", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"BLENDINDICES", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"BLENDINDICES", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"BLENDWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"BLENDWEIGHT", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + m_ForwardShaderProgram = new ShaderProgram(); + m_ForwardShaderProgram->CompileVertexShader(L"Shaders/DirectX/vertex.hlsl"); + m_ForwardShaderProgram->CompilePixelShader(L"Shaders/DirectX/pixel.hlsl"); + m_ForwardShaderProgram->CreateInputLayout(VertexIED, sizeof(VertexIED) / sizeof(VertexIED[0])); + m_GUIShaderProgram = new ShaderProgram(); + m_GUIShaderProgram->CompileVertexShader(L"Shaders/DirectX/vertex.hlsl"); + m_GUIShaderProgram->CompilePixelShader(L"Shaders/DirectX/Flat.pixel.hlsl"); + m_GUIShaderProgram->CreateInputLayout(VertexIED, sizeof(VertexIED) / sizeof(VertexIED[0])); + + // Create constant buffer + // TODO: Put this in shader + D3D11_BUFFER_DESC bd = { }; + bd.ByteWidth = sizeof(ConstantBufferStruct); + bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + m_Device->CreateBuffer(&bd, NULL, &constantBuffer); + m_DeviceContext->VSSetConstantBuffers(0, 1, &constantBuffer); + m_DeviceContext->PSSetConstantBuffers(0, 1, &constantBuffer); + + D3D11_SAMPLER_DESC samplerDesc; + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; + samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; + samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; + samplerDesc.MipLODBias = 0.0f; + samplerDesc.MaxAnisotropy = 1; + samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; + samplerDesc.BorderColor[0] = 1.f; + samplerDesc.BorderColor[1] = 0; + samplerDesc.BorderColor[2] = 1.f; + samplerDesc.BorderColor[3] = 0; + samplerDesc.MinLOD = 0; + samplerDesc.MaxLOD = D3D11_FLOAT32_MAX; + m_Device->CreateSamplerState(&samplerDesc, &m_SamplerState); + + m_UnitQuad = ResourceManager::Load("Models/Core/UnitQuad.obj"); + m_WhiteSphereTexture = ResourceManager::Load("Textures/Test/Water.png"); +} + +void dd::Renderer::Draw(RenderQueueCollection& rq) +{ + using namespace DirectX::SimpleMath; + + rq.Forward.Jobs.sort(dd::Renderer::DepthSort); + + m_DeviceContext->OMSetRenderTargets(1, &m_BackBuffer, m_DepthBuffer); + float color[] = { 0.f, 0.f, 0.f, 1.f }; + m_DeviceContext->ClearRenderTargetView(m_BackBuffer, color); + m_DeviceContext->ClearDepthStencilView(m_DepthBuffer, D3D11_CLEAR_DEPTH, 1.0f, 0); + + // Set the viewport + D3D11_VIEWPORT viewport = { 0 }; + viewport.TopLeftX = 0; + viewport.TopLeftY = 0; + viewport.Width = m_Resolution.Width; + viewport.Height = m_Resolution.Height; + viewport.MinDepth = 0; + viewport.MaxDepth = 1; + m_DeviceContext->RSSetViewports(1, &viewport); + + m_ForwardShaderProgram->Bind(); + + Matrix proj = DirectX::SimpleMath::Matrix::CreatePerspectiveFieldOfView(m_Camera->m_FOV, m_Camera->m_AspectRatio, m_Camera->m_NearClip, m_Camera->m_FarClip); // Right-handed + Matrix view = Matrix::CreateTranslation(Vector3(m_Camera->Position().x, m_Camera->Position().y, -m_Camera->Position().z)); + + int i = 0; + constantBufferStruct.NumLights = 0; + for (auto &job : rq.Lights) { + auto pointLightJob = std::dynamic_pointer_cast(job); + if (pointLightJob) { + glm::vec3 p = pointLightJob->Position; + constantBufferStruct.LightPositions[i] = Vector4(p.r, p.g, p.b, 0.f); + glm::vec3 c = pointLightJob->DiffuseColor; + constantBufferStruct.LightColors[i] = Vector4(c.r, c.g, c.b, 1.f); + constantBufferStruct.LightRadii[i] = pointLightJob->Radius; + constantBufferStruct.NumLights++; + i++; + } + } + + for (auto &job : rq.Deferred) { + auto modelJob = std::dynamic_pointer_cast(job); + if (modelJob) { + constantBufferStruct.MVP = Matrix(glm::value_ptr(modelJob->ModelMatrix)) * view * proj; + constantBufferStruct.InverseTransposeViewModel = (Matrix(glm::value_ptr(modelJob->ModelMatrix)) * view).Transpose().Invert(); + constantBufferStruct.Color = Vector4(modelJob->Color.r, modelJob->Color.g, modelJob->Color.b, modelJob->Color.a); + + m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0); + m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState); + + m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + UINT stride = sizeof(Model::Vertex); + UINT offset = 0; + m_DeviceContext->IASetVertexBuffers(0, 1, &modelJob->Model->VertexBuffer, &stride, &offset); + m_DeviceContext->IASetIndexBuffer(modelJob->Model->IndexBuffer, DXGI_FORMAT_R32_UINT, 0); + + if (modelJob->DiffuseTexture != nullptr) { + m_DeviceContext->PSSetShaderResources(0, 1, &modelJob->DiffuseTexture->m_ShaderResourceView); + } + //m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex); + m_DeviceContext->DrawIndexed(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex, 0); + + continue; + } + } + + for (auto &job : rq.Forward) { + auto spriteJob = std::dynamic_pointer_cast(job); + if (spriteJob) { + constantBufferStruct.MVP = Matrix(glm::value_ptr(spriteJob->ModelMatrix)) * view * proj; + constantBufferStruct.InverseTransposeViewModel = (Matrix(glm::value_ptr(spriteJob->ModelMatrix)) * view).Transpose().Invert(); + constantBufferStruct.Color = Vector4(glm::value_ptr(spriteJob->Color)); + + m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0); + m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState); + + m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + UINT stride = sizeof(Model::Vertex); + UINT offset = 0; + m_DeviceContext->IASetVertexBuffers(0, 1, &m_UnitQuad->VertexBuffer, &stride, &offset); + m_DeviceContext->IASetIndexBuffer(m_UnitQuad->IndexBuffer, DXGI_FORMAT_R32_UINT, 0); + + if (spriteJob->DiffuseTexture != nullptr) { + m_DeviceContext->PSSetShaderResources(0, 1, &spriteJob->DiffuseTexture->m_ShaderResourceView); + } + //m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex); + m_DeviceContext->DrawIndexed(m_UnitQuad->m_Indices.size(), 0, 0); + + continue; + } + + auto waterJob = std::dynamic_pointer_cast(job); + if (waterJob) { + constantBufferStruct.MVP = Matrix(glm::value_ptr(waterJob->ModelMatrix)) * view * proj; + constantBufferStruct.InverseTransposeViewModel = (Matrix(glm::value_ptr(waterJob->ModelMatrix)) * view).Transpose().Invert(); + constantBufferStruct.Color = Vector4(glm::value_ptr(waterJob->Color)); + + m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0); + m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState); + + m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + UINT stride = sizeof(Model::Vertex); + UINT offset = 0; + m_DeviceContext->IASetVertexBuffers(0, 1, &m_UnitQuad->VertexBuffer, &stride, &offset); + m_DeviceContext->IASetIndexBuffer(m_UnitQuad->IndexBuffer, DXGI_FORMAT_R32_UINT, 0); + + m_DeviceContext->PSSetShaderResources(0, 1, &m_WhiteSphereTexture->m_ShaderResourceView); + //m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex); + m_DeviceContext->DrawIndexed(m_UnitQuad->m_Indices.size(), 0, 0); + + continue; + } + } + + m_DeviceContext->OMSetRenderTargets(1, &m_BackBuffer, nullptr); + m_GUIShaderProgram->Bind(); + + for (auto &job : rq.GUI) { + auto frameJob = std::dynamic_pointer_cast(job); + if (frameJob) { + Rectangle& vp = frameJob->Viewport; + glViewport(vp.X, m_Resolution.Height - vp.Y - vp.Height, vp.Width, vp.Height); + Rectangle& sc = frameJob->Scissor; + if (sc == Rectangle()) { + glDisable(GL_SCISSOR_TEST); + } else { + glEnable(GL_SCISSOR_TEST); + glScissor(sc.X, m_Resolution.Height - sc.Y - sc.Height, sc.Width, sc.Height); + } + + D3D11_VIEWPORT viewport = { 0 }; + viewport.TopLeftX = vp.X; + viewport.TopLeftY = vp.Y; + viewport.Width = vp.Width; + viewport.Height = vp.Height; + viewport.MinDepth = 0; + viewport.MaxDepth = 1; + m_DeviceContext->RSSetViewports(1, &viewport); + + proj = Matrix::Identity; + view = Matrix::Identity; + Matrix model = Matrix::CreateScale(2.f); + constantBufferStruct.MVP = model * view * proj; + constantBufferStruct.InverseTransposeViewModel = (model * view).Transpose().Invert(); + constantBufferStruct.Color = Vector4(glm::value_ptr(frameJob->Color)); + + m_DeviceContext->UpdateSubresource(constantBuffer, 0, 0, &constantBufferStruct, 0, 0); + m_DeviceContext->PSSetSamplers(0, 1, &m_SamplerState); + + m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + UINT stride = sizeof(Model::Vertex); + UINT offset = 0; + m_DeviceContext->IASetVertexBuffers(0, 1, &m_UnitQuad->VertexBuffer, &stride, &offset); + m_DeviceContext->IASetIndexBuffer(m_UnitQuad->IndexBuffer, DXGI_FORMAT_R32_UINT, 0); + + if (frameJob->DiffuseTexture != nullptr) { + m_DeviceContext->PSSetShaderResources(0, 1, &frameJob->DiffuseTexture->m_ShaderResourceView); + } + //m_DeviceContext->Draw(modelJob->EndIndex - modelJob->StartIndex + 1, modelJob->StartIndex); + m_DeviceContext->DrawIndexed(m_UnitQuad->m_Indices.size(), 0, 0); + + continue; + } + } + //constantBufferStruct.ModelMatrix = GLMtoDX(glm::mat4(1.f)); + //constantBufferStruct.ViewMatrix = GLMtoDX(m_Camera->ViewMatrix()); + //constantBufferStruct.ProjectionMatrix = proj; + //constantBufferStruct.InverseTransposeViewModel = GLMtoDX(glm::mat4(1.f)); + + m_SwapChain->Present(0, 0); + //glfwSwapBuffers(m_Window); +} + +//void dd::Renderer::Resize(int width, int height) +//{ +// m_DeviceContext->OMSetRenderTargets(0, 0, 0); +// m_BackBuffer->Release(); +// +// HRESULT hr; // TODO: Error handling +// // Preserve the existing buffer count and format. +// hr = m_SwapChain->ResizeBuffers(0, width, height, DXGI_FORMAT_UNKNOWN, 0); +// +// ID3D11Texture2D* pBuffer; +// hr = m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pBuffer); +// hr = m_Device->CreateRenderTargetView(pBuffer, NULL, &m_BackBuffer); +// pBuffer->Release(); +// m_DeviceContext->OMSetRenderTargets(1, &BackBuffer, NULL); +// +// // Set the viewport +// D3D11_VIEWPORT viewport = { 0 }; +// viewport.TopLeftX = 0; +// viewport.TopLeftY = 0; +// viewport.Width = width; +// viewport.Height = height; +// m_DeviceContext->RSSetViewports(1, &viewport); +//} + +dd::Renderer::~Renderer() +{ + m_SwapChain->Release(); + m_BackBuffer->Release(); + m_Device->Release(); + m_DeviceContext->Release(); +} + +DirectX::SimpleMath::Matrix dd::Renderer::GLMtoDXModelView(glm::mat4 gm) +{ + gm = glm::transpose(gm); + DirectX::SimpleMath::Matrix dm( + gm[0][0], gm[0][1], -gm[0][2], gm[0][3], + gm[1][0], gm[1][1], -gm[1][2], gm[1][3], + -gm[2][0], -gm[2][1], gm[2][2], gm[2][3], + gm[3][0], gm[3][1], -gm[3][2], gm[3][3] + ); + return dm; +} + +DirectX::SimpleMath::Matrix dd::Renderer::GLMtoDXProjection(glm::mat4 gm) +{ + gm = glm::transpose(gm); + DirectX::SimpleMath::Matrix dm( + gm[0][0], gm[0][1], gm[0][2], gm[0][3], + gm[1][0], gm[1][1], gm[1][2], gm[1][3], + -gm[2][0], -gm[2][1], -gm[2][2], -gm[2][3], + gm[3][0], gm[3][1], gm[3][2], gm[3][3] + ); + return dm; +} + +void dd::Renderer::setDefaultRasterState() +{ + if (m_RasterState != nullptr) { + m_RasterState->Release(); + m_RasterState = nullptr; + } + + D3D11_RASTERIZER_DESC rd; + memset(&rd, 0, sizeof(D3D11_RASTERIZER_DESC)); + rd.AntialiasedLineEnable = false; + rd.CullMode = D3D11_CULL_BACK; + rd.DepthBias = 0; + rd.DepthBiasClamp = 0.0f; + rd.DepthClipEnable = true; + rd.FillMode = D3D11_FILL_SOLID; + rd.FrontCounterClockwise = true; + rd.MultisampleEnable = false; + rd.ScissorEnable = false; + rd.SlopeScaledDepthBias = 0.0f; + m_Device->CreateRasterizerState(&rd, &m_RasterState); + m_DeviceContext->RSSetState(m_RasterState); +} + +void dd::Renderer::setGUIRasterState() +{ + if (m_RasterState != nullptr) { + m_RasterState->Release(); + m_RasterState = nullptr; + } + + D3D11_RASTERIZER_DESC rd; + memset(&rd, 0, sizeof(D3D11_RASTERIZER_DESC)); + rd.AntialiasedLineEnable = false; + rd.CullMode = D3D11_CULL_BACK; + rd.DepthBias = 0; + rd.DepthBiasClamp = 0.0f; + rd.DepthClipEnable = false; + rd.FillMode = D3D11_FILL_SOLID; + rd.FrontCounterClockwise = true; + rd.MultisampleEnable = false; + rd.ScissorEnable = false; + rd.SlopeScaledDepthBias = 0.0f; + m_Device->CreateRasterizerState(&rd, &m_RasterState); + m_DeviceContext->RSSetState(m_RasterState); +} diff --git a/src/game/Rendering/DirectX/ShaderProgram.cpp b/src/game/Rendering/DirectX/ShaderProgram.cpp new file mode 100644 index 0000000..0b7c4db --- /dev/null +++ b/src/game/Rendering/DirectX/ShaderProgram.cpp @@ -0,0 +1,78 @@ +#include "PrecompiledHeader.h" +#include "Rendering/ShaderProgram.h" + +dd::ShaderProgram::ShaderProgram() +{ + m_VertexShaderBlob = nullptr; + m_VertexShader = nullptr; + m_PixelShaderBlob = nullptr; + m_PixelShader = nullptr; + m_InputLayout = nullptr; +} + +dd::ShaderProgram::~ShaderProgram() +{ + if (m_VertexShader != nullptr) + m_VertexShader->Release(); + if (m_VertexShaderBlob != nullptr) + m_VertexShaderBlob->Release(); + if (m_PixelShader != nullptr) + m_PixelShader->Release(); + if (m_PixelShaderBlob != nullptr) + m_PixelShaderBlob->Release(); + if (m_InputLayout != nullptr) + m_InputLayout->Release(); +} + +void dd::ShaderProgram::CompileVertexShader(std::wstring filename) +{ + //D3DX11CompileFromFile(filename.c_str(), 0, 0, "main", "vs_5_0", 0, 0, 0, &m_VertexShaderBlob, 0, 0); + ID3DBlob* blob = nullptr; + HRESULT result = D3DCompileFromFile(filename.c_str(), nullptr, nullptr, "main", "vs_5_0", 0, 0, &m_VertexShaderBlob, &blob); + if (result != S_OK) { + std::wstring blobString((wchar_t*)blob->GetBufferPointer(), blob->GetBufferSize()); + LOG_ERROR("Failed to compile vertex shader!\n\n%s", blobString.c_str()); + return; + } + StaticSystem::Get()->m_Device->CreateVertexShader(m_VertexShaderBlob->GetBufferPointer(), m_VertexShaderBlob->GetBufferSize(), NULL, &m_VertexShader); +} + +void dd::ShaderProgram::CompilePixelShader(std::wstring filename) +{ + //D3DX11CompileFromFile(filename.c_str(), 0, 0, "main", "ps_5_0", 0, 0, 0, &m_PixelShaderBlob, 0, 0); + ID3DBlob* blob = nullptr; + HRESULT result = D3DCompileFromFile(filename.c_str(), nullptr, nullptr, "main", "ps_5_0", 0, 0, &m_PixelShaderBlob, &blob); + if (result != S_OK) { + std::wstring blobString((wchar_t*)blob->GetBufferPointer(), blob->GetBufferSize()); + LOG_ERROR("Failed to compile pixel shader!\n\n%s", blobString.c_str()); + return; + } + StaticSystem::Get()->m_Device->CreatePixelShader(m_PixelShaderBlob->GetBufferPointer(), m_PixelShaderBlob->GetBufferSize(), NULL, &m_PixelShader); +} + +void dd::ShaderProgram::Bind() +{ + if (m_VertexShader != nullptr) + StaticSystem::Get()->m_DeviceContext->VSSetShader(m_VertexShader, 0, 0); + if (m_PixelShader != nullptr) + StaticSystem::Get()->m_DeviceContext->PSSetShader(m_PixelShader, 0, 0); + if (m_InputLayout != nullptr) + StaticSystem::Get()->m_DeviceContext->IASetInputLayout(m_InputLayout); +} + +void dd::ShaderProgram::Unbind() +{ + if (m_VertexShader != nullptr) { + StaticSystem::Get()->m_DeviceContext->VSSetShader(NULL, 0, 0); + } + if (m_PixelShader != nullptr) { + StaticSystem::Get()->m_DeviceContext->PSSetShader(NULL, 0, 0); + } + //if (m_InputLayout != nullptr) + // dd::RENDERER->DeviceContext->IASetInputLayout(NULL); +} + +HRESULT dd::ShaderProgram::CreateInputLayout(D3D11_INPUT_ELEMENT_DESC* ied, UINT numElements) +{ + return StaticSystem::Get()->m_Device->CreateInputLayout(ied, numElements, m_VertexShaderBlob->GetBufferPointer(), m_VertexShaderBlob->GetBufferSize(), &m_InputLayout); +} diff --git a/src/game/Rendering/DirectX/Shaders/Flat.pixel.hlsl b/src/game/Rendering/DirectX/Shaders/Flat.pixel.hlsl new file mode 100644 index 0000000..474c7bc --- /dev/null +++ b/src/game/Rendering/DirectX/Shaders/Flat.pixel.hlsl @@ -0,0 +1,38 @@ +cbuffer ConstantBuffer +{ + float4x4 MVP; + float4x4 ModelMatrix; + float4x4 ViewMatrix; + float4x4 ProjectionMatrix; + float4x4 InverseTransposeViewModel; + float4 Color; + float4 LightPositions[10]; + float4 LightColors[10]; + float LightRadii[10]; + uint NumLights; +} + +Texture2D Texture; +SamplerState samplerState; + +struct VOut +{ + float4 PixelPosition : SV_POSITION; + float4 Position : POSITION; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 BiTangent : TANGENT1; + float2 TextureCoord : TEXCOORD; + float4 DiffuseColor : COLOR0; + float4 SpecularColor : COLOR1; + float4 BoneIndices1 : BLENDINDICES0; + float4 BoneIndices2 : BLENDINDICES1; + float4 BoneWeights1 : BLENDWEIGHT0; + float4 BoneWeights2 : BLENDWEIGHT1; +}; + +float4 main(VOut input) : SV_TARGET +{ + float4 diffuseTexture = Texture.Sample(samplerState, input.TextureCoord) * Color; + return diffuseTexture; +} diff --git a/src/game/Rendering/DirectX/Shaders/pixel.hlsl b/src/game/Rendering/DirectX/Shaders/pixel.hlsl new file mode 100644 index 0000000..6253993 --- /dev/null +++ b/src/game/Rendering/DirectX/Shaders/pixel.hlsl @@ -0,0 +1,76 @@ +cbuffer ConstantBuffer +{ + float4x4 MVP; + float4x4 ModelMatrix; + float4x4 ViewMatrix; + float4x4 ProjectionMatrix; + float4x4 InverseTransposeViewModel; + float4 Color; + float4 LightPositions[10]; + float4 LightColors[10]; + float LightRadii[10]; + uint NumLights; +} + +Texture2D Texture; +SamplerState samplerState; + +struct VOut +{ + float4 PixelPosition : SV_POSITION; + float4 Position : POSITION; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 BiTangent : TANGENT1; + float2 TextureCoord : TEXCOORD; + float4 DiffuseColor : COLOR0; + float4 SpecularColor : COLOR1; + float4 BoneIndices1 : BLENDINDICES0; + float4 BoneIndices2 : BLENDINDICES1; + float4 BoneWeights1 : BLENDWEIGHT0; + float4 BoneWeights2 : BLENDWEIGHT1; +}; + +float4 phong(float3 lightPos, float lightRadius, float3 lightColor, float3 position, float3 normal, float3 specular, float specularExponent) +{ + float3 LightSpecular = float3(1.0f, 1.0f, 1.0f) * 0.5f; + + // Diffuse + lightPos = mul(ViewMatrix, float4(lightPos, 1.0f)).xyz; + float3 distanceToLight = lightPos - position; + float3 directionToLight = normalize(distanceToLight); + float dotProd = dot(directionToLight, normal); + float3 Idiffuse = lightColor * dotProd; + + // Specular + float3 surfaceToViewer = normalize(-position); + float3 halfWay = normalize(surfaceToViewer + directionToLight); + float dotSpecular = max(dot(halfWay, normal), 0.0f); + float specularFactor = pow(dotSpecular, specularExponent); + float3 Ispecular = specular * LightSpecular * specularFactor; + + // Attenuation + float dist = distance(lightPos, position); + float attenuation = pow(max(0.0f, 1.0f - (dist / lightRadius)), 2.0f); + + return float4((Idiffuse + Ispecular) * attenuation, 1.0f); +} + +float4 main(VOut input) : SV_TARGET +{ + //float4 ambientLight = float4(1.0f, 1.0f, 1.0f, 1.0f) * 0.1f; + //float4 lightColor = float4(1.0f, 1.0f, 1.0f, 1.0f); + //float3 lightToPixel = normalize(LightPosition - mul(input.Position, transpose(ModelMatrix))); + //float diffuseBrightness = saturate(dot(lightToPixel, normalize(mul(input.Normal, transpose(ModelMatrix))))); + + float4 diffuseTexture = Texture.Sample(samplerState, input.TextureCoord) * Color; + float4 lights = float4(1.f, 1.f, 1.f, 1.f); + + for (uint i = 0; i < NumLights; i++) { + float4 light = phong(LightPositions[i], LightRadii[i], LightColors[i].rgb, input.Position, normalize(input.Normal.xyz), float3(1.0f, 1.0f, 1.0f), 1.0f); + lights = lights + light; + } + + //return float4(1.f, 0.f, 0.f, 1.f); + return float4(diffuseTexture.rgb * 0.8f, diffuseTexture.a) * lights; +} \ No newline at end of file diff --git a/src/game/Rendering/DirectX/Shaders/vertex.hlsl b/src/game/Rendering/DirectX/Shaders/vertex.hlsl new file mode 100644 index 0000000..7ac4af3 --- /dev/null +++ b/src/game/Rendering/DirectX/Shaders/vertex.hlsl @@ -0,0 +1,67 @@ +cbuffer ConstantBuffer +{ + float4x4 MVP; + float4x4 ModelMatrix; + float4x4 ViewMatrix; + float4x4 ProjectionMatrix; + float4x4 InverseTransposeViewModel; + float4 Color; + float4 LightPositions[2]; +} + +struct VIn +{ + float4 Position : POSITION; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 BiTangent : TANGENT1; + float2 TextureCoord : TEXCOORD; + float4 DiffuseColor : COLOR0; + float4 SpecularColor : COLOR1; + float4 BoneIndices1 : BLENDINDICES0; + float4 BoneIndices2 : BLENDINDICES1; + float4 BoneWeights1 : BLENDWEIGHT0; + float4 BoneWeights2 : BLENDWEIGHT1; +}; + +struct VOut +{ + float4 PixelPosition : SV_POSITION; + float4 Position : POSITION; + float4 Normal : NORMAL; + float4 Tangent : TANGENT0; + float4 BiTangent : TANGENT1; + float2 TextureCoord : TEXCOORD; + float4 DiffuseColor : COLOR0; + float4 SpecularColor : COLOR1; + float4 BoneIndices1 : BLENDINDICES0; + float4 BoneIndices2 : BLENDINDICES1; + float4 BoneWeights1 : BLENDWEIGHT0; + float4 BoneWeights2 : BLENDWEIGHT1; +}; + +VOut main(VIn input) +{ + /*float4 ambientLight = float4(1.0f, 1.0f, 1.0f, 1.0f) * 0.1f; + float4 lightPos = float4(0.0f, 0.0f, 8.0f, 0.0f); + float4 lightColor = float4(1.0f, 1.0f, 1.0f, 1.0f); + float diffuseBrightness = saturate(dot(normal, lightPos));*/ + + VOut output; + + output.PixelPosition = mul(MVP, input.Position); + //TODO: Make sure that boneTransform works here. + output.Position = mul(ModelMatrix * ViewMatrix, float4(input.Position.xyz, 1.0f)); + output.Normal = mul(InverseTransposeViewModel, float4(input.Normal.xyz, 0.0f)); + output.Tangent = input.Tangent; + output.BiTangent = input.BiTangent; + output.TextureCoord = input.TextureCoord; + output.DiffuseColor = input.DiffuseColor; + output.SpecularColor = input.SpecularColor; + output.BoneIndices1 = input.BoneIndices1; + output.BoneIndices2 = input.BoneIndices2; + output.BoneWeights1 = input.BoneWeights1; + output.BoneWeights2 = input.BoneWeights2; + + return output; +} \ No newline at end of file diff --git a/src/game/Rendering/DirectX/Texture.cpp b/src/game/Rendering/DirectX/Texture.cpp new file mode 100644 index 0000000..8749d41 --- /dev/null +++ b/src/game/Rendering/DirectX/Texture.cpp @@ -0,0 +1,68 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#include "PrecompiledHeader.h" +#include "Rendering/Texture.h" + +dd::Texture::Texture(std::string path) +{ + std::unique_ptr image = std::make_unique(path); + + if (image->Width == 0 && image->Height == 0 || image->Format == Image::ImageFormat::Unknown) { + image = std::make_unique("Textures/Core/ErrorTexture.png"); + if (image->Width == 0 && image->Height == 0 || image->Format == Image::ImageFormat::Unknown) { + LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed."); + return; + } + } + + this->Width = image->Width; + this->Height = image->Height; + + D3D11_TEXTURE2D_DESC desc; + desc.Width = this->Width; + desc.Height = this->Height; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; + desc.MiscFlags = 0; + + D3D11_SUBRESOURCE_DATA data; + data.pSysMem = image->Data; + data.SysMemPitch = image->Width * 4; + data.SysMemSlicePitch = image->Width * image->Height * 4; + + HRESULT result; + result = StaticSystem::Get()->m_Device->CreateTexture2D(&desc, &data, &m_Texture); + if (result != S_OK) { + LOG_ERROR("DirectX failed to create texture \"%s\"", path.c_str()); + } + result = StaticSystem::Get()->m_Device->CreateShaderResourceView(m_Texture, nullptr, &m_ShaderResourceView); + if (result != S_OK) { + LOG_ERROR("DirectX failed to create shader resource view for texture \"%s\"", path.c_str()); + } +} + +dd::Texture::~Texture() +{ +} \ No newline at end of file diff --git a/src/game/Core/OBJ.cpp b/src/game/Rendering/OBJ.cpp similarity index 99% rename from src/game/Core/OBJ.cpp rename to src/game/Rendering/OBJ.cpp index 0dd75a5..795b202 100644 --- a/src/game/Core/OBJ.cpp +++ b/src/game/Rendering/OBJ.cpp @@ -17,7 +17,7 @@ */ #include "PrecompiledHeader.h" -#include "Core/OBJ.h" +#include "Rendering/OBJ.h" bool dd::OBJ::LoadFromFile(std::string filename) { diff --git a/src/game/Rendering/OpenGL/Model.cpp b/src/game/Rendering/OpenGL/Model.cpp new file mode 100644 index 0000000..6559706 --- /dev/null +++ b/src/game/Rendering/OpenGL/Model.cpp @@ -0,0 +1,81 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#include "PrecompiledHeader.h" +#include "Rendering/Model.h" + +dd::Model::Model(std::string fileName) + : RawModel(fileName) +{ + // Generate GL buffers + GLuint buffer; + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, m_Vertices.size() * sizeof(Vertex), &m_Vertices[0], GL_STATIC_DRAW); + + glGenBuffers(1, &ElementBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ElementBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_Indices.size() * sizeof(unsigned int), &m_Indices[0], GL_STATIC_DRAW); + + glGenVertexArrays(1, &VAO); + glBindVertexArray(VAO); + GLERROR("GLEW: BufferFail4"); + + glBindBuffer(GL_ARRAY_BUFFER, buffer); + std::vector structSizes = { 3, 3, 3, 3, 2, 4, 4, 4, 4, 4, 4 }; + int stride = 0; + for (int size : structSizes) + stride += size; + stride *= sizeof(GLfloat); + int offset = 0; + { + int element = 0; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * offset)); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; + } + GLERROR("GLEW: BufferFail5"); + + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glEnableVertexAttribArray(2); + glEnableVertexAttribArray(3); + glEnableVertexAttribArray(4); + glEnableVertexAttribArray(5); + glEnableVertexAttribArray(6); + glEnableVertexAttribArray(7); + glEnableVertexAttribArray(8); + glEnableVertexAttribArray(9); + glEnableVertexAttribArray(10); + GLERROR("GLEW: BufferFail5"); + + //CreateBuffers(); +} + +dd::Model::~Model() +{ + +} \ No newline at end of file diff --git a/src/game/Core/Renderer.cpp b/src/game/Rendering/OpenGL/Renderer.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/game/Core/Renderer.cpp rename to src/game/Rendering/OpenGL/Renderer.cpp index 8ea20c8..d0c0877 --- a/src/game/Core/Renderer.cpp +++ b/src/game/Rendering/OpenGL/Renderer.cpp @@ -17,7 +17,7 @@ */ #include "PrecompiledHeader.h" -#include "Core/Renderer.h" +#include "Rendering/Renderer.h" void dd::Renderer::Initialize() { @@ -45,7 +45,7 @@ void dd::Renderer::Initialize() glGetIntegerv(GL_MINOR_VERSION, &m_GLVersion[1]); m_GLVendor = (GLchar*)glGetString(GL_VENDOR); std::stringstream ss; - ss << m_GLVendor << " OpenGL " << m_GLVersion[0] << "." << m_GLVersion[1]; + ss << "Squidout! (" << m_GLVendor << " OpenGL " << m_GLVersion[0] << "." << m_GLVersion[1] << ")"; #ifdef DEBUG ss << " DEBUG"; #endif @@ -80,7 +80,7 @@ void dd::Renderer::LoadShaders() */ // Pass #1: Fill G-buffers - m_SpDeferred1 = ResourceManager::Load("Shaders/Deferred/1/"); + m_SpDeferred1 = ResourceManager::Load("Shaders/OpenGL/Deferred/1/"); m_SpDeferred1->BindFragDataLocation(0, "GDiffuse"); m_SpDeferred1->BindFragDataLocation(1, "GPosition"); m_SpDeferred1->BindFragDataLocation(2, "GNormal"); @@ -88,30 +88,30 @@ void dd::Renderer::LoadShaders() m_SpDeferred1->Link(); // Pass #2: Lighting - m_SpDeferred2 = ResourceManager::Load("Shaders/Deferred/2/"); + m_SpDeferred2 = ResourceManager::Load("Shaders/OpenGL/Deferred/2/"); //glBindFragDataLocation(m_SPDeferred2, 0, "FragmentLighting"); m_SpDeferred2->Link(); //Water Pass - m_SpWater = ResourceManager::Load("Shaders/Deferred/water/"); + m_SpWater = ResourceManager::Load("Shaders/OpenGL/Deferred/water/"); m_SpWater->Link(); - m_SpWater2 = ResourceManager::Load("Shaders/Deferred/water2/"); + m_SpWater2 = ResourceManager::Load("Shaders/OpenGL/Deferred/water2/"); m_SpWater2->Link(); // Pass #3: Combining into final image - m_SpDeferred3 = ResourceManager::Load("Shaders/Deferred/3/"); + m_SpDeferred3 = ResourceManager::Load("Shaders/OpenGL/Deferred/3/"); m_SpDeferred3->Link(); /* Forward rendering */ - m_SpForward = ResourceManager::Load("Shaders/Forward/"); + m_SpForward = ResourceManager::Load("Shaders/OpenGL/Forward/"); m_SpForward->Link(); /* Screen draw */ - m_SpScreen = ResourceManager::Load("Shaders/Screen/"); + m_SpScreen = ResourceManager::Load("Shaders/OpenGL/Screen/"); m_SpScreen->Link(); } @@ -121,6 +121,7 @@ void dd::Renderer::CreateBuffers() m_ScreenQuad = CreateQuad(); m_UnitQuad = ResourceManager::Load("Models/Core/UnitQuad.obj"); m_UnitSphere = ResourceManager::Load("Models/Core/UnitSphere.obj"); + m_ErrorTexture = ResourceManager::Load("Textures/Core/ErrorTexture.png"); m_StandardNormal = ResourceManager::Load("Textures/Core/NeutralNormalMap.png"); m_StandardSpecular = ResourceManager::Load("Textures/Core/NeutralSpecularMap.png"); //m_WhiteSphereTexture = ResourceManager::Load("Textures/Test/Water.png"); @@ -414,22 +415,28 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program) glUniform1f(glGetUniformLocation(shaderProgramHandle, "LightRadius"), 40.0f); glUniform1f(glGetUniformLocation(shaderProgramHandle, "MaterialShininess"), modelJob->Shininess); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture); - if (modelJob->NormalTexture != 0) { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture); + if (modelJob->DiffuseTexture != nullptr) { + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture); } else { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, *m_StandardNormal); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture); } - if (modelJob->SpecularTexture != 0) { + if (modelJob->NormalTexture != nullptr) { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture->m_Texture); + } else { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, m_StandardNormal->m_Texture); + } + + if (modelJob->SpecularTexture != nullptr) { glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture); + glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture->m_Texture); } else { glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, *m_StandardSpecular); + glBindTexture(GL_TEXTURE_2D, m_StandardSpecular->m_Texture); } if (modelJob->Skeleton != nullptr) { @@ -446,8 +453,8 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program) } } - glBindVertexArray(modelJob->VAO); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->ElementBuffer); + glBindVertexArray(modelJob->Model->VAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex); continue; @@ -464,11 +471,11 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program) glUniform4fv(glGetUniformLocation(shaderProgramHandle, "Color"), 1, glm::value_ptr(spriteJob->Color)); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture); + glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture); glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, spriteJob->NormalTexture); + glBindTexture(GL_TEXTURE_2D, spriteJob->NormalTexture->m_Texture); glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, spriteJob->SpecularTexture); + glBindTexture(GL_TEXTURE_2D, spriteJob->SpecularTexture->m_Texture); glBindVertexArray(m_UnitQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_UnitQuad->ElementBuffer); @@ -536,7 +543,7 @@ void dd::Renderer::DrawWater(RenderQueue &rq) glm::value_ptr(viewMatrix)); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, *m_WhiteSphereTexture); + glBindTexture(GL_TEXTURE_2D, m_WhiteSphereTexture->m_Texture); glBindVertexArray(m_UnitQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_UnitQuad->ElementBuffer); @@ -691,7 +698,7 @@ void dd::Renderer::DrawGUI(dd::RenderQueue& rq) glUniform4fv(glGetUniformLocation(*m_SpScreen, "Color"), 1, glm::value_ptr(frameJob->Color)); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, frameJob->DiffuseTexture); + glBindTexture(GL_TEXTURE_2D, frameJob->DiffuseTexture->m_Texture); //glActiveTexture(GL_TEXTURE1); //glBindTexture(GL_TEXTURE_2D, frameJob->NormalTexture); //glActiveTexture(GL_TEXTURE2); diff --git a/src/game/Core/ShaderProgram.cpp b/src/game/Rendering/OpenGL/ShaderProgram.cpp similarity index 99% rename from src/game/Core/ShaderProgram.cpp rename to src/game/Rendering/OpenGL/ShaderProgram.cpp index 853c367..3ae5627 100644 --- a/src/game/Core/ShaderProgram.cpp +++ b/src/game/Rendering/OpenGL/ShaderProgram.cpp @@ -17,7 +17,7 @@ */ #include "PrecompiledHeader.h" -#include "Core/ShaderProgram.h" +#include "Rendering/ShaderProgram.h" void dd::Shader::Compile() { diff --git a/src/game/Core/Shaders/Deferred/1/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/1/Fragment.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Deferred/1/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/1/Fragment.glsl diff --git a/src/game/Core/Shaders/Deferred/1/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/1/Vertex.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Deferred/1/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/1/Vertex.glsl diff --git a/src/game/Core/Shaders/Deferred/2/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/2/Fragment.glsl similarity index 100% rename from src/game/Core/Shaders/Deferred/2/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/2/Fragment.glsl diff --git a/src/game/Core/Shaders/Deferred/2/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/2/Vertex.glsl similarity index 100% rename from src/game/Core/Shaders/Deferred/2/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/2/Vertex.glsl diff --git a/src/game/Core/Shaders/Deferred/3/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/3/Fragment.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Deferred/3/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/3/Fragment.glsl diff --git a/src/game/Core/Shaders/Deferred/3/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/3/Vertex.glsl similarity index 100% rename from src/game/Core/Shaders/Deferred/3/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/3/Vertex.glsl diff --git a/src/game/Core/Shaders/Deferred/water/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/water/Fragment.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Deferred/water/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/water/Fragment.glsl diff --git a/src/game/Core/Shaders/Deferred/water/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/water/Vertex.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Deferred/water/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/water/Vertex.glsl diff --git a/src/game/Core/Shaders/Deferred/water2/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/water2/Fragment.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Deferred/water2/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/water2/Fragment.glsl diff --git a/src/game/Core/Shaders/Deferred/water2/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/Deferred/water2/Vertex.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Deferred/water2/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/Deferred/water2/Vertex.glsl diff --git a/src/game/Core/Shaders/Forward/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/Forward/Fragment.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Forward/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/Forward/Fragment.glsl diff --git a/src/game/Core/Shaders/Forward/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/Forward/Vertex.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/Forward/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/Forward/Vertex.glsl diff --git a/src/game/Core/Shaders/PureForward/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/PureForward/Fragment.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/PureForward/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/PureForward/Fragment.glsl diff --git a/src/game/Core/Shaders/PureForward/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/PureForward/Vertex.glsl old mode 100755 new mode 100644 similarity index 100% rename from src/game/Core/Shaders/PureForward/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/PureForward/Vertex.glsl diff --git a/src/game/Core/Shaders/Screen/Fragment.glsl b/src/game/Rendering/OpenGL/Shaders/Screen/Fragment.glsl similarity index 100% rename from src/game/Core/Shaders/Screen/Fragment.glsl rename to src/game/Rendering/OpenGL/Shaders/Screen/Fragment.glsl diff --git a/src/game/Core/Shaders/Screen/Vertex.glsl b/src/game/Rendering/OpenGL/Shaders/Screen/Vertex.glsl similarity index 100% rename from src/game/Core/Shaders/Screen/Vertex.glsl rename to src/game/Rendering/OpenGL/Shaders/Screen/Vertex.glsl diff --git a/src/game/Core/Texture.cpp b/src/game/Rendering/OpenGL/Texture.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/game/Core/Texture.cpp rename to src/game/Rendering/OpenGL/Texture.cpp index 2dd9f49..ee33ed1 --- a/src/game/Core/Texture.cpp +++ b/src/game/Rendering/OpenGL/Texture.cpp @@ -17,7 +17,7 @@ */ #include "PrecompiledHeader.h" -#include "Core/Texture.h" +#include "Rendering/Texture.h" dd::Texture::Texture(std::string path) { diff --git a/src/game/Core/PNG.cpp b/src/game/Rendering/PNG.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/game/Core/PNG.cpp rename to src/game/Rendering/PNG.cpp index a35be44..2779ae0 --- a/src/game/Core/PNG.cpp +++ b/src/game/Rendering/PNG.cpp @@ -17,7 +17,7 @@ */ #include "PrecompiledHeader.h" -#include "Core/PNG.h" +#include "Rendering/PNG.h" dd::PNG::PNG(std::string path) { @@ -75,8 +75,6 @@ dd::PNG::PNG(std::string path) } switch (color_type) { case PNG_COLOR_TYPE_RGB: - Format = Image::ImageFormat::RGB; - break; case PNG_COLOR_TYPE_RGBA: Format = Image::ImageFormat::RGBA; break; @@ -84,8 +82,15 @@ dd::PNG::PNG(std::string path) LOG_ERROR("libpng: Unsupported color format \"%i\" of image \"%s\"", color_type, path.c_str()); return; } - unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr); + // Convert RGB to RGBA, since DirectX rather treat them all the same way + if (color_type == PNG_COLOR_TYPE_RGB) { + LOG_DEBUG("Converting RGB to RGBA for \"%s\"", path.c_str()); + png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER); + png_read_update_info(png_ptr, info_ptr); + } + + unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr); this->Data = new unsigned char[height * row_bytes]; png_bytep* row_pointers = new png_bytep[height]; diff --git a/src/game/Core/Model.cpp b/src/game/Rendering/RawModel.cpp old mode 100755 new mode 100644 similarity index 79% rename from src/game/Core/Model.cpp rename to src/game/Rendering/RawModel.cpp index 84b4261..46fb5df --- a/src/game/Core/Model.cpp +++ b/src/game/Rendering/RawModel.cpp @@ -17,9 +17,9 @@ */ #include "PrecompiledHeader.h" -#include "Core/Model.h" +#include "Rendering/RawModel.h" -dd::Model::Model(std::string fileName) +dd::RawModel::RawModel(std::string fileName) { Assimp::Importer importer; const aiScene* scene = importer.ReadFile(fileName, aiProcess_CalcTangentSpace | aiProcess_Triangulate); @@ -29,7 +29,7 @@ dd::Model::Model(std::string fileName) LOG_ERROR("Assimp error: %s", importer.GetErrorString()); return; } - + auto m = scene->mRootNode->mTransformation; m_Matrix = glm::mat4( m.a1, m.a2, m.a3, m.a4, @@ -303,68 +303,16 @@ dd::Model::Model(std::string fileName) m_Skeleton->Animations[animationName] = skelAnim; } - - // Generate GL buffers - GLuint buffer; - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, m_Vertices.size() * sizeof(Vertex), &m_Vertices[0], GL_STATIC_DRAW); - - glGenBuffers(1, &ElementBuffer); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ElementBuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_Indices.size() * sizeof(unsigned int), &m_Indices[0], GL_STATIC_DRAW); - - glGenVertexArrays(1, &VAO); - glBindVertexArray(VAO); - GLERROR("GLEW: BufferFail4"); - - glBindBuffer(GL_ARRAY_BUFFER, buffer); - std::vector structSizes = { 3, 3, 3, 3, 2, 4, 4, 4, 4, 4, 4 }; - int stride = 0; - for (int size : structSizes) - stride += size; - stride *= sizeof(GLfloat); - int offset = 0; - { - int element = 0; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * offset)); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - glVertexAttribPointer(element, structSizes[element], GL_FLOAT, GL_FALSE, stride, (GLvoid*)(sizeof(GLfloat) * (offset += structSizes[element - 1]))); element++; - } - GLERROR("GLEW: BufferFail5"); - - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); - glEnableVertexAttribArray(2); - glEnableVertexAttribArray(3); - glEnableVertexAttribArray(4); - glEnableVertexAttribArray(5); - glEnableVertexAttribArray(6); - glEnableVertexAttribArray(7); - glEnableVertexAttribArray(8); - glEnableVertexAttribArray(9); - glEnableVertexAttribArray(10); - GLERROR("GLEW: BufferFail5"); - - //CreateBuffers(); } -dd::Model::~Model() +dd::RawModel::~RawModel() { if (m_Skeleton) { delete m_Skeleton; } } -void dd::Model::CreateSkeleton(std::vector> &boneInfo, std::map &boneNameMapping, aiNode* node, int parentID) +void dd::RawModel::CreateSkeleton(std::vector> &boneInfo, std::map &boneNameMapping, aiNode* node, int parentID) { std::string nodeName = node->mName.C_Str(); diff --git a/src/game/Core/Skeleton.cpp b/src/game/Rendering/Skeleton.cpp similarity index 99% rename from src/game/Core/Skeleton.cpp rename to src/game/Rendering/Skeleton.cpp index 5b2895c..69e9651 100644 --- a/src/game/Core/Skeleton.cpp +++ b/src/game/Rendering/Skeleton.cpp @@ -17,7 +17,7 @@ */ #include "PrecompiledHeader.h" -#include "Core/Skeleton.h" +#include "Rendering/Skeleton.h" int dd::Skeleton::CreateBone(int ID, int parentID, std::string name, glm::mat4 offsetMatrix) { diff --git a/tools/deploy.bat b/tools/deploy.bat index 249b16d..2715ad1 100644 --- a/tools/deploy.bat +++ b/tools/deploy.bat @@ -4,13 +4,19 @@ SET DeployLocation=bin\ ECHO Deploying resources to %DeployLocation% :: Asset folders +RMDIR "%DeployLocation%\Models" +RMDIR "%DeployLocation%\Textures" +RMDIR "%DeployLocation%\Sounds" MKLINK "%DeployLocation%\Models\" "assets\Models" /J MKLINK "%DeployLocation%\Textures\" "assets\Textures\" /J MKLINK "%DeployLocation%\Sounds\" "assets\Sounds\" /J :: Configuration files MKLINK "%DeployLocation%\DefaultConfig.ini" "assets\DefaultConfig.ini" /H :: Shaders -MKLINK "%DeployLocation%\Shaders\" "src\game\Core\Shaders\" /J +RMDIR /S /Q "%DeployLocation%\Shaders" +MKDIR "%DeployLocation%\Shaders" +MKLINK "%DeployLocation%\Shaders\OpenGL\" "src\game\Rendering\OpenGL\Shaders\" /J +MKLINK "%DeployLocation%\Shaders\DirectX\" "src\game\Rendering\DirectX\Shaders\" /J :: Platform specific binaries IF "%~1"=="" GOTO :EOF ECHO Deploying %1 binaries to %DeployLocation%