├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── engine ├── CMakeLists.txt ├── Consts.h ├── Engine.cpp ├── Engine.h ├── ScalarConsts.h ├── World.cpp ├── World.h ├── animation │ ├── Animation.cpp │ ├── Animation.h │ ├── Animations.h │ ├── AttractToPoint.h │ ├── Decompose.h │ ├── Function.h │ ├── Interpolation.cpp │ ├── Interpolation.h │ ├── Rotate.h │ ├── RotateLeft.h │ ├── RotateLeftUpLookAt.h │ ├── RotateRelativePoint.h │ ├── Scale.h │ ├── ShowCreation.h │ ├── ShowUncreation.h │ ├── Timeline.cpp │ ├── Timeline.h │ ├── Translate.h │ ├── TranslateToPoint.h │ └── Wait.h ├── components │ ├── Component.h │ ├── TransformMatrix.cpp │ ├── TransformMatrix.h │ ├── geometry │ │ ├── Bounds.h │ │ ├── Line.h │ │ ├── LineMesh.cpp │ │ ├── LineMesh.h │ │ ├── Plane.cpp │ │ ├── Plane.h │ │ ├── Triangle.cpp │ │ ├── Triangle.h │ │ ├── TriangleMesh.cpp │ │ └── TriangleMesh.h │ ├── lighting │ │ ├── DirectionalLight.h │ │ ├── LightSource.h │ │ ├── PointLight.h │ │ └── SpotLight.h │ ├── physics │ │ ├── HitBox.cpp │ │ ├── HitBox.h │ │ ├── RigidObject.cpp │ │ ├── RigidObject.h │ │ └── Simplex.h │ └── props │ │ ├── Color.cpp │ │ ├── Color.h │ │ ├── Material.cpp │ │ ├── Material.h │ │ ├── Texture.cpp │ │ └── Texture.h ├── io │ ├── Image.cpp │ ├── Image.h │ ├── Keyboard.cpp │ ├── Keyboard.h │ ├── Mouse.cpp │ ├── Mouse.h │ ├── Screen.cpp │ ├── Screen.h │ └── microui │ │ ├── microui.c │ │ └── microui.h ├── linalg │ ├── Matrix3x3.h │ ├── Matrix3x3.inl │ ├── Matrix4x4.h │ ├── Matrix4x4.inl │ ├── Vec2D.h │ ├── Vec2D.inl │ ├── Vec3D.h │ ├── Vec3D.inl │ ├── Vec4D.h │ └── Vec4D.inl ├── objects │ ├── Camera.cpp │ ├── Camera.h │ ├── Group.cpp │ ├── Group.h │ ├── Object.cpp │ └── Object.h ├── resources │ ├── fonts │ │ └── Roboto │ │ │ ├── LICENSE.txt │ │ │ ├── Roboto-Black.ttf │ │ │ ├── Roboto-BlackItalic.ttf │ │ │ ├── Roboto-Bold.ttf │ │ │ ├── Roboto-BoldItalic.ttf │ │ │ ├── Roboto-Italic.ttf │ │ │ ├── Roboto-Light.ttf │ │ │ ├── Roboto-LightItalic.ttf │ │ │ ├── Roboto-Medium.ttf │ │ │ ├── Roboto-MediumItalic.ttf │ │ │ ├── Roboto-Regular.ttf │ │ │ ├── Roboto-Thin.ttf │ │ │ └── Roboto-ThinItalic.ttf │ └── png │ │ └── texture_test.png └── utils │ ├── EventHandler.cpp │ ├── EventHandler.h │ ├── FilePath.cpp │ ├── FilePath.h │ ├── Font.cpp │ ├── Font.h │ ├── Log.cpp │ ├── Log.h │ ├── ObjectController.cpp │ ├── ObjectController.h │ ├── ResourceManager.cpp │ ├── ResourceManager.h │ ├── Time.cpp │ ├── Time.h │ ├── Timer.cpp │ ├── Timer.h │ ├── WorldEditor.cpp │ ├── WorldEditor.h │ ├── math.cpp │ ├── math.h │ ├── monitoring.cpp │ ├── monitoring.h │ └── stack_vector.h ├── resources └── obj │ ├── Dust │ ├── Dust_material_0.png │ ├── Dust_material_1.png │ ├── Dust_material_10.png │ ├── Dust_material_11.png │ ├── Dust_material_12.png │ ├── Dust_material_13.png │ ├── Dust_material_14.png │ ├── Dust_material_15.png │ ├── Dust_material_16.png │ ├── Dust_material_17.png │ ├── Dust_material_18.png │ ├── Dust_material_19.png │ ├── Dust_material_2.png │ ├── Dust_material_20.png │ ├── Dust_material_21.png │ ├── Dust_material_22.png │ ├── Dust_material_3.png │ ├── Dust_material_4.png │ ├── Dust_material_5.png │ ├── Dust_material_6.png │ ├── Dust_material_7.png │ ├── Dust_material_8.png │ ├── Dust_material_9.png │ ├── dust_map.mtl │ └── dust_map.obj │ ├── PastVillage │ ├── PastVillage.mtl │ ├── PastVillage.obj │ ├── mk_032k_pkaidanue.png │ ├── mr_008o_kuro.png │ ├── mr_032f_peye.png │ ├── mr_032f_yane.png │ ├── mr_032k_knphuti.png │ ├── mr_032k_knphuti2.png │ ├── mr_032k_pkaidanue2.png │ ├── mr_032k_pkaidanue3.png │ ├── mr_032k_pnikaid01.png │ ├── mr_032k_psansyoku.png │ ├── mr_064f_ata.png │ ├── mr_064f_atab.png │ ├── mr_064f_atac.png │ ├── mr_064f_atowerc.png │ ├── mr_064f_doord.png │ ├── mr_064f_doorg.png │ ├── mr_064f_puroe.png │ ├── mr_064f_purof.png │ ├── mr_064f_toi.png │ ├── mr_064f_tugime.png │ ├── mr_064f_tugimeb.png │ ├── mr_064k_knhashi.png │ ├── mr_064k_knkabem.png │ ├── mr_064k_knmizo.png │ ├── mr_064k_mizo.png │ ├── mr_064k_mizok.png │ ├── mr_064k_pcueye.png │ ├── mr_064k_piemae.png │ ├── mr_064k_pkaidanmae.png │ ├── mr_064k_pkaidanue.png │ ├── mr_064k_pkata.png │ ├── mr_064k_pkata2.png │ ├── mr_064k_pkire.png │ ├── mr_064k_pue.png │ ├── mr_064k_ue.png │ ├── mr_128f_minkabee.png │ ├── mr_128f_mosh.png │ ├── mr_128f_wallna.png │ ├── mr_128k_knpknu.png │ ├── mr_128k_knpyane.png │ ├── mr_128k_knpyuka.png │ ├── mr_128k_knpyuka25.png │ ├── mr_128k_knpyuka3.png │ ├── mr_128k_krgake.png │ ├── mr_128k_krgakehuti.png │ ├── mr_128k_krkaishita.png │ ├── mr_128k_kuzud.png │ ├── mr_128k_kuzure.png │ ├── mr_128k_kuzure3.png │ ├── mr_128k_mrpkabe.png │ ├── mr_128k_mrpkabe2.png │ ├── mr_128k_nikabe01.png │ ├── mr_128k_phebi.png │ ├── mr_128k_phebi2.png │ ├── mr_128k_phuti.png │ ├── mr_128k_pie.png │ ├── mr_128k_pmiti.png │ ├── mr_128k_pnakaheki.png │ ├── mr_128k_pnikabe01.png │ ├── mr_128k_uekaba.png │ ├── mr_256f_kaaikabe.png │ ├── mr_256f_minkabec.png │ ├── mr_256f_minkabed.png │ ├── mr_256k_krgakemoto.png │ ├── mr_256k_krgakeshi.png │ ├── mr_256k_krkusahara.png │ ├── mr_256k_pgaiheki.png │ ├── mr_256k_uekiregake.png │ ├── mrb_064k_criwac.png │ ├── mrb_128k_criwaa.png │ └── mrb_128k_criwab.png │ ├── cars │ ├── car1 │ │ ├── Car1.mtl │ │ ├── Car1.obj │ │ ├── car1.png │ │ ├── car_blue.png │ │ ├── car_gray.png │ │ ├── car_red.png │ │ ├── car_snow.png │ │ ├── car_snow_blue.png │ │ ├── car_snow_gray.png │ │ ├── car_snow_red.png │ │ ├── car_snowcovered.png │ │ ├── car_snowcovered_blue.png │ │ ├── car_snowcovered_gray.png │ │ └── car_snowcovered_red.png │ ├── car2 │ │ ├── Car2.mtl │ │ ├── Car2.obj │ │ ├── car2.png │ │ ├── car2_black.png │ │ └── car2_red.png │ ├── car3 │ │ ├── Car3.mtl │ │ ├── Car3.obj │ │ ├── car3.png │ │ ├── car3_red.png │ │ └── car3_yellow.png │ ├── car4 │ │ ├── Car4.mtl │ │ ├── Car4.obj │ │ ├── car4.png │ │ ├── car4_grey.png │ │ ├── car4_lightgrey.png │ │ └── car4_lightorange.png │ ├── car5 │ │ ├── Car5.mtl │ │ ├── Car5.obj │ │ ├── Car5_Police.mtl │ │ ├── Car5_Police.obj │ │ ├── Car5_Taxi.mtl │ │ ├── Car5_Taxi.obj │ │ ├── car5.png │ │ ├── car5_green.png │ │ ├── car5_grey.png │ │ ├── car5_police.png │ │ ├── car5_police_la.png │ │ └── car5_taxi.png │ ├── car6 │ │ ├── Car6.mtl │ │ ├── Car6.obj │ │ └── car6.png │ ├── car7 │ │ ├── Car7.mtl │ │ ├── Car7.obj │ │ ├── car7.png │ │ ├── car7_black.png │ │ ├── car7_brown.png │ │ ├── car7_green.png │ │ ├── car7_grey.png │ │ └── car7_red.png │ ├── car8 │ │ ├── Car8.mtl │ │ ├── Car8.obj │ │ ├── Car8.png │ │ ├── Car8_grey.png │ │ ├── Car8_mail.png │ │ └── Car8_purple.png │ ├── cheetah │ │ ├── auto_13_diffuse.png │ │ ├── auto_20_0_diffuse.png │ │ ├── auto_20_diffuse.png │ │ ├── auto_2_diffuse.png │ │ ├── auto_6_diffuse.png │ │ ├── auto_8_diffuse.png │ │ ├── auto_8_normal.png │ │ ├── auto_diffuse.png │ │ ├── cheetah.mtl │ │ └── cheetah.obj │ └── greenwood │ │ ├── greenwoo92interior128.png │ │ ├── greenwoo92wheel64.png │ │ ├── greenwood.mtl │ │ ├── greenwood.obj │ │ ├── plateback3.png │ │ ├── platecharset.png │ │ ├── vehicledash32.png │ │ ├── vehiclegeneric256.png │ │ ├── vehiclegrunge256.png │ │ ├── vehiclegrunge256_primary.png │ │ ├── vehiclegrunge256_secondary.png │ │ ├── vehiclelights128.png │ │ ├── vehiclesteering128.png │ │ └── vehicletyres128.png │ ├── monkey.obj │ ├── skybox │ ├── midday │ │ ├── MidSkyTop.png │ │ ├── MidwayClouds.png │ │ ├── MidwaySkyBack.png │ │ ├── skybox1Shape.mtl │ │ ├── skybox1Shape.obj │ │ ├── skybox2Shape.mtl │ │ ├── skybox2Shape.obj │ │ ├── skyboxShape.mtl │ │ └── skyboxShape.obj │ └── sunset │ │ ├── EgyptBack.bmp.png │ │ ├── EgyptClouds.tga.png │ │ ├── EgyptHaze.tga.png │ │ ├── EgyptWisps.tga.png │ │ ├── skybox.mtl │ │ └── skybox.obj │ └── teapot.obj └── test_scenes ├── animations.cpp ├── gjk_epa_test.cpp ├── past_village.cpp └── physics.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Build folders 2 | out/ 3 | build/ 4 | cmake-build-*/ 5 | film/ 6 | 7 | # IDE 8 | .vscode/ 9 | .idea/ 10 | engine_test 11 | demos/ 12 | 13 | # Compiled source # 14 | *.com 15 | *.class 16 | *.dll 17 | *.exe 18 | *.o 19 | *.so 20 | 21 | # Packages # 22 | # it's better to unpack these files and commit the raw source 23 | # git has its own built in compression methods 24 | *.7z 25 | *.dmg 26 | *.gz 27 | *.iso 28 | *.jar 29 | *.rar 30 | *.tar 31 | *.zip 32 | 33 | # Logs and databases # 34 | *.log 35 | *.sql 36 | *.sqlite 37 | 38 | # OS generated files # 39 | .DS_Store 40 | .DS_Store? 41 | ._* 42 | .Spotlight-V100 43 | .Trashes 44 | ehthumbs.db 45 | Thumbs.db 46 | ======= 47 | .vs/ 48 | CMakeSettings.json 49 | 50 | # CMake 51 | CMakeUserPresets.json 52 | 53 | # MacOS 54 | .DS_Store 55 | 56 | # Project exclude paths 57 | engine.log 58 | 3dzavr_test 59 | *.blend -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.25) 2 | set(CMAKE_CXX_STANDARD 20) 3 | 4 | project(3dzavr) 5 | 6 | 7 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 8 | add_executable(${CMAKE_PROJECT_NAME} test_scenes/past_village.cpp) 9 | 10 | find_package(SDL2 CONFIG COMPONENTS SDL2main) 11 | if(TARGET SDL2::SDL2main) 12 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE SDL2::SDL2main) 13 | else() 14 | target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE SDL_MAIN_HANDLED) 15 | endif() 16 | 17 | # include engine into our project 18 | add_subdirectory(engine) 19 | target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC 3DZAVR) 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Ivan Ilin (Vectozavr) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /engine/Consts.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINE_CONSTS_H 2 | #define ENGINE_CONSTS_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Consts { 13 | const Color BACKGROUND_COLOR = Color(255, 255, 255); 14 | 15 | // Running mode detection 16 | #ifndef NDEBUG 17 | const std::string RUNNING_MODE = "Debug"; 18 | #else 19 | const std::string RUNNING_MODE = "Release"; 20 | #endif 21 | 22 | // OS Detection 23 | #if defined(_WIN32) || defined(_WIN64) 24 | const std::string OPERATION_SYSTEM = "Windows"; 25 | #elif defined(__linux__) 26 | const std::string OPERATION_SYSTEM = "Linux"; 27 | #elif defined(__APPLE__) && defined(__MACH__) 28 | const std::string OPERATION_SYSTEM = "MacOS"; 29 | #else 30 | const std::string OPERATION_SYSTEM = "Unknown"; 31 | #endif 32 | 33 | // Processor Architecture 34 | #if defined(__x86_64__) || defined(_M_X64) 35 | const std::string CPU_ARCHITECTURE = "x86-64"; 36 | #elif defined(__i386__) || defined(_M_IX86) 37 | const std::string CPU_ARCHITECTURE = "x86"; 38 | #elif defined(__arm__) 39 | const std::string CPU_ARCHITECTURE = "ARM"; 40 | #elif defined(__aarch64__) 41 | const std::string CPU_ARCHITECTURE = "ARM64"; 42 | #else 43 | const std::string CPU_ARCHITECTURE = "Unknown"; 44 | #endif 45 | 46 | const std::string BUILD_INFO = "3dzavr sdl v0.2.1 CPU | " + RUNNING_MODE; 47 | 48 | const Vec2D BEZIER[2] = {Vec2D{0.8, 0}, Vec2D{0.2, 1}}; 49 | 50 | const Color WHITE_COLORS[] = { 51 | Color(137, 135, 222), // blue 52 | Color(195, 155, 209), // pink 53 | Color(201, 137, 137), // red 54 | Color(116, 204, 135), // green 55 | Color(201, 171, 137), // orange 56 | }; 57 | 58 | const Color DARK_COLORS[] = { 59 | Color(16, 18, 69), // blue 60 | Color(77, 0, 62), // pink 61 | Color(99, 20, 20), // red 62 | Color(12, 46, 9), // green 63 | Color(97, 70, 51), // orange 64 | }; 65 | 66 | const FilePath DEFAULT_TEXTURE_PATH = FilePath("engine/resources/png/texture_test.png"); 67 | const std::shared_ptr DEFAULT_MATERIAL = std::make_shared( 68 | MaterialTag("Default_material"), nullptr, 69 | Color(255, 200, 170),Color(255, 200, 170),Color(255, 200, 170)); 70 | 71 | // resources 72 | const FilePath DEFAULT_FONT_FILENAME = FilePath("engine/resources/fonts/Roboto/Roboto-Light.ttf"); 73 | } 74 | 75 | #endif //ENGINE_CONSTS_H 76 | -------------------------------------------------------------------------------- /engine/Engine.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINE_ENGINE_H 2 | #define ENGINE_ENGINE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * TODO: implement network system for the SDL version. That might be based on the SDL_net module: 11 | * https://wiki.libsdl.org/SDL2_net/FrontPage 12 | * https://wiki.libsdl.org/SDL2_net/CategoryAPI 13 | */ 14 | 15 | class Engine { 16 | private: 17 | bool _updateWorld = true; 18 | 19 | std::vector> _projectedOpaqueTriangles; 20 | std::vector> _projectedTranspTriangles; 21 | std::vector> _projectedLines; 22 | 23 | std::vector> _lightSources; 24 | 25 | void projectObject(const Object& object); 26 | void drawProjectedTriangles(); 27 | 28 | // For debug purposes 29 | bool _showDebugInfo = Consts::SHOW_DEBUG_INFO; 30 | std::map>> _histResources; 31 | 32 | void printDebugInfo(); 33 | 34 | static int handleSDLEvents(); 35 | 36 | protected: 37 | const std::shared_ptr screen = std::make_shared(); 38 | 39 | const std::shared_ptr world = std::make_shared(ObjectTag("Main_Scene(World)")); 40 | const std::shared_ptr camera = std::make_shared(); 41 | 42 | virtual void start() {}; 43 | virtual void update() {}; 44 | 45 | [[nodiscard]] bool showDebugInfo() const { return _showDebugInfo; } 46 | void setDebugInfo(bool value) { _showDebugInfo = value; } 47 | 48 | void setUpdateWorld(bool value) { _updateWorld = value; } 49 | 50 | virtual void gui() {} 51 | 52 | public: 53 | Engine(); 54 | 55 | void create(uint16_t screenWidth = Consts::STANDARD_SCREEN_WIDTH, uint16_t screenHeight = Consts::STANDARD_SCREEN_HEIGHT, 56 | const Color& background = Consts::BACKGROUND_COLOR); 57 | 58 | void exit(); 59 | }; 60 | 61 | 62 | #endif //ENGINE_ENGINE_H 63 | -------------------------------------------------------------------------------- /engine/ScalarConsts.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINE_SCALAR_CONSTS_H 2 | #define ENGINE_SCALAR_CONSTS_H 3 | 4 | #include 5 | 6 | namespace Consts { 7 | constexpr uint16_t STANDARD_SCREEN_WIDTH = 640; 8 | constexpr uint16_t STANDARD_SCREEN_HEIGHT = 480; 9 | 10 | constexpr uint16_t STANDARD_EDITOR_WIDTH = STANDARD_SCREEN_WIDTH + 300; 11 | constexpr uint16_t STANDARD_EDITOR_HEIGHT = STANDARD_SCREEN_HEIGHT; 12 | constexpr uint16_t SCREEN_SCALE = 2; 13 | 14 | constexpr bool USE_LOG_FILE = true; 15 | constexpr bool SHOW_DEBUG_INFO = false; 16 | 17 | constexpr double PI = 3.14159265358979323846264338327950288; 18 | constexpr double EPS = 0.00000000001; // 1e-11 19 | constexpr double ABG_TRIANGLE_BORDER_WIDTH = 0.01; 20 | 21 | constexpr double LIGHTING_LOD_NEAR_DISTANCE = 5; 22 | constexpr double LIGHTING_LOD_FAR_DISTANCE = 10; 23 | 24 | constexpr unsigned int GJK_MAX_ITERATIONS = 30; 25 | constexpr unsigned int EPA_MAX_ITERATIONS = 30; 26 | constexpr double EPA_DEPTH_EPS = 0.0001; // 1e-4 27 | 28 | constexpr double FIXED_UPDATE_INTERVAL = 0.02; // 50 fps 29 | constexpr double TAP_DELAY = 0.2; 30 | 31 | constexpr int MB = 1024*1024; 32 | } 33 | 34 | #endif //ENGINE_SCALAR_CONSTS_H 35 | -------------------------------------------------------------------------------- /engine/World.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | std::shared_ptr World::loadObject(const ObjectTag &tag, 11 | const FilePath &meshFile, 12 | const Vec3D &scale) { 13 | auto obj = ResourceManager::loadTriangleMesh(tag, meshFile); 14 | obj->getComponent()->scale(scale); 15 | add(obj); 16 | 17 | Log::log("World::loadMesh(): inserted Group from " + meshFile.str() + " with title '" + tag.str() + "'"); 18 | return obj; 19 | } 20 | 21 | TriangleMesh::IntersectionInformation World::rayCast(const Vec3D &from, const Vec3D &to, const std::set &skipTags) { 22 | return intersect(from, to, skipTags); 23 | } 24 | 25 | void World::update() { 26 | updateComponents(); 27 | checkCollision(sharedPtr()); 28 | } 29 | 30 | void World::checkCollision(const std::shared_ptr &whereToCheck) { 31 | for (auto &[name, object] : *whereToCheck) { 32 | auto rigidObject = object->getComponent(); 33 | if(rigidObject && rigidObject->hasCollision()) { 34 | checkCollision(sharedPtr(), object); 35 | checkCollision(object); 36 | } 37 | } 38 | } 39 | 40 | void World::checkCollision(const std::shared_ptr& whereToCheck, const std::shared_ptr& whatToCheck) { 41 | 42 | for (auto &[name, object] : *whereToCheck) { 43 | // Check collision of whatToCheck with object 44 | checkCollisionBetweenTwo(whatToCheck, object); 45 | 46 | // Check collision of whatToCheck with all children of object 47 | checkCollision(object, whatToCheck); 48 | } 49 | } 50 | 51 | void World::checkCollisionBetweenTwo(const std::shared_ptr &obj1, const std::shared_ptr &obj2) { 52 | if(obj1->name() == obj2->name()) { 53 | return; // We should not check the collision of the object with itself 54 | } 55 | 56 | auto rigidObj1 = obj1->getComponent(); 57 | auto rigidObj2 = obj2->getComponent(); 58 | if(!rigidObj2) { 59 | return; 60 | } 61 | 62 | std::pair gjk = rigidObj1->checkGJKCollision(rigidObj2); 63 | if (!gjk.first) { 64 | return; // no collision 65 | } 66 | 67 | CollisionPoint epa = rigidObj1->EPA(gjk.second, rigidObj2); 68 | RigidObject::SolveCollision(epa, rigidObj1, rigidObj2); 69 | 70 | if (rigidObj1->collisionCallBack() != nullptr) { 71 | rigidObj1->collisionCallBack()(epa, rigidObj1, rigidObj2); 72 | } 73 | if (rigidObj2->collisionCallBack() != nullptr) { 74 | rigidObj2->collisionCallBack()(epa, rigidObj2, rigidObj1); 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /engine/World.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINE_WORLD_H 2 | #define ENGINE_WORLD_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | class World final : public Group { 15 | private: 16 | void checkCollision(const std::shared_ptr& whereToCheck); 17 | void checkCollision(const std::shared_ptr& whereToCheck, const std::shared_ptr& whatToCheck); 18 | static void checkCollisionBetweenTwo(const std::shared_ptr& obj1, const std::shared_ptr& obj2); 19 | public: 20 | explicit World(const ObjectTag& sceneName) : Group(sceneName) {}; 21 | 22 | void update(); 23 | 24 | std::shared_ptr loadObject(const ObjectTag &tag, 25 | const FilePath &meshFile, 26 | const Vec3D &scale = Vec3D{1, 1, 1}); 27 | 28 | // std::vector skipTags is a vector of all objects we want to skip in ray casting 29 | TriangleMesh::IntersectionInformation rayCast(const Vec3D &from, const Vec3D &to, const std::set &skipTags = {}); 30 | }; 31 | 32 | 33 | #endif //INC_3DZAVR_WORLD_H 34 | -------------------------------------------------------------------------------- /engine/animation/Animation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | Animation::Animation(double duration, Animation::LoopOut looped, Animation::InterpolationType intType, bool waitForFinish) 6 | : _duration(duration), _looped(looped), _intType(intType), _waitForFinish(waitForFinish) { 7 | } 8 | 9 | bool Animation::updateState() { 10 | if (_finished || std::abs(_duration) < Consts::EPS) { 11 | _finished = true; 12 | return false; 13 | } 14 | 15 | // linear normalized time: 16 | _dtime = Time::deltaTime() / _duration; 17 | 18 | switch (_intType) { 19 | case InterpolationType::Bezier: 20 | _dprogress = Interpolation::dBezier(Consts::BEZIER[0], Consts::BEZIER[1], _time, _dtime); 21 | break; 22 | case InterpolationType::Bouncing: 23 | _dprogress = Interpolation::dBouncing(_time, _dtime); 24 | break; 25 | case InterpolationType::Linear: 26 | _dprogress = Interpolation::dLinear(_time, _dtime); 27 | break; 28 | default: 29 | throw std::logic_error{ 30 | "Animation::updateState: unknown interpolation type " + std::to_string(static_cast(_intType)) 31 | }; 32 | } 33 | 34 | if (_time + _dtime > 1.0) { 35 | _dtime = 1.0 - _time; 36 | _time = 1.0; 37 | _dprogress = 1.0 - _progress; 38 | _progress = 1.0; 39 | _finished = true; 40 | 41 | } else { 42 | _time += _dtime; 43 | _progress += _dprogress; 44 | } 45 | 46 | if (_looped == LoopOut::Continue && _time > 0.5) { 47 | _time = 0.5; 48 | } 49 | 50 | update(); 51 | 52 | return !_finished; 53 | } 54 | -------------------------------------------------------------------------------- /engine/animation/Animation.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_ANIMATION_H 2 | #define ANIMATION_ANIMATION_H 3 | 4 | #include 5 | 6 | class Animation { 7 | public: 8 | enum class InterpolationType { 9 | Linear, 10 | Bezier, 11 | Bouncing 12 | }; 13 | enum class LoopOut { 14 | None, 15 | Continue 16 | }; 17 | private: 18 | // normalized time (from 0 to 1) 19 | double _time = 0; 20 | double _dtime = 0; 21 | 22 | bool _finished = false; 23 | 24 | double _progress = 0; 25 | double _dprogress = 0; 26 | 27 | // If '_waitForFinish' == true then we need to finish all animation before starting this one. (for example AWait) 28 | // In addition new animations in particular animation list will be started only after finishing this animation. 29 | const bool _waitForFinish; 30 | const double _duration = 0; 31 | const LoopOut _looped = LoopOut::None; 32 | const InterpolationType _intType = InterpolationType::Bezier; 33 | 34 | // You should override this method for your particular animation 35 | virtual void update() = 0; 36 | 37 | protected: 38 | [[nodiscard]] double progress() const { return _progress; } 39 | [[nodiscard]] double dprogress() const { return _dprogress; } 40 | 41 | void stop() { _finished = true; } 42 | 43 | public: 44 | Animation(double duration, LoopOut looped, InterpolationType intType, bool waitForFinish = false); 45 | 46 | virtual ~Animation() = default; 47 | 48 | bool updateState(); 49 | 50 | [[nodiscard]] bool isWaitingForFinish() const { return _waitForFinish; } 51 | }; 52 | 53 | #endif //ANIMATION_ANIMATION_H 54 | -------------------------------------------------------------------------------- /engine/animation/Animations.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_ANIMATIONS_H 2 | #define ANIMATION_ANIMATIONS_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | #endif //ANIMATION_ANIMATIONS_H 22 | -------------------------------------------------------------------------------- /engine/animation/AttractToPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_ATTRACTTOPOINT_H 2 | #define ANIMATION_ATTRACTTOPOINT_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | class AttractToPoint : public Animation { 8 | private: 9 | const std::weak_ptr _object; 10 | const Vec3D _targetPoint; 11 | const double _valueToAttract; 12 | 13 | void update() override { 14 | auto obj = _object.lock(); 15 | 16 | if (obj == nullptr) { 17 | stop(); 18 | return; 19 | } 20 | 21 | obj->attractToPoint(_targetPoint, _valueToAttract * dprogress()); 22 | } 23 | 24 | public: 25 | AttractToPoint(const std::weak_ptr& object, const Vec3D &targetPoint, double valueToAttract, double duration = 1, 26 | Animation::LoopOut looped = LoopOut::None, 27 | Animation::InterpolationType interpolationType = InterpolationType::Bezier) 28 | : Animation(duration, looped, interpolationType), _object(object), _targetPoint(targetPoint), 29 | _valueToAttract(valueToAttract) {} 30 | }; 31 | 32 | #endif //ANIMATION_ATTRACTTOPOINT_H 33 | -------------------------------------------------------------------------------- /engine/animation/Decompose.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_DECOMPOSE_H 2 | #define ANIMATION_DECOMPOSE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Decompose final : public Animation { 9 | private: 10 | const std::weak_ptr _mesh; 11 | std::vector _triangles; 12 | 13 | double _value; 14 | bool _started = false; 15 | 16 | void update() override { 17 | auto mesh = _mesh.lock(); 18 | 19 | if (mesh == nullptr) { 20 | stop(); 21 | return; 22 | } 23 | 24 | if (!_started) { 25 | _started = true; 26 | _triangles = _mesh.lock()->triangles(); 27 | } 28 | 29 | std::vector newTriangles; 30 | newTriangles.reserve(_triangles.size()); 31 | 32 | for(auto &t : _triangles) { 33 | newTriangles.emplace_back((t * Matrix4x4::Translation(t.centroid().normalized()*progress()*_value))); 34 | } 35 | mesh->setTriangles(std::move(newTriangles)); 36 | } 37 | 38 | public: 39 | Decompose(const std::weak_ptr& triangleMesh, double value, double duration = 1, LoopOut looped = LoopOut::None, 40 | InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped, 41 | interpolationType), 42 | _value(value), _mesh(triangleMesh) {} 43 | }; 44 | 45 | #endif //ANIMATION_DECOMPOSE_H 46 | -------------------------------------------------------------------------------- /engine/animation/Function.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_FUNCTION_H 2 | #define ANIMATION_FUNCTION_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | class Function final : public Animation { 9 | private: 10 | int _callsCounter = 0; 11 | const int _allCalls = 1; 12 | const std::function _callBack; 13 | 14 | void update() override { 15 | if (_allCalls != 0 && progress() >= (double) (_callsCounter + 1) / _allCalls) { 16 | _callsCounter++; 17 | _callBack(); 18 | } 19 | } 20 | 21 | public: 22 | explicit Function(std::function function, int calls = 1, double duration = 1, 23 | LoopOut looped = LoopOut::None, InterpolationType interpolationType = InterpolationType::Linear) 24 | : Animation(duration, looped, interpolationType), _callBack(std::move(function)), _allCalls(calls) { 25 | } 26 | }; 27 | 28 | #endif //ANIMATION_FUNCTION_H 29 | -------------------------------------------------------------------------------- /engine/animation/Interpolation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | double Interpolation::Linear(double t) { 7 | if (t < 0) { 8 | t = -t; 9 | } 10 | int integer = static_cast(t); 11 | 12 | return (integer % 2) ? 1.0 - (t - integer) : (t - integer); 13 | } 14 | 15 | double Interpolation::Bezier(const Vec2D &p1, const Vec2D &p2, double t) { 16 | // TODO: implement bezier curve without finding the root of equation 17 | t = Interpolation::Linear(t); 18 | 19 | double h = Consts::EPS; 20 | double eps = Consts::EPS; 21 | 22 | // We are trying to find 's' when px = t 23 | auto f = [=](double s) { 24 | return 3.0 * (1.0 - s) * (1.0 - s) * s * p1.x() + 3.0 * (1.0 - s) * s * s * p2.x() + s * s * s - t; 25 | }; 26 | // Using found 's' we will calculate resulting py 27 | auto py = [=](double s) { 28 | return 3.0 * (1.0 - s) * (1.0 - s) * s * p1.y() + 3.0 * (1.0 - s) * s * s * p2.y() + s * s * s; 29 | }; 30 | 31 | auto df = [=](double s) { 32 | return (f(s + h) - f(s - h)) / (2.0 * h); 33 | }; 34 | 35 | // Newton method 36 | double s1 = 0.0, s2 = 0.5; 37 | int i = 0; 38 | 39 | while (std::abs(s1 - s2) > eps) { 40 | s1 = s2; 41 | s2 = s1 - f(s1) / df(s1); 42 | i++; 43 | } 44 | 45 | return py(s1); 46 | } 47 | 48 | double Interpolation::Bouncing(double t) { 49 | t = Interpolation::Linear(t); 50 | return 0.5 * (1.0 / (1.0 + exp(10.0 * (-4.0 * t + 0.8))) + 51 | (1.0 + 2.5 * sin(50.0 * (t - 1.0 / 3.0)) * exp(-7.0 * t)) / (1.0 + exp(10.0 * (-15.0 * t + 3.1)))); 52 | } 53 | 54 | double Interpolation::dLinear(double t, double dt) { 55 | return ((int) trunc(t) % 2) ? -dt : dt; 56 | } 57 | 58 | double Interpolation::dBezier(const Vec2D &p1, const Vec2D &p2, double t, double dt) { 59 | return Interpolation::Bezier(p1, p2, t + dt) - Interpolation::Bezier(p1, p2, t); 60 | } 61 | 62 | double Interpolation::dBouncing(double t, double dt) { 63 | return Bouncing(t + dt) - Bouncing(t); 64 | } 65 | -------------------------------------------------------------------------------- /engine/animation/Interpolation.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_INTERPOLATION_H 2 | #define ANIMATION_INTERPOLATION_H 3 | 4 | #include 5 | 6 | namespace Interpolation { 7 | double Linear(double t); 8 | double Bezier(const Vec2D &p1, const Vec2D &p2, double t); 9 | double Bouncing(double t); 10 | 11 | double dLinear(double t, double dt); 12 | double dBezier(const Vec2D &p1, const Vec2D &p2, double t, double dt); 13 | double dBouncing(double t, double dt); 14 | }; 15 | 16 | #endif //ANIMATION_INTERPOLATION_H 17 | -------------------------------------------------------------------------------- /engine/animation/Rotate.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_ROTATE_H 2 | #define ANIMATION_ROTATE_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | class Rotate final : public Animation { 8 | private: 9 | const std::weak_ptr _object; 10 | const Vec3D _rotationValue; 11 | 12 | void update() override { 13 | auto obj = _object.lock(); 14 | 15 | if (obj == nullptr) { 16 | stop(); 17 | return; 18 | } 19 | 20 | obj->rotate(_rotationValue * dprogress()); 21 | } 22 | 23 | public: 24 | Rotate(const std::weak_ptr& object, const Vec3D &r, double duration = 1, LoopOut looped = LoopOut::None, 25 | InterpolationType interpolationType = InterpolationType::Bezier) 26 | : Animation(duration, looped, interpolationType), _object(object), _rotationValue(r) { 27 | } 28 | }; 29 | 30 | #endif //ANIMATION_ROTATE_H 31 | -------------------------------------------------------------------------------- /engine/animation/RotateLeft.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_ROTATELEFT_H 2 | #define ANIMATION_ROTATELEFT_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | class RotateLeft final : public Animation { 8 | private: 9 | const std::weak_ptr _object; 10 | const double _rotationValue; 11 | 12 | void update() override { 13 | auto obj = _object.lock(); 14 | 15 | if (obj == nullptr) { 16 | stop(); 17 | return; 18 | } 19 | 20 | obj->rotateLeft(_rotationValue*dprogress()); 21 | } 22 | 23 | public: 24 | RotateLeft(const std::weak_ptr& object, double r, double duration = 1, LoopOut looped = LoopOut::None, 25 | InterpolationType interpolationType = InterpolationType::Bezier) 26 | : Animation(duration, looped, interpolationType), _object(object), _rotationValue(r) {} 27 | }; 28 | 29 | #endif //ANIMATION_ROTATELEFT_H 30 | -------------------------------------------------------------------------------- /engine/animation/RotateLeftUpLookAt.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_ROTATELEFTUPLOOKAT_H 2 | #define ANIMATION_ROTATELEFTUPLOOKAT_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | 8 | class RotateLeftUpLookAt final : public Animation { 9 | private: 10 | const std::weak_ptr _object; 11 | const Vec3D _rotationValue; 12 | 13 | void update() override { 14 | auto obj = _object.lock(); 15 | 16 | if (obj == nullptr) { 17 | stop(); 18 | return; 19 | } 20 | 21 | obj->rotateLeft(_rotationValue.x()*dprogress()); 22 | obj->rotateUp(_rotationValue.y()*dprogress()); 23 | obj->rotateLookAt(_rotationValue.z()*dprogress()); 24 | } 25 | 26 | public: 27 | RotateLeftUpLookAt(const std::weak_ptr& object, const Vec3D &r, double duration = 1, LoopOut looped = LoopOut::None, 28 | InterpolationType interpolationType = InterpolationType::Bezier) 29 | : Animation(duration, looped, interpolationType), _object(object), _rotationValue(r) {} 30 | }; 31 | 32 | #endif //ANIMATION_ROTATELEFTUPLOOKAT_H 33 | -------------------------------------------------------------------------------- /engine/animation/RotateRelativePoint.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_ROTATERELATIVEPOINT_H 2 | #define ANIMATION_ROTATERELATIVEPOINT_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | class RotateRelativePoint : public Animation { 8 | private: 9 | const std::weak_ptr _object; 10 | const Vec3D _targetPoint; 11 | const Vec3D _rotationValue; 12 | 13 | void update() override { 14 | auto obj = _object.lock(); 15 | 16 | if (obj == nullptr) { 17 | stop(); 18 | return; 19 | } 20 | 21 | obj->rotateRelativePoint(_targetPoint, _rotationValue * dprogress()); 22 | } 23 | 24 | public: 25 | RotateRelativePoint(const std::weak_ptr& object, const Vec3D &targetPoint, const Vec3D &rotationValue, 26 | double duration = 1, Animation::LoopOut looped = LoopOut::None, 27 | Animation::InterpolationType interpolationType = InterpolationType::Bezier) 28 | : Animation(duration, looped, interpolationType), _object(object), _targetPoint(targetPoint), 29 | _rotationValue(rotationValue) {} 30 | }; 31 | 32 | #endif //ANIMATION_ROTATERELATIVEPOINT_H 33 | -------------------------------------------------------------------------------- /engine/animation/Scale.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_SCALE_H 2 | #define ANIMATION_SCALE_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | class Scale final : public Animation { 8 | private: 9 | const std::weak_ptr _object; 10 | const Vec3D _scalingValue; 11 | Vec3D _prevScaleFactor{1, 1, 1}; 12 | 13 | void update() override { 14 | auto obj = _object.lock(); 15 | 16 | if (obj == nullptr) { 17 | stop(); 18 | return; 19 | } 20 | // invert scale 21 | obj->scale(Vec3D(1.0/_prevScaleFactor.x(), 1.0/_prevScaleFactor.y(), 1.0/_prevScaleFactor.z())); 22 | Vec3D scaleFactor = Vec3D{1, 1, 1} + (_scalingValue - Vec3D{1, 1, 1}) * progress(); 23 | obj->scale(scaleFactor); 24 | _prevScaleFactor = scaleFactor; 25 | } 26 | 27 | public: 28 | Scale(const std::weak_ptr& object, const Vec3D &s, double duration = 1, LoopOut looped = LoopOut::None, 29 | InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped, 30 | interpolationType), 31 | _object(object), _scalingValue(s) { 32 | } 33 | }; 34 | 35 | #endif //ANIMATION_SCALE_H 36 | -------------------------------------------------------------------------------- /engine/animation/ShowCreation.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_SHOWCREATION_H 2 | #define ANIMATION_SHOWCREATION_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class ShowCreation final : public Animation { 9 | private: 10 | const std::weak_ptr _mesh; 11 | const std::vector _triangles; 12 | double _shift; // value from 0 to 1 13 | 14 | void update() override { 15 | auto mesh = _mesh.lock(); 16 | 17 | if (!mesh) { 18 | stop(); 19 | return; 20 | } 21 | 22 | std::vector newTriangles; 23 | newTriangles.reserve(_triangles.size()); 24 | 25 | // The time of one triangle 26 | double dt = 1.0/((_triangles.size()-1)*_shift + 1); 27 | double k = 0; 28 | 29 | for(auto &t : _triangles) { 30 | auto& tc = t.textureCoordinates(); 31 | 32 | if(progress() >= dt*k*_shift) { 33 | if(progress() <= dt*(k*_shift + 1)) { 34 | double triProgress = (progress() - dt*k*_shift) / dt; 35 | 36 | newTriangles.emplace_back(Triangle({t[0], t[1], t[1] + (t[2] - t[1]) * triProgress}, 37 | {tc[0], tc[1], tc[1] + (tc[2] - tc[1]) * triProgress})); 38 | } else { 39 | newTriangles.emplace_back(t); 40 | } 41 | } 42 | 43 | k += 1; 44 | } 45 | mesh->setTriangles(std::move(newTriangles)); 46 | } 47 | 48 | public: 49 | ShowCreation(const std::weak_ptr& triangleMesh, double duration = 1, double shift = 0.005, LoopOut looped = LoopOut::None, 50 | InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped, 51 | interpolationType), 52 | _mesh(triangleMesh), _triangles(triangleMesh.lock()->triangles()) { 53 | _shift = std::clamp(shift, 0.0, 1.0); 54 | } 55 | }; 56 | 57 | #endif //ANIMATION_SHOWCREATION_H 58 | -------------------------------------------------------------------------------- /engine/animation/ShowUncreation.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_SHOWUNCREATION_H 2 | #define ANIMATION_SHOWUNCREATION_H 3 | 4 | #include 5 | #include 6 | 7 | class ShowUncreation final : public Animation { 8 | private: 9 | const std::weak_ptr _mesh; 10 | const std::vector _triangles; 11 | double _shift; // value from 0 to 1 12 | 13 | void update() override { 14 | auto mesh = _mesh.lock(); 15 | 16 | if (!mesh) { 17 | stop(); 18 | return; 19 | } 20 | 21 | std::vector newTriangles; 22 | newTriangles.reserve(_triangles.size()); 23 | 24 | // The time of one triangle 25 | double dt = 1.0/((_triangles.size()-1)*_shift + 1); 26 | double k = 0; 27 | double progress_inv = 1 - progress(); 28 | 29 | for(auto &t : _triangles) { 30 | auto& tc = t.textureCoordinates(); 31 | 32 | if(progress_inv >= dt*k*_shift) { 33 | if(progress_inv <= dt*(k*_shift + 1)) { 34 | double triProgress = (progress_inv - dt*k*_shift) / dt; 35 | 36 | newTriangles.emplace_back(Triangle({t[0], t[1], t[1] + (t[2] - t[1]) * triProgress}, 37 | {tc[0], tc[1], tc[1] + (tc[2] - tc[1]) * triProgress})); 38 | } else { 39 | newTriangles.emplace_back(t); 40 | } 41 | } 42 | 43 | k += 1; 44 | } 45 | mesh->setTriangles(std::move(newTriangles)); 46 | } 47 | 48 | public: 49 | ShowUncreation(const std::weak_ptr& triangleMesh, double duration = 1, double shift = 0.005, LoopOut looped = LoopOut::None, 50 | InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped, 51 | interpolationType), 52 | _mesh(triangleMesh), _triangles(triangleMesh.lock()->triangles()) { 53 | _shift = std::clamp(shift, 0.0, 1.0); 54 | } 55 | }; 56 | 57 | #endif //ANIMATION_SHOWUNCREATION_H 58 | -------------------------------------------------------------------------------- /engine/animation/Timeline.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | Timeline *Timeline::_instance = nullptr; 7 | 8 | void Timeline::init() { 9 | delete _instance; 10 | _instance = new Timeline(); 11 | 12 | Log::log("Timeline::init(): animation timeline was initialized"); 13 | } 14 | 15 | void Timeline::deleteAllAnimations() { 16 | if (_instance == nullptr) { 17 | return; 18 | } 19 | 20 | Log::log("Timeline::deleteAllAnimations(): all " + std::to_string(_instance->_animations.size()) + " list was deleted"); 21 | _instance->_animations.clear(); 22 | } 23 | 24 | void Timeline::deleteAnimationList(const AnimationListTag &listName) { 25 | if (_instance == nullptr) { 26 | return; 27 | } 28 | 29 | auto it = _instance->_animations.find(listName); 30 | 31 | if(it != _instance->_animations.end()) { 32 | _instance->_animations.erase(it); 33 | } else { 34 | Log::log("Timeline::deleteAnimationList(): list '" + listName.str() + "' does not exist"); 35 | } 36 | } 37 | 38 | [[nodiscard]] bool Timeline::isInAnimList(const AnimationListTag &listName) { 39 | if (_instance == nullptr) { 40 | return false; 41 | } 42 | 43 | auto it = _instance->_animations.find(listName); 44 | if(it != _instance->_animations.end()) { 45 | return !it->second.empty(); 46 | } 47 | 48 | return false; 49 | } 50 | 51 | void Timeline::update() { 52 | if (_instance == nullptr) { 53 | return; 54 | } 55 | 56 | for (auto iter = _instance->_animations.begin(); iter != _instance->_animations.end(); ) { 57 | if (iter->second.empty()) { 58 | _instance->_animations.erase(iter++); 59 | continue; 60 | } 61 | auto& animationList = iter->second; 62 | auto it = animationList.begin(); 63 | 64 | // If it the front animation is 'AWait' we should wait until waiting time is over 65 | if ((it != animationList.end()) && (*it)->isWaitingForFinish()) { 66 | if (!(*it)->updateState()) { 67 | animationList.erase(it); 68 | } 69 | ++iter; 70 | continue; 71 | } 72 | 73 | // Otherwise we iterate over all animation until we meet animations.end() or wait animation 74 | while (!animationList.empty() && (it != animationList.end()) && (!(*it)->isWaitingForFinish())) { 75 | if (!(*it)->updateState()) { 76 | animationList.erase(it++); 77 | } else { 78 | ++it; 79 | } 80 | } 81 | ++iter; 82 | } 83 | } 84 | 85 | void Timeline::free() { 86 | Timeline::deleteAllAnimations(); 87 | 88 | delete _instance; 89 | _instance = nullptr; 90 | 91 | Log::log("Timeline::free(): pointer to 'Timeline' was freed"); 92 | } 93 | -------------------------------------------------------------------------------- /engine/animation/Timeline.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_TIMELINE_H 2 | #define ANIMATION_TIMELINE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | class AnimationListTag final { 12 | private: 13 | const std::string _name; 14 | public: 15 | explicit AnimationListTag(const std::string& name = "") : _name(name) {} 16 | 17 | [[nodiscard]] std::string str() const { return _name; } 18 | [[nodiscard]] bool empty() const { return _name.empty(); } 19 | 20 | bool operator==(const AnimationListTag &tag) const { return _name == tag._name; } 21 | bool operator!=(const AnimationListTag &tag) const { return _name != tag._name; } 22 | bool operator<(const AnimationListTag &tag) const { return _name < tag._name; } 23 | }; 24 | 25 | class Timeline { 26 | private: 27 | std::map>> _animations; 28 | 29 | static Timeline *_instance; 30 | 31 | Timeline() = default; 32 | 33 | public: 34 | Timeline(const Timeline &) = delete; 35 | 36 | Timeline &operator=(Timeline &) = delete; 37 | 38 | static void update(); 39 | 40 | static void deleteAllAnimations(); 41 | 42 | static void deleteAnimationList(const AnimationListTag &listName); 43 | 44 | [[nodiscard]] static bool isInAnimList(const AnimationListTag &listName); 45 | 46 | static void init(); 47 | 48 | static void free(); 49 | 50 | template 51 | static void addAnimation(const AnimationListTag &listName, Arguments... args) { 52 | if (_instance == nullptr) { 53 | return; 54 | } 55 | 56 | _instance->_animations[listName].emplace_back(std::make_shared(args...)); 57 | } 58 | 59 | template 60 | static void addAnimation(Arguments... args) { 61 | if (_instance == nullptr) { 62 | return; 63 | } 64 | 65 | _instance->_animations[AnimationListTag("timeline_0")].emplace_back(std::make_shared(args...)); 66 | } 67 | }; 68 | 69 | #endif //ANIMATION_TIMELINE_H 70 | -------------------------------------------------------------------------------- /engine/animation/Translate.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_TRANSLATE_H 2 | #define ANIMATION_TRANSLATE_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | class Translate final : public Animation { 8 | private: 9 | const std::weak_ptr _object; 10 | const Vec3D _translationValue; 11 | 12 | void update() override { 13 | auto obj = _object.lock(); 14 | 15 | if (obj == nullptr) { 16 | stop(); 17 | return; 18 | } 19 | 20 | obj->translate(_translationValue * dprogress()); 21 | } 22 | 23 | public: 24 | Translate(const std::weak_ptr& object, const Vec3D &t, double duration = 1, LoopOut looped = LoopOut::None, 25 | InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped, 26 | interpolationType), 27 | _object(object), 28 | _translationValue(t) { 29 | } 30 | }; 31 | 32 | #endif //ANIMATION_TRANSLATE_H 33 | -------------------------------------------------------------------------------- /engine/animation/TranslateToPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_TRANSLATETOPOINT_H 2 | #define ANIMATION_TRANSLATETOPOINT_H 3 | 4 | #include 5 | #include "components/TransformMatrix.h" 6 | 7 | class TranslateToPoint final : public Animation { 8 | private: 9 | const std::weak_ptr _object; 10 | const Vec3D _targetPoint; 11 | Vec3D _translationValue; 12 | 13 | bool _started = false; 14 | 15 | void update() override { 16 | auto obj = _object.lock(); 17 | 18 | if (obj == nullptr) { 19 | stop(); 20 | return; 21 | } 22 | 23 | if (!_started) { 24 | _started = true; 25 | _translationValue = _targetPoint - _object.lock()->position(); 26 | } 27 | obj->translate(_translationValue * dprogress()); 28 | } 29 | 30 | public: 31 | TranslateToPoint(const std::weak_ptr& object, const Vec3D &p, double duration = 1, LoopOut looped = LoopOut::None, 32 | InterpolationType interpolationType = InterpolationType::Bezier) 33 | : Animation(duration, looped, interpolationType), _targetPoint(p), _object(object) { 34 | } 35 | }; 36 | 37 | #endif //ANIMATION_TRANSLATETOPOINT_H 38 | -------------------------------------------------------------------------------- /engine/animation/Wait.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_WAIT_H 2 | #define ANIMATION_WAIT_H 3 | 4 | #include 5 | 6 | class Wait final : public Animation { 7 | private: 8 | void update() override {} 9 | 10 | public: 11 | explicit Wait(double duration = 1) : Animation(duration, LoopOut::None, InterpolationType::Linear, true) { 12 | } 13 | }; 14 | 15 | #endif //ANIMATION_WAIT_H 16 | -------------------------------------------------------------------------------- /engine/components/Component.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPONENTS_COMPONENT_H 2 | #define COMPONENTS_COMPONENT_H 3 | 4 | #include 5 | 6 | class Component { 7 | private: 8 | Object* _object = nullptr; // Reference to the parent Object that owns this Component 9 | 10 | public: 11 | Component() = default; 12 | Component(const Component& component) = default; 13 | 14 | virtual void start() {}; 15 | virtual void update(double deltaTime) {}; 16 | virtual void fixedUpdate(double deltaTime) {}; 17 | 18 | template 19 | [[nodiscard]] std::shared_ptr getComponent() const { 20 | if (_object) { 21 | return _object->getComponent(); 22 | } 23 | return nullptr; 24 | } 25 | 26 | template 27 | [[nodiscard]] bool hasComponent() const { 28 | if (_object) { 29 | return _object->hasComponent(); 30 | } 31 | return false; 32 | } 33 | 34 | template 35 | std::shared_ptr addComponent(Args&&... args) { 36 | if (_object) { 37 | return _object->addComponent(std::forward(args)...); 38 | } 39 | return nullptr; 40 | } 41 | 42 | void assignTo(Object* object) { _object = object; } 43 | [[nodiscard]] Object* assignedToPtr() const { return _object; } 44 | [[nodiscard]] std::shared_ptr assignedToShared() const { return _object->sharedPtr(); } 45 | 46 | [[nodiscard]] virtual std::shared_ptr copy() const { 47 | return std::make_shared(*this); 48 | } 49 | 50 | virtual ~Component() = default; 51 | }; 52 | 53 | #endif //COMPONENTS_COMPONENT_H 54 | -------------------------------------------------------------------------------- /engine/components/TransformMatrix.cpp: -------------------------------------------------------------------------------- 1 | #include "TransformMatrix.h" 2 | 3 | void TransformMatrix::transform(const Matrix4x4 &t) { 4 | _transformMatrix = t * _transformMatrix; 5 | } 6 | 7 | void TransformMatrix::transformRelativePoint(const Vec3D &point, const Matrix4x4 &transform) { 8 | // translate object in the new coordinate system (connected with point) 9 | _transformMatrix = Matrix4x4::Translation( -point) * _transformMatrix; 10 | // transform object in the new coordinate system 11 | _transformMatrix = transform * _transformMatrix; 12 | // translate object back in self connected coordinate system 13 | _transformMatrix = Matrix4x4::Translation(point) * _transformMatrix; 14 | } 15 | 16 | void TransformMatrix::translate(const Vec3D &dv) { 17 | transform(Matrix4x4::Translation(dv)); 18 | } 19 | 20 | void TransformMatrix::scale(const Vec3D &s) { 21 | transform(Matrix4x4::Scale(s)); 22 | } 23 | 24 | void TransformMatrix::scaleInside(const Vec3D &s) { 25 | // Scale relative to the internal coordinate system 26 | transform(_transformMatrix*Matrix4x4::Scale(s)*Matrix4x4::View(_transformMatrix)); 27 | } 28 | 29 | void TransformMatrix::rotate(const Vec3D &r) { 30 | _angle = _angle + r; 31 | 32 | Matrix4x4 rotationMatrix = Matrix4x4::RotationX(r.x()) * Matrix4x4::RotationY(r.y()) * Matrix4x4::RotationZ(r.z()); 33 | transform(rotationMatrix); 34 | } 35 | 36 | void TransformMatrix::rotate(const Vec3D &v, double rv) { 37 | transform(Matrix4x4::Rotation(v, rv)); 38 | } 39 | 40 | void TransformMatrix::rotateRelativePoint(const Vec3D &s, const Vec3D &r) { 41 | _angle = _angle + r; 42 | 43 | transformRelativePoint(s, Matrix4x4::Rotation(r)); 44 | } 45 | 46 | void TransformMatrix::rotateRelativePoint(const Vec3D &s, const Vec3D &v, double r) { 47 | transformRelativePoint(s, Matrix4x4::Rotation(v, r)); 48 | } 49 | 50 | void TransformMatrix::rotateRelativeItself(const Vec3D &r) { 51 | rotateRelativePoint(position(), r); 52 | } 53 | 54 | void TransformMatrix::rotateRelativeItself(const Vec3D &v, double r) { 55 | rotateRelativePoint(position(), v, r); 56 | } 57 | 58 | void TransformMatrix::rotateLeft(double rl) { 59 | _angleLeftUpLookAt = Vec3D{_angleLeftUpLookAt.x() + rl, 60 | _angleLeftUpLookAt.y(), 61 | _angleLeftUpLookAt.z()}; 62 | 63 | transformRelativePoint(_transformMatrix.w(), Matrix4x4::Rotation(left(), rl)); 64 | } 65 | 66 | void TransformMatrix::rotateUp(double ru) { 67 | _angleLeftUpLookAt = Vec3D{_angleLeftUpLookAt.x(), 68 | _angleLeftUpLookAt.y() + ru, 69 | _angleLeftUpLookAt.z()}; 70 | 71 | transformRelativePoint(_transformMatrix.w(), Matrix4x4::Rotation(up(), ru)); 72 | } 73 | 74 | void TransformMatrix::rotateLookAt(double rlAt) { 75 | _angleLeftUpLookAt = Vec3D{_angleLeftUpLookAt.x(), 76 | _angleLeftUpLookAt.y(), 77 | _angleLeftUpLookAt.z() + rlAt}; 78 | 79 | transformRelativePoint(_transformMatrix.w(), Matrix4x4::Rotation(lookAt(), rlAt)); 80 | } 81 | 82 | void TransformMatrix::translateToPoint(const Vec3D &point) { 83 | translate(point - position()); 84 | } 85 | 86 | void TransformMatrix::attractToPoint(const Vec3D &point, double value) { 87 | Vec3D v = (point - position()).normalized(); 88 | translate(v*value); 89 | } 90 | 91 | void TransformMatrix::rotateToAngle(const Vec3D &v) { 92 | rotate(v - _angle); 93 | } 94 | 95 | Matrix4x4 TransformMatrix::model() const { 96 | return _transformMatrix; 97 | } 98 | 99 | Matrix4x4 TransformMatrix::fullModel() const { 100 | if(!assignedToPtr() || !assignedToPtr()->attachedTo()) { 101 | return model(); 102 | } 103 | 104 | auto attachedToTransformC = assignedToPtr()->attachedTo()->getComponent(); 105 | if(!attachedToTransformC) { 106 | return model(); 107 | } 108 | 109 | return attachedToTransformC->fullModel()*model(); 110 | } 111 | -------------------------------------------------------------------------------- /engine/components/TransformMatrix.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPONENTS_TRANSFORMMATRIX_H 2 | #define COMPONENTS_TRANSFORMMATRIX_H 3 | 4 | #include 5 | #include 6 | 7 | class TransformMatrix : public Component { 8 | private: 9 | Matrix4x4 _transformMatrix = Matrix4x4::Identity(); 10 | /* 11 | * Take into account that when you rotate a body, 12 | * you change '_angle' & '_angleLeftUpLookAt' only for this particular body, 13 | * not for attached objects! Therefore, during rotations 14 | * '_angle' & '_angleLeftUpLookAt' stays constant for all attached objects. 15 | */ 16 | Vec3D _angle{0, 0, 0}; 17 | Vec3D _angleLeftUpLookAt{0, 0, 0}; 18 | public: 19 | TransformMatrix() = default; 20 | TransformMatrix(const TransformMatrix& transformMatrix) = default; 21 | 22 | void transform(const Matrix4x4 &t); 23 | void undoTransformations() { transform(invModel()); } 24 | void transformRelativePoint(const Vec3D &point, const Matrix4x4 &transform); 25 | void translate(const Vec3D &dv); 26 | void translateToPoint(const Vec3D &point); 27 | void attractToPoint(const Vec3D &point, double value); 28 | void scale(const Vec3D &s); 29 | void scaleInside(const Vec3D &s); 30 | void rotate(const Vec3D &r); 31 | void rotate(const Vec3D &v, double rv); 32 | void rotateToAngle(const Vec3D &v); 33 | void rotateRelativePoint(const Vec3D &s, const Vec3D &r); 34 | void rotateRelativePoint(const Vec3D &s, const Vec3D &v, double r); 35 | void rotateRelativeItself(const Vec3D &r); 36 | void rotateRelativeItself(const Vec3D &v, double r); 37 | void rotateLeft(double rl); 38 | void rotateUp(double ru); 39 | void rotateLookAt(double rlAt); 40 | 41 | [[nodiscard]] Vec3D left() const { return _transformMatrix.x().normalized(); } 42 | [[nodiscard]] Vec3D up() const { return _transformMatrix.y().normalized(); } 43 | [[nodiscard]] Vec3D lookAt() const { return _transformMatrix.z().normalized(); } 44 | [[nodiscard]] Vec3D position() const { return _transformMatrix.w(); } 45 | [[nodiscard]] Vec3D fullPosition() const { return fullModel().w(); } 46 | [[nodiscard]] Vec3D angle() const { return _angle; } 47 | [[nodiscard]] Vec3D angleLeftUpLookAt() const { return _angleLeftUpLookAt; } 48 | 49 | // model() returns the transform matrix of this object 50 | [[nodiscard]] Matrix4x4 model() const; 51 | /* 52 | * fullModel() returns the chain of transform matrices: 53 | * _attachedTo full transform matrix * (current transform matrix) 54 | */ 55 | [[nodiscard]] Matrix4x4 fullModel() const; 56 | 57 | /* 58 | * invModel() and fullInvModel() are fast methods to calculate the inverse. 59 | * When columns of the model() matrix are perpendicular to each other 60 | * invModel() will return the result of fast inverse. 61 | * Otherwise, it will calculate the full inverse (computationally less efficient). 62 | */ 63 | [[nodiscard]] Matrix4x4 invModel() const { return Matrix4x4::View(model()); } 64 | [[nodiscard]] Matrix4x4 fullInvModel() const { return Matrix4x4::View(fullModel()); } 65 | 66 | [[nodiscard]] std::shared_ptr copy() const override { 67 | return std::make_shared(*this); 68 | } 69 | }; 70 | 71 | 72 | #endif //COMPONENTS_TRANSFORMMATRIX_H 73 | -------------------------------------------------------------------------------- /engine/components/geometry/Bounds.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Neiro on 28.2.2024. 3 | // 4 | 5 | #ifndef GEOMETRY_BOUNDS_H 6 | #define GEOMETRY_BOUNDS_H 7 | 8 | #include "linalg/Matrix4x4.h" 9 | 10 | struct Bounds { 11 | Vec3D center; 12 | Vec3D extents; 13 | 14 | [[nodiscard]] inline Bounds operator*(const Matrix4x4 &matrix4X4) const { 15 | Vec3D newCenter = Vec3D(matrix4X4 * center.makePoint4D()); 16 | Vec3D left = matrix4X4.x() * extents.x(); 17 | Vec3D up = matrix4X4.y() * extents.y(); 18 | Vec3D forward = matrix4X4.z() * extents.z(); 19 | Vec3D newExtents( 20 | std::abs(left.x()) + std::abs(up.x()) + std::abs(forward.x()), 21 | std::abs(left.y()) + std::abs(up.y()) + std::abs(forward.y()), 22 | std::abs(left.z()) + std::abs(up.z()) + std::abs(forward.z()) 23 | ); 24 | 25 | return {newCenter, newExtents}; 26 | } 27 | }; 28 | 29 | #endif //GEOMETRY_BOUNDS_H 30 | -------------------------------------------------------------------------------- /engine/components/geometry/Line.h: -------------------------------------------------------------------------------- 1 | #ifndef GEOMETRY_LINE_H 2 | #define GEOMETRY_LINE_H 3 | 4 | 5 | #include "linalg/Vec4D.h" 6 | #include "linalg/Vec3D.h" 7 | #include "linalg/Vec2D.h" 8 | #include "linalg/Matrix4x4.h" 9 | #include "Consts.h" 10 | 11 | 12 | class Line final { 13 | private: 14 | Vec4D _p1 = Vec4D(0, 0, 0, 1); 15 | Vec4D _p2 = Vec4D(0, 0, 0, 1); 16 | public: 17 | Line() = default; 18 | 19 | Line(const Line &line) = default; 20 | 21 | Line(const Vec4D& p1, const Vec4D& p2) : _p1(p1), _p2(p2) {}; 22 | 23 | Line &operator=(const Line &) = default; 24 | [[nodiscard]] inline Vec3D center() const { return Vec3D(_p1 + _p2)/3; } 25 | 26 | // Operations with Matrix4x4 27 | [[nodiscard]] inline Line operator*(const Matrix4x4 &matrix4X4) const { return {matrix4X4*_p1, matrix4X4*_p2}; }; 28 | 29 | [[nodiscard]] inline double distance(const Vec3D &vec) const { return (center() - vec).abs(); } 30 | 31 | [[nodiscard]] inline Vec4D p1() const { return _p1; } 32 | [[nodiscard]] inline Vec4D p2() const { return _p2; } 33 | }; 34 | 35 | #endif //GEOMETRY_LINE_H 36 | -------------------------------------------------------------------------------- /engine/components/geometry/LineMesh.cpp: -------------------------------------------------------------------------------- 1 | #include "LineMesh.h" 2 | 3 | LineMesh &LineMesh::operator*=(const Matrix4x4 &matrix4X4) { 4 | std::vector newLines; 5 | newLines.reserve(_lines.size()); 6 | for (auto &line : _lines) { 7 | newLines.emplace_back(line*matrix4X4); 8 | } 9 | setLines(std::move(newLines)); 10 | 11 | return *this; 12 | } 13 | 14 | void LineMesh::copyLines(const LineMesh &lineMesh, bool deepCopy) { 15 | if(deepCopy) { 16 | _lines.reserve(lineMesh._lines.size()); 17 | for (const auto& tr : lineMesh._lines) { 18 | _lines.push_back(tr); 19 | } 20 | } else { 21 | _lines = lineMesh._lines; 22 | } 23 | _bounds = lineMesh._bounds; 24 | } 25 | 26 | void LineMesh::calculateBounds() { 27 | Vec3D min = _lines.empty() ? Vec3D() : Vec3D(_lines[0].p1()); 28 | Vec3D max = min; 29 | for (const auto & line : _lines) { 30 | for (int j = 0; j < 3; j++) { 31 | min[j] = std::min({min[j], line.p1()[j], line.p2()[j]}); 32 | max[j] = std::max({max[j], line.p1()[j], line.p2()[j]}); 33 | } 34 | } 35 | _bounds = Bounds { 36 | .center = (max + min) / 2, 37 | .extents = (max - min) / 2 38 | }; 39 | } 40 | 41 | LineMesh::LineMesh(const LineMesh &lineMesh, bool deepCopy): 42 | Component(lineMesh), _color(lineMesh._color), _visible(lineMesh._visible) { 43 | copyLines(lineMesh, deepCopy); 44 | } 45 | 46 | LineMesh::LineMesh(const std::vector &lines, 47 | const Color& color): _lines(lines), _color(color) { 48 | calculateBounds(); 49 | } 50 | 51 | void LineMesh::setLines(std::vector &&lines) { 52 | _lines = std::move(lines); 53 | calculateBounds(); 54 | } 55 | 56 | LineMesh LineMesh::Cube(double size) { 57 | LineMesh cube; 58 | 59 | cube.setLines(std::move(std::vector{ 60 | {Vec4D{-0.5, -0.5, -0.5, 1}, Vec4D{-0.5, 0.5, -0.5, 1}}, 61 | {Vec4D{-0.5, 0.5, -0.5, 1}, Vec4D{0.5, 0.5, -0.5, 1}}, 62 | {Vec4D{0.5, 0.5, -0.5, 1}, Vec4D{0.5, -0.5, -0.5, 1}}, 63 | {Vec4D{0.5, -0.5, -0.5, 1}, Vec4D{-0.5, -0.5, -0.5, 1}}, 64 | 65 | {Vec4D{-0.5, -0.5, -0.5, 1},Vec4D{-0.5, -0.5, 0.5, 1}}, 66 | {Vec4D{-0.5, 0.5, -0.5, 1}, Vec4D{-0.5, 0.5, 0.5, 1}}, 67 | {Vec4D{0.5, 0.5, -0.5, 1}, Vec4D{0.5, 0.5, 0.5, 1}}, 68 | {Vec4D{0.5, -0.5, -0.5, 1}, Vec4D{0.5, -0.5, 0.5, 1}}, 69 | 70 | {Vec4D{-0.5, -0.5, 0.5, 1}, Vec4D{-0.5, 0.5, 0.5, 1}}, 71 | {Vec4D{-0.5, 0.5, 0.5, 1}, Vec4D{0.5, 0.5, 0.5, 1}}, 72 | {Vec4D{0.5, 0.5, 0.5, 1}, Vec4D{0.5, -0.5, 0.5, 1}}, 73 | {Vec4D{0.5, -0.5, 0.5, 1}, Vec4D{-0.5, -0.5, 0.5, 1}}, 74 | })); 75 | 76 | return cube *= Matrix4x4::Scale(Vec3D(size, size, size)); 77 | } 78 | 79 | LineMesh LineMesh::BoundsFrame(const struct Bounds& bounds) { 80 | LineMesh result = LineMesh::Cube(); 81 | result *= Matrix4x4::Translation(bounds.center)*Matrix4x4::Scale(bounds.extents*2); 82 | return result; 83 | } 84 | 85 | void LineMesh::start() { 86 | if (!hasComponent()) { 87 | // This component requires to work with TransformMatrix component, 88 | addComponent(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /engine/components/geometry/LineMesh.h: -------------------------------------------------------------------------------- 1 | #ifndef GEOMETRY_LINEMESH_H 2 | #define GEOMETRY_LINEMESH_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class LineMesh : public Component { 10 | private: 11 | std::vector _lines; 12 | Color _color; 13 | Bounds _bounds; 14 | 15 | bool _visible = true; 16 | 17 | void copyLines(const LineMesh& lineMesh, bool deepCopy); 18 | void calculateBounds(); 19 | public: 20 | LineMesh() = default; 21 | 22 | LineMesh &operator=(const LineMesh &lineMesh) = delete; 23 | LineMesh(const LineMesh &lineMesh, bool deepCopy = false); 24 | 25 | explicit LineMesh(const std::vector &lines, const Color& color = Color::BLACK); 26 | 27 | [[nodiscard]] std::vector const &lines() const { return _lines; } 28 | 29 | LineMesh &operator*=(const Matrix4x4 &matrix4X4); 30 | void setLines(std::vector&& lines); 31 | 32 | [[nodiscard]] size_t size() const { return _lines.size() * 2; } 33 | 34 | [[nodiscard]] Color getColor() const { return _color; } 35 | void setColor(const Color& color) { _color = color; } 36 | 37 | [[nodiscard]] const Bounds& bounds() const { return _bounds; } 38 | 39 | void setVisible(bool visibility) { _visible = visibility; } 40 | 41 | [[nodiscard]] bool isVisible() const { return _visible; } 42 | 43 | LineMesh static Cube(double size = 1.0); 44 | LineMesh static BoundsFrame(const Bounds& bounds); 45 | 46 | [[nodiscard]] std::shared_ptr copy() const override { 47 | return std::make_shared(*this); 48 | } 49 | 50 | void start() override; 51 | }; 52 | 53 | 54 | #endif //INC_3DZAVR_LINEMESH_H 55 | -------------------------------------------------------------------------------- /engine/components/geometry/Plane.cpp: -------------------------------------------------------------------------------- 1 | #include "Plane.h" 2 | 3 | Plane::Plane() : normal(1), offset() {} 4 | 5 | Plane::Plane(const Triangle &tri) : normal(tri.norm()), offset(tri.norm().dot(Vec3D(tri[0]))) {} 6 | 7 | Plane::Plane(const Vec3D &normal, const Vec3D &point) : normal(normal.normalized()), offset(normal.normalized().dot(point)) {} 8 | 9 | Plane::Plane(const Vec3D &normal, double offset) : normal(normal.normalized()), offset(offset) {} 10 | 11 | double Plane::distance(const Vec3D &v) const { 12 | return v.dot(normal) - offset; 13 | } 14 | 15 | void Plane::clip(std::vector>& input, std::vector>& output) const { 16 | if (input.empty()) return; 17 | auto prev = input.back(); 18 | double prevDistance = distance(prev.first); 19 | for (auto &curr : input) { 20 | double currDistance = distance(curr.first); 21 | 22 | if (currDistance >= 0) { 23 | if (prevDistance < 0) { 24 | auto p = intersect(prev.first, curr.first); 25 | output.emplace_back(p.pointOfIntersection, prev.second + (curr.second - prev.second) * p.k); 26 | } 27 | output.emplace_back(curr); 28 | } else if (prevDistance >= 0) { 29 | auto p = intersect(prev.first, curr.first); 30 | output.emplace_back(p.pointOfIntersection, prev.second + (curr.second - prev.second) * p.k); 31 | } 32 | prev = curr; 33 | prevDistance = currDistance; 34 | } 35 | } 36 | 37 | Plane::IntersectionInformation Plane::intersect(const Vec3D &from, const Vec3D &to) const { 38 | double s_dot_n = from.dot(normal); 39 | double k = std::numeric_limits::infinity(); 40 | 41 | double den = s_dot_n - to.dot(normal); 42 | bool intersected = false; 43 | if(std::abs(den) > Consts::EPS) { 44 | k = (s_dot_n - offset) / den; 45 | intersected = k > 0; 46 | } 47 | 48 | Vec3D v = from + (to - from) * k; 49 | double distance = (v - from).abs(); 50 | 51 | return Plane::IntersectionInformation{v, distance, k, intersected}; 52 | } 53 | 54 | Line Plane::clip(const Line &line, bool& isFullyOutside) const { 55 | double distances[2] = {distance(Vec3D(line.p1())), 56 | distance(Vec3D(line.p2()))}; 57 | 58 | isFullyOutside = false; 59 | if((distances[0] < 0) && (distances[1] < 0)) { 60 | // In this case the line is fully outside the clipping plane 61 | isFullyOutside = true; 62 | return {}; 63 | } 64 | if((distances[0] >= 0) && (distances[1] >= 0)) { 65 | // In this case the line is fully inside the clipping plane 66 | return line; 67 | } 68 | if((distances[0] < 0) && (distances[1] >= 0)) { 69 | // The first point is outside 70 | auto intersection = intersect(Vec3D(line.p1()), Vec3D(line.p2())); 71 | return {intersection.pointOfIntersection.makePoint4D(), line.p2()}; 72 | } 73 | if((distances[0] >= 0) && (distances[1] < 0)) { 74 | // The second point is outside 75 | auto intersection = intersect(Vec3D(line.p1()), Vec3D(line.p2())); 76 | return {line.p1(), intersection.pointOfIntersection.makePoint4D()}; 77 | } 78 | 79 | return {}; 80 | } 81 | -------------------------------------------------------------------------------- /engine/components/geometry/Plane.h: -------------------------------------------------------------------------------- 1 | #ifndef GEOMETRY_PLANE_H 2 | #define GEOMETRY_PLANE_H 3 | 4 | #include 5 | 6 | #include "linalg/Vec4D.h" 7 | #include "objects/Object.h" 8 | #include "utils/stack_vector.h" 9 | #include "Triangle.h" 10 | #include "Line.h" 11 | 12 | 13 | class Plane final { 14 | private: 15 | struct IntersectionInformation final { 16 | Vec3D pointOfIntersection; 17 | double distanceToObject = std::numeric_limits::infinity(); 18 | double k = 0; 19 | bool intersected = false; 20 | }; 21 | public: 22 | Vec3D normal; 23 | double offset; 24 | 25 | Plane(); 26 | Plane(const Plane &plane) = default; 27 | 28 | // You can define plane by defining the points in 3D space 29 | explicit Plane(const Triangle &tri); 30 | 31 | // Or by defining normal vector and one val laying on the plane 32 | Plane(const Vec3D &normal, const Vec3D &point); 33 | Plane(const Vec3D &normal, double offset); 34 | 35 | Plane& operator=(const Plane &plane) = default; 36 | 37 | [[nodiscard]] double distance(const Vec3D &point4D) const; 38 | [[nodiscard]] IntersectionInformation intersect(const Vec3D &from, const Vec3D &to) const; 39 | void clip(std::vector>& input, std::vector>& output) const; 40 | [[nodiscard]] Line clip(const Line& line, bool& isFullyOutside) const; 41 | }; 42 | 43 | 44 | #endif //GEOMETRY_PLANE_H 45 | -------------------------------------------------------------------------------- /engine/components/geometry/Triangle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | Triangle::Triangle(const std::array& p, const std::array& uv) : 6 | _points{p}, _textureCoordinates(uv) { 7 | calculateNormal(); 8 | } 9 | 10 | void Triangle::calculateNormal() { 11 | auto v1 = Vec3D(_points[1] - _points[0]); 12 | auto v2 = Vec3D(_points[2] - _points[0]); 13 | Vec3D crossProduct = v1.cross(v2); 14 | 15 | if (crossProduct.sqrAbs() > Consts::EPS) { 16 | _normal = crossProduct.normalized(); 17 | } else { 18 | _normal = Vec3D(0); 19 | } 20 | } 21 | 22 | Triangle Triangle::operator*(const Matrix4x4 &matrix4X4) const { 23 | return Triangle{{matrix4X4 * _points[0], matrix4X4 * _points[1], matrix4X4 * _points[2]}, _textureCoordinates}; 24 | } 25 | 26 | Triangle::IntersectionInformation Triangle::intersect(const Vec3D &from, const Vec3D &to) const { 27 | // Möller, T. and Trumbore, B., 2005. Fast, minimum storage ray/triangle intersection. In ACM SIGGRAPH 2005 Courses (pp. 7-es). 28 | 29 | Vec3D pointOfIntersection; 30 | double a = 0; 31 | double b = 0; 32 | double distanceToTriangle = std::numeric_limits::infinity(); 33 | bool intersected = false; 34 | 35 | Vec3D ab = Vec3D(_points[1] - _points[0]); // E1 = v1 - v0 36 | Vec3D ac = Vec3D(_points[2] - _points[0]); // E2 = v2 - v0 37 | Vec3D ap = from - Vec3D(_points[0]); // T = O - v0 38 | Vec3D d = (to-from).normalized(); // D 39 | 40 | Vec3D P = d.cross(ac); 41 | Vec3D Q = ap.cross(ab); 42 | double dot = P.dot(ab); 43 | 44 | if(std::abs(dot) > Consts::EPS) { 45 | a = P.dot(ap) / dot; 46 | b = Q.dot(d) / dot; 47 | 48 | if((a >= 0) && (b >= 0) && (a + b <= 1)) { 49 | intersected = true; 50 | distanceToTriangle = Q.dot(ac) / dot; 51 | pointOfIntersection = from + d*distanceToTriangle; 52 | } 53 | } 54 | 55 | return {pointOfIntersection, Vec3D(a, b, 1-a-b), distanceToTriangle, intersected}; 56 | } 57 | 58 | Vec3D Triangle::abgBarycCoord(const Vec2D& point) const { 59 | Vec2D ab = Vec2D(_points[1]) - Vec2D(_points[0]); 60 | Vec2D ac = Vec2D(_points[2]) - Vec2D(_points[0]); 61 | Vec2D ap = point - Vec2D(_points[0]); 62 | 63 | bool swapped = std::abs(ac.y()) < std::abs(ab.y()); 64 | if (swapped) { 65 | std::swap(ab, ac); 66 | } 67 | 68 | double betta = (ap.y() * ac.x() - ap.x() * ac.y()) / 69 | (ab.y() * ac.x() - ab.x() * ac.y()); 70 | double gamma = (ap.y() - betta * ab.y()) / ac.y(); 71 | double alpha = 1.0 - betta - gamma; 72 | 73 | if (swapped) { 74 | std::swap(betta, gamma); 75 | } 76 | 77 | return Vec3D{alpha, betta, gamma}; 78 | } 79 | 80 | Vec3D Triangle::abgBarycCoord(const Vec3D &point) const { 81 | Vec3D ab = Vec3D(_points[1]) - Vec3D(_points[0]); 82 | Vec3D ac = Vec3D(_points[2]) - Vec3D(_points[0]); 83 | Vec3D ap = point - Vec3D(_points[0]); 84 | 85 | double len_ab = ab.abs(); 86 | double len_ac = ac.abs(); 87 | 88 | // Firstly we handle cases when the triangle is degenerate 89 | 90 | if(len_ab < Consts::EPS && len_ac < Consts::EPS) { // Triangle - is a single point 91 | return Vec3D{1.0, 0, 0}; 92 | } 93 | 94 | if(len_ab < Consts::EPS) { // |AB| = 0 95 | double projection = (ap.dot(ac) / (len_ac * len_ac)); 96 | return Vec3D{1.0 - projection, 0.0, projection}; 97 | } 98 | 99 | if(len_ac < Consts::EPS) { // |AC| = 0 100 | double projection = (ap.dot(ab) / (len_ab * len_ab)); 101 | return Vec3D{1.0 - projection, projection, 0.0}; 102 | } 103 | 104 | Matrix3x3 system((Vec3D(_points[0])), 105 | Vec3D(_points[1]), 106 | Vec3D(_points[2])); 107 | 108 | return system.inverse()*point; 109 | } 110 | -------------------------------------------------------------------------------- /engine/components/geometry/Triangle.h: -------------------------------------------------------------------------------- 1 | #ifndef GEOMETRY_TRIANGLE_H 2 | #define GEOMETRY_TRIANGLE_H 3 | 4 | #include "linalg/Vec4D.h" 5 | #include "linalg/Vec3D.h" 6 | #include "linalg/Matrix4x4.h" 7 | #include "Consts.h" 8 | 9 | 10 | class Triangle final { 11 | private: 12 | struct IntersectionInformation final { 13 | Vec3D pointOfIntersection; 14 | Vec3D abg; 15 | double distanceToTriangle = std::numeric_limits::infinity(); 16 | bool intersected = false; 17 | }; 18 | 19 | std::array _points; 20 | /* 21 | * Texture coordinates are in 3D because we need to work with its 3th component 22 | * during de-homogenization procedure for correct perspective projection (see Screen::drawTriangle() for example) 23 | */ 24 | std::array _textureCoordinates; 25 | 26 | Vec3D _normal; 27 | 28 | void calculateNormal(); 29 | public: 30 | Triangle() = default; 31 | 32 | Triangle(const Triangle &triangle) = default; 33 | 34 | Triangle(const std::array& p, const std::array& uv = {Vec3D{0, 0, 1}, 35 | Vec3D{0, 0, 1}, 36 | Vec3D{0, 0, 1}}); 37 | 38 | Triangle &operator=(const Triangle &) = default; 39 | [[nodiscard]] inline const Vec4D& operator[](int i) const { return _points[i]; } 40 | [[nodiscard]] inline Vec3D centroid() const { return Vec3D(_points[0] + _points[1] + _points[2])/3; } 41 | [[nodiscard]] inline Vec3D norm() const { return _normal; } 42 | 43 | // Operations with Matrix4x4 44 | [[nodiscard]] Triangle operator*(const Matrix4x4 &matrix4X4) const; 45 | 46 | [[nodiscard]] IntersectionInformation intersect(const Vec3D &from, const Vec3D &to) const; 47 | 48 | [[nodiscard]] inline const std::array& points() const {return _points; } 49 | [[nodiscard]] inline const std::array& textureCoordinates() const { return _textureCoordinates; } 50 | [[nodiscard]] double distance(const Vec3D &vec) const { return norm().dot(Vec3D(_points[0]) - vec); } 51 | [[nodiscard]] Vec3D abgBarycCoord(const Vec2D& point) const; 52 | [[nodiscard]] Vec3D abgBarycCoord(const Vec3D& point) const; 53 | }; 54 | 55 | 56 | #endif //GEOMETRY_TRIANGLE_H 57 | -------------------------------------------------------------------------------- /engine/components/geometry/TriangleMesh.h: -------------------------------------------------------------------------------- 1 | #ifndef GEOMETRY_MESH_H 2 | #define GEOMETRY_MESH_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class TriangleMesh : public Component, public std::enable_shared_from_this { 13 | public: 14 | struct IntersectionInformation final { 15 | Vec3D pointOfIntersection; 16 | Vec3D normal; 17 | double distanceToObject = std::numeric_limits::infinity(); 18 | std::shared_ptr triangleMesh = nullptr; 19 | bool intersected = false; 20 | Triangle triangle{}; 21 | }; 22 | private: 23 | std::vector _tris; 24 | std::shared_ptr _material = Consts::DEFAULT_MATERIAL; 25 | Bounds _bounds; 26 | 27 | bool _visible = true; 28 | 29 | void copyTriangles(const TriangleMesh& mesh, bool deepCopy); 30 | void calculateBounds(); 31 | 32 | public: 33 | TriangleMesh() = default; 34 | 35 | TriangleMesh &operator=(const TriangleMesh &mesh) = delete; 36 | TriangleMesh(const TriangleMesh &mesh, bool deepCopy = false); 37 | 38 | explicit TriangleMesh(const std::vector &tries, const std::shared_ptr& material = Consts::DEFAULT_MATERIAL); 39 | 40 | [[nodiscard]] std::vector const &triangles() const { return _tris; } 41 | 42 | TriangleMesh &operator*=(const Matrix4x4 &matrix4X4); 43 | void setTriangles(std::vector&& t); 44 | void setTriangles(const std::vector& t); 45 | 46 | [[nodiscard]] size_t size() const { return _tris.size() * 3; } 47 | 48 | [[nodiscard]] std::shared_ptr getMaterial() const { return _material; } 49 | void setMaterial(std::shared_ptr material) { _material = std::move(material); } 50 | 51 | [[nodiscard]] const Bounds& bounds() const { return _bounds; } 52 | 53 | void setVisible(bool visibility) { _visible = visibility; } 54 | 55 | [[nodiscard]] bool isVisible() const { return _visible; } 56 | 57 | [[nodiscard]] IntersectionInformation intersect(const Vec3D &from, const Vec3D &to); 58 | 59 | TriangleMesh static Surface(double width, double height, const std::shared_ptr& material = nullptr); 60 | TriangleMesh static Cube(double size = 1.0); 61 | TriangleMesh static LineTo(const Vec3D &from, const Vec3D &to, double line_width = 0.1); 62 | TriangleMesh static ArrowTo(const Vec3D& from, const Vec3D& to, double line_width = 1); 63 | TriangleMesh static Plane(const Vec3D& normal, const Vec3D& point, double size = 3.0); 64 | TriangleMesh static Plane(const Vec3D& p1, const Vec3D& p2, const Vec3D& p3, double size = 3.0); 65 | 66 | [[nodiscard]] std::shared_ptr copy() const override { 67 | return std::make_shared(*this); 68 | } 69 | 70 | void start() override; 71 | }; 72 | 73 | #endif //GEOMETRY_MESH_H 74 | -------------------------------------------------------------------------------- /engine/components/lighting/DirectionalLight.h: -------------------------------------------------------------------------------- 1 | #ifndef LIGHTING_DIRECTIONALLIGHT_H 2 | #define LIGHTING_DIRECTIONALLIGHT_H 3 | 4 | #include "LightSource.h" 5 | 6 | class DirectionalLight final : public LightSource { 7 | private: 8 | Vec3D _dir; 9 | public: 10 | explicit DirectionalLight(const Vec3D& direction, const Color& color = Color::WHITE, double intensity = 1.0): 11 | LightSource(color, intensity), _dir(direction.normalized()) {}; 12 | DirectionalLight(const DirectionalLight& directionalLight) = default; 13 | 14 | [[nodiscard]] inline Vec3D direction() const { return getComponent()->fullModel()*_dir; }; 15 | 16 | [[nodiscard]] Color illuminate(const Vec3D& pixelNorm, const Vec3D& pixelPosition, double simplCoef) const override { 17 | auto dot = -std::clamp(pixelNorm.dot(direction()), -1, -0.3); 18 | 19 | // linear interpolation between exact and inexact (with dot = 0.5) 20 | dot = dot + (0.5 - dot)*simplCoef; 21 | 22 | return Color(std::clamp(dot*color().r()*intensity(), 0, 255), 23 | std::clamp(dot*color().g()*intensity(), 0, 255), 24 | std::clamp(dot*color().b()*intensity(), 0, 255)); 25 | } 26 | 27 | [[nodiscard]] std::shared_ptr copy() const override { 28 | return std::make_shared(*this); 29 | } 30 | 31 | 32 | }; 33 | 34 | 35 | #endif //LIGHTING_DIRECTIONALLIGHT_H 36 | -------------------------------------------------------------------------------- /engine/components/lighting/LightSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Ivan Ilin on 12/03/2024. 3 | // 4 | 5 | #ifndef LIGHTING_LIGHTSOURCE_H 6 | #define LIGHTING_LIGHTSOURCE_H 7 | 8 | #include "components/Component.h" 9 | 10 | class LightSource : public Component { 11 | protected: 12 | Color _color = Color::WHITE; 13 | double _intensity = 1.0; 14 | 15 | public: 16 | LightSource(const Color& color, double intensity): _color(color), _intensity(std::max(intensity, 0.0)) {} 17 | 18 | LightSource(const LightSource& lightSource) = default; 19 | 20 | [[nodiscard]] inline Color color() const { return _color; }; 21 | [[nodiscard]] inline double intensity() const { return _intensity; }; 22 | 23 | /* 24 | * simplCoef is in range [0, 1], where 0 means exact computation and 1 means simplified. 25 | * All values between 0 and 1 can be handled in any reasonable way 26 | * (e.g. linear interpolation between exact and simplified). 27 | */ 28 | [[nodiscard]] virtual Color illuminate(const Vec3D& pixelNorm, const Vec3D& pixelPosition, double simplCoef) const = 0; 29 | 30 | void start() override { 31 | if (!hasComponent()) { 32 | // This component requires to work with TransformMatrix component, 33 | addComponent(); 34 | } 35 | } 36 | 37 | void setIntensity(double intensity) { _intensity = intensity; } 38 | void setColor(const Color& color) { _color = color; } 39 | }; 40 | 41 | 42 | #endif //LIGHTING_LIGHTSOURCE_H 43 | -------------------------------------------------------------------------------- /engine/components/lighting/PointLight.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Ivan Ilin on 12/03/2024. 3 | // 4 | 5 | #ifndef LIGHTING_POINTLIGHT_H 6 | #define LIGHTING_POINTLIGHT_H 7 | 8 | #include "LightSource.h" 9 | 10 | class PointLight final : public LightSource { 11 | private: 12 | Vec3D _initialPos; 13 | public: 14 | explicit PointLight(const Vec3D& position, const Color& color = Color::WHITE, double intensity = 1.0): 15 | LightSource(color, intensity), _initialPos(position) {}; 16 | PointLight(const PointLight& pointLight) = default; 17 | 18 | [[nodiscard]] Color illuminate(const Vec3D& pixelNorm, const Vec3D& pixelPosition, double simplCoef) const override { 19 | auto toLight = getComponent()->fullPosition() - pixelPosition; 20 | double distance = toLight.abs(); 21 | Vec3D dir = toLight.normalized(); 22 | 23 | auto dot = std::clamp(pixelNorm.dot(dir), 0.2, 1); 24 | 25 | // linear interpolation between exact and inexact (with dot = 0.5) 26 | dot = dot + (0.5 - dot)*simplCoef; 27 | 28 | double energy = intensity()/(distance + 0.1); 29 | 30 | return Color(std::clamp(dot*color().r()*energy, 0, 255), 31 | std::clamp(dot*color().g()*energy, 0, 255), 32 | std::clamp(dot*color().b()*energy, 0, 255)); 33 | } 34 | 35 | [[nodiscard]] std::shared_ptr copy() const override { 36 | return std::make_shared(*this); 37 | } 38 | 39 | void start() override { 40 | if (!hasComponent()) { 41 | // This component requires to work with TransformMatrix component, 42 | addComponent(); 43 | } 44 | 45 | getComponent()->translate(_initialPos); 46 | } 47 | }; 48 | 49 | #endif //LIGHTING_POINTLIGHT_H 50 | -------------------------------------------------------------------------------- /engine/components/lighting/SpotLight.h: -------------------------------------------------------------------------------- 1 | #ifndef LIGHTING_SPOTLIGHT_H 2 | #define LIGHTING_SPOTLIGHT_H 3 | 4 | #include "LightSource.h" 5 | 6 | class SpotLight final : public LightSource { 7 | private: 8 | Vec3D _initialPos; 9 | Vec3D _dir; 10 | double _innerConeCos; 11 | double _outerConeCos; 12 | public: 13 | SpotLight(const Vec3D& position, const Vec3D& direction, double innerConeCos = cos(Consts::PI / 4), 14 | double outerConeCos = cos(Consts::PI / 3), const Color& color = Color::WHITE, double intensity = 1.0): 15 | LightSource(color, intensity), _dir(direction), _innerConeCos(innerConeCos), _outerConeCos(outerConeCos), _initialPos(position) {}; 16 | SpotLight(const SpotLight& spotLight) = default; 17 | 18 | [[nodiscard]] inline Vec3D direction() const { return getComponent()->fullModel()*_dir; }; 19 | 20 | [[nodiscard]] double innerConeCos() const { return _innerConeCos; } 21 | [[nodiscard]] double outerConeCos() const { return _outerConeCos; } 22 | void setInnerConeCos(double innerConeCos) { _innerConeCos = innerConeCos; } 23 | void setOuterConeCos(double outerConeCos) { _outerConeCos = outerConeCos; } 24 | 25 | [[nodiscard]] Color illuminate(const Vec3D& pixelNorm, const Vec3D& pixelPosition, double simplCoef = 0.0) const override { 26 | auto toLight = getComponent()->fullPosition() - pixelPosition; 27 | double distance = toLight.abs(); 28 | Vec3D dir = toLight.normalized(); 29 | 30 | auto dot = std::clamp(pixelNorm.dot(dir), 0.1, 1); 31 | 32 | // linear interpolation between exact and inexact (with dot = 0.5) 33 | dot = dot + (0.5 - dot)*simplCoef; 34 | 35 | double energy = intensity()/(distance + 0.1); 36 | 37 | double cosAngle = -dir.dot(direction()); 38 | if (cosAngle < _outerConeCos) { 39 | energy = 0; 40 | } 41 | if (cosAngle > _innerConeCos) { 42 | energy *= (cosAngle - _outerConeCos) / (_innerConeCos - _outerConeCos); 43 | } 44 | 45 | return Color(std::clamp(dot*color().r()*energy, 0, 255), 46 | std::clamp(dot*color().g()*energy, 0, 255), 47 | std::clamp(dot*color().b()*energy, 0, 255)); 48 | } 49 | 50 | [[nodiscard]] std::shared_ptr copy() const override { 51 | return std::make_shared(*this); 52 | } 53 | 54 | void start() override { 55 | if (!hasComponent()) { 56 | // This component requires to work with TransformMatrix component, 57 | addComponent(); 58 | } 59 | 60 | getComponent()->translate(_initialPos); 61 | } 62 | }; 63 | 64 | #endif //LIGHTING_SPOTLIGHT_H 65 | -------------------------------------------------------------------------------- /engine/components/physics/HitBox.h: -------------------------------------------------------------------------------- 1 | #ifndef PHYSICS_HITBOX_H 2 | #define PHYSICS_HITBOX_H 3 | 4 | #include "components/geometry/TriangleMesh.h" 5 | #include "components/geometry/LineMesh.h" 6 | 7 | class HitBox final { 8 | private: 9 | struct Vec3DLess { 10 | bool operator()(const Vec3D& lhs, const Vec3D& rhs) const noexcept; 11 | }; 12 | 13 | std::vector _hitBox; 14 | 15 | void generateSimpleFromTriangleMesh(const TriangleMesh &triangleMesh); 16 | void generateDetailedFromTriangleMesh(const TriangleMesh &triangleMesh); 17 | void generateSimpleFromLineMesh(const LineMesh &lineMesh); 18 | void generateDetailedFromLineMesh(const LineMesh &lineMesh); 19 | 20 | void constructFrom2Points(const Vec3D& from, const Vec3D& to); 21 | public: 22 | HitBox() = default; 23 | HitBox(const HitBox &hitBox) = default; 24 | 25 | explicit HitBox(const TriangleMesh &triangleMesh, bool useSimpleBox = true); 26 | explicit HitBox(const LineMesh &lineMesh, bool useSimpleBox = true); 27 | 28 | [[nodiscard]] size_t size() const { return _hitBox.size(); } 29 | [[nodiscard]] bool empty() const { return _hitBox.empty(); } 30 | 31 | [[nodiscard]] std::vector::iterator begin() { return _hitBox.begin(); } 32 | [[nodiscard]] std::vector::iterator end() { return _hitBox.end(); } 33 | 34 | ~HitBox(); 35 | }; 36 | 37 | 38 | #endif //PHYSICS_HITBOX_H 39 | -------------------------------------------------------------------------------- /engine/components/physics/Simplex.h: -------------------------------------------------------------------------------- 1 | #ifndef PHYSICS_SIMPLEX_H 2 | #define PHYSICS_SIMPLEX_H 3 | 4 | #include 5 | 6 | #include "linalg/Vec3D.h" 7 | 8 | enum class SimplexType { 9 | Zero, 10 | Point, 11 | Line, 12 | Triangle, 13 | Tetrahedron 14 | }; 15 | 16 | struct SupportPoint final { 17 | Vec3D p1; 18 | Vec3D p2; 19 | Vec3D support; 20 | }; 21 | 22 | struct Simplex final { 23 | private: 24 | std::list _points{}; 25 | 26 | public: 27 | Simplex() = default; 28 | 29 | Simplex(std::initializer_list list) { 30 | for (const auto &v : list) { 31 | _points.push_back(v); 32 | if (_points.size() > 4) { 33 | _points.pop_front(); 34 | } 35 | } 36 | } 37 | 38 | void push_front(const SupportPoint &point) { 39 | _points.push_front(point); 40 | if (_points.size() > 4) { 41 | _points.pop_back(); 42 | } 43 | } 44 | 45 | SupportPoint operator[](unsigned i) const { 46 | auto it = _points.begin(); 47 | for (unsigned k = 0; k < i; k++) { 48 | ++it; 49 | } 50 | return *it; 51 | 52 | } 53 | 54 | [[nodiscard]] unsigned size() const { return _points.size(); } 55 | 56 | [[nodiscard]] auto begin() const { return _points.begin(); } 57 | 58 | [[nodiscard]] auto end() const { return _points.end(); } 59 | 60 | [[nodiscard]] SimplexType type() const { return static_cast(_points.size()); } 61 | }; 62 | 63 | #endif //PHYSICS_SIMPLEX_H 64 | -------------------------------------------------------------------------------- /engine/components/props/Color.cpp: -------------------------------------------------------------------------------- 1 | #include "Color.h" 2 | 3 | const Color Color::WHITE = Color(255, 255, 255); 4 | const Color Color::BLACK = Color(0, 0, 0); 5 | const Color Color::GRAY = Color(100, 100, 100); 6 | const Color Color::WHITE_GRAY = Color(200, 200, 200); 7 | const Color Color::RED = Color(255, 0, 0); 8 | const Color Color::GREEN = Color(0, 255, 0); 9 | const Color Color::BLUE = Color(0, 0, 255); 10 | const Color Color::YELLOW = Color(255, 255, 0); 11 | const Color Color::LIGHT_YELLOW = Color(255, 255, 224); 12 | const Color Color::LIGHT_ORANGE = Color(255, 200, 170); 13 | -------------------------------------------------------------------------------- /engine/components/props/Color.h: -------------------------------------------------------------------------------- 1 | #ifndef PROPS_COLOR_H 2 | #define PROPS_COLOR_H 3 | 4 | #include 5 | #include 6 | 7 | class Color final { 8 | private: 9 | std::array _c; 10 | 11 | public: 12 | Color(const Color &other) { 13 | std::copy(other._c.begin(), other._c.end(), _c.begin()); 14 | } 15 | 16 | explicit Color(uint32_t c) : _c({ 17 | static_cast((c >> 24) & 0xFF), 18 | static_cast((c >> 16) & 0xFF), 19 | static_cast((c >> 8) & 0xFF), 20 | static_cast(c & 0xFF) 21 | }) {} 22 | 23 | explicit Color(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0, uint8_t a = 255) : _c({r, g, b, a}) {} 24 | explicit Color(const std::array &color) : _c(color) {} 25 | 26 | Color &operator=(const Color &color) = default; 27 | 28 | [[nodiscard]] inline uint8_t r() const { return _c[0]; } 29 | [[nodiscard]] inline uint8_t g() const { return _c[1]; } 30 | [[nodiscard]] inline uint8_t b() const { return _c[2]; } 31 | [[nodiscard]] inline uint8_t a() const { return _c[3]; } 32 | 33 | [[nodiscard]] inline uint8_t& operator[](std::size_t i) { return _c[i]; } 34 | [[nodiscard]] inline const uint8_t& operator[](std::size_t i) const { return _c[i]; } 35 | 36 | [[nodiscard]] inline uint32_t rgba() const { return (_c[0] << 24) | (_c[1] << 16) | (_c[2] << 8) | _c[3]; } 37 | 38 | // Operations with colors 39 | [[nodiscard]] inline bool operator==(const Color &other) const { return _c == other._c; } 40 | [[nodiscard]] inline bool operator!=(const Color &other) const { return !(*this == other); } 41 | 42 | [[nodiscard]] inline Color operator*(double alpha) const { return Color((uint8_t)(_c[0]*alpha), 43 | (uint8_t)(_c[1]*alpha), 44 | (uint8_t)(_c[2]*alpha), 45 | (uint8_t)(_c[3]*alpha)); }; 46 | [[nodiscard]] inline Color operator+(const Color &other) const { return Color(r()+other.r(), 47 | g()+other.g(), 48 | b()+other.b(), 49 | a()+other.a()); }; 50 | 51 | [[nodiscard]] inline Color blend(const Color& other) const { 52 | // default SDL blend mode: 53 | // dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) 54 | // dstA = srcA + (dstA * (1-srcA)) 55 | uint8_t ra = 255 - a(); 56 | return Color( 57 | (static_cast(r()) * a() + other.r() * ra) / 255, 58 | (static_cast(g()) * a() + other.g() * ra) / 255, 59 | (static_cast(b()) * a() + other.b() * ra) / 255, 60 | (static_cast(a()) * 255 + other.a() * ra) / 255 61 | ); 62 | } 63 | 64 | static const Color WHITE; 65 | static const Color BLACK; 66 | static const Color GRAY; 67 | static const Color WHITE_GRAY; 68 | static const Color RED; 69 | static const Color GREEN; 70 | static const Color BLUE; 71 | static const Color YELLOW; 72 | static const Color LIGHT_YELLOW; 73 | static const Color LIGHT_ORANGE; 74 | }; 75 | 76 | #endif //PROPS_COLOR_H 77 | -------------------------------------------------------------------------------- /engine/components/props/Material.cpp: -------------------------------------------------------------------------------- 1 | #include "Material.h" 2 | 3 | bool MaterialTag::contains(const MaterialTag &nameTag) const { 4 | if(_name.find(nameTag.str()) != std::string::npos) { 5 | return true; 6 | } 7 | return false; 8 | } 9 | 10 | Material::Material(const MaterialTag &tag, std::shared_ptr texture, const Color &ambient, const Color &diffuse, 11 | const Color &specular, uint8_t illum, double d): 12 | _tag(tag), _texture(texture), _ambient(ambient), 13 | _diffuse(diffuse), _specular(specular), _illum(illum), _d(d) { 14 | checkTransparent(); 15 | } 16 | 17 | void Material::setAmbient(const Color &color) { 18 | _ambient = color; 19 | checkTransparent(); 20 | } 21 | 22 | void Material::setTransparency(double d) { 23 | _d = d; 24 | checkTransparent(); 25 | } 26 | 27 | void Material::checkTransparent() { 28 | if(_texture) { 29 | _isTransparent = _texture->isTransparent() || (_d < 1.0-Consts::EPS); 30 | } else { 31 | _isTransparent = (_ambient.a() != 255) || (_d < 1.0-Consts::EPS); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /engine/components/props/Material.h: -------------------------------------------------------------------------------- 1 | #ifndef PROPS_MATERIAL_H 2 | #define PROPS_MATERIAL_H 3 | 4 | #include 5 | 6 | #include "linalg/Vec3D.h" 7 | #include "Texture.h" 8 | 9 | class MaterialTag final { 10 | private: 11 | const std::string _name; 12 | public: 13 | explicit MaterialTag(std::string name = "") : _name(std::move(name)) {} 14 | 15 | [[nodiscard]] std::string str() const { return _name; } 16 | 17 | bool operator==(const MaterialTag &tag) const { return _name == tag._name; } 18 | bool operator!=(const MaterialTag &tag) const { return _name != tag._name; } 19 | bool operator<(const MaterialTag &tag) const { return _name < tag._name; } 20 | 21 | [[nodiscard]] bool contains(const MaterialTag& tag) const; 22 | }; 23 | 24 | class Material { 25 | private: 26 | const MaterialTag _tag; 27 | std::shared_ptr _texture = nullptr; 28 | // TODO: add other maps like normal map, shadow map and eth.. 29 | // std::shared_ptr _normalMap = nullptr; 30 | // std::shared_ptr _shadowMap = nullptr; 31 | // std::shared_ptr _diffusionMap = nullptr; 32 | // ... 33 | 34 | Color _ambient, _diffuse, _specular; 35 | uint16_t _illum; 36 | double _d = 1.0; 37 | 38 | bool _isTransparent = false; 39 | 40 | void checkTransparent(); 41 | public: 42 | Material(const MaterialTag& tag, 43 | std::shared_ptr texture, 44 | const Color& ambient = Color::WHITE, 45 | const Color& diffuse = Color::WHITE, 46 | const Color& specular = Color::WHITE, 47 | uint8_t illum = 1, 48 | double d = 1); 49 | 50 | [[nodiscard]] Color ambient() const { return _ambient; } 51 | [[nodiscard]] Color diffuse() const { return _diffuse; } 52 | [[nodiscard]] Color specular() const { return _specular; } 53 | [[nodiscard]] uint8_t illum() const { return _illum; } 54 | [[nodiscard]] double d() const { return _d; } 55 | 56 | void setAmbient(const Color& color); 57 | void setTransparency(double d); 58 | 59 | [[nodiscard]] std::shared_ptr texture() const {return _texture; } 60 | 61 | [[nodiscard]] MaterialTag tag() const { return _tag; } 62 | 63 | [[nodiscard]] bool isTransparent() const {return _isTransparent; } 64 | }; 65 | 66 | 67 | #endif //PROPS_MATERIAL_H 68 | -------------------------------------------------------------------------------- /engine/components/props/Texture.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Texture.h" 4 | #include "utils/math.h" 5 | 6 | #include 7 | 8 | Texture::Texture(const FilePath &filename) : _filename(filename) { 9 | _texture.emplace_back(filename); 10 | 11 | //Check does the texture have the transparent pixels 12 | checkTransparency(); 13 | 14 | //Down sample the texture (for mini-mapping) 15 | downSample(); 16 | } 17 | 18 | Texture::Texture(Image &image) : _filename(image.fileName()) { 19 | _texture.emplace_back(std::move(image)); 20 | 21 | //Check does the texture have the transparent pixels 22 | checkTransparency(); 23 | 24 | //Down sample the texture (for mini-mapping) 25 | downSample(); 26 | } 27 | 28 | void Texture::checkTransparency() { 29 | for(int x = 0; x < width(); x++) { 30 | for(int y = 0; y < height(); y++) { 31 | auto pix = get_pixel(x, y); 32 | if(pix.a() != 255) { 33 | _isTransparent = true; 34 | return; 35 | } 36 | } 37 | } 38 | } 39 | 40 | void Texture::downSample() { 41 | while (_texture.back().width() * _texture.back().height() != 1) { 42 | _texture.emplace_back(_texture.back().downSampled()); 43 | } 44 | } 45 | 46 | Color Texture::get_pixel(uint16_t x, uint16_t y) const { 47 | return _texture.front().get_pixel(x, y); 48 | } 49 | 50 | Color Texture::get_pixel_from_UV(const Vec2D &uv) const { 51 | return _texture.front().get_pixel_from_UV(uv); 52 | } 53 | 54 | const Image& Texture::get_sample(double area) const { 55 | uint64_t limit = 1ULL << (_texture.size() - 1); 56 | uint16_t K; 57 | 58 | if (area < 2) { 59 | K = 0; 60 | } else if (area < limit) { 61 | K = static_cast(log2_u64(area)) - 1; 62 | } else { 63 | K = _texture.size() - 1; 64 | } 65 | return _texture[K]; 66 | } 67 | 68 | Color Texture::get_pixel_from_UV(const Vec2D &uv, double area) const { 69 | return get_sample(area).get_pixel_from_UV(uv); 70 | } 71 | -------------------------------------------------------------------------------- /engine/components/props/Texture.h: -------------------------------------------------------------------------------- 1 | #ifndef PROPS_TEXTURE_H 2 | #define PROPS_TEXTURE_H 3 | 4 | #include 5 | 6 | #include "io/Image.h" 7 | #include "utils/FilePath.h" 8 | 9 | class Texture { 10 | private: 11 | // For resampling purposes we store resampled versions of the image 12 | // up until 1x1 image (avg color of the whole texture) 13 | std::vector _texture; 14 | FilePath _filename; 15 | 16 | bool _isTransparent = false; 17 | 18 | void checkTransparency(); 19 | void downSample(); 20 | public: 21 | explicit Texture(const FilePath& filename); 22 | explicit Texture(Image& image); 23 | 24 | [[nodiscard]] Color get_pixel(uint16_t x, uint16_t y) const; 25 | [[nodiscard]] Color get_pixel_from_UV(const Vec2D& uv) const; 26 | 27 | // For resampling 28 | [[nodiscard]] const Image& get_sample(double area) const; 29 | [[nodiscard]] Color get_pixel_from_UV(const Vec2D& uv, double area) const; 30 | 31 | [[nodiscard]] uint16_t width() const { return _texture.front().width(); } 32 | [[nodiscard]] uint16_t height() const { return _texture.front().height(); } 33 | 34 | [[nodiscard]] bool isTransparent() const {return _isTransparent; } 35 | 36 | [[nodiscard]] FilePath fileName() const { return _filename; } 37 | }; 38 | 39 | 40 | #endif //PROPS_TEXTURE_H 41 | -------------------------------------------------------------------------------- /engine/io/Image.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_IMAGE_H 2 | #define IO_IMAGE_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class Image { 13 | public: 14 | enum CODE {SUCCESS, FILE_OPEN_ERROR, PNG_STRUCT_ERROR, INFO_STRUCT_ERROR, ERROR}; 15 | enum CLAMP_MODE {REPEAT, MIRRORED_REPEAT, CLAMP_TO_EDGE}; 16 | private: 17 | uint16_t _width; 18 | uint16_t _height; 19 | 20 | png_bytep _data = nullptr; 21 | 22 | bool _valid = false; 23 | 24 | FilePath _filename; 25 | 26 | void invalidate(); 27 | public: 28 | explicit Image(uint16_t width = Consts::STANDARD_SCREEN_WIDTH, uint16_t height = Consts::STANDARD_SCREEN_HEIGHT); 29 | explicit Image(const FilePath &filename); 30 | Image(const std::vector& pixelBuffer, uint16_t width, uint16_t height); 31 | 32 | Image(const Image& img) = delete; 33 | Image& operator=(const Image &img) = delete; 34 | 35 | Image(Image&& img) noexcept; 36 | Image& operator=(Image&& img) noexcept; 37 | 38 | [[nodiscard]] uint16_t width() const { return _width; }; 39 | [[nodiscard]] uint16_t height() const { return _height; }; 40 | [[nodiscard]] bool isValid() const { return _valid; }; 41 | 42 | void set_pixel(uint16_t x, uint16_t y, const Color& color); 43 | [[nodiscard]] Color get_pixel_unsafe(uint16_t x, uint16_t y) const; 44 | [[nodiscard]] Color get_pixel(uint16_t x, uint16_t y) const; 45 | [[nodiscard]] Color get_pixel_from_UV(const Vec2D& uv, CLAMP_MODE mode = REPEAT, bool bottomUp = true) const; 46 | [[nodiscard]] Image downSampled() const; 47 | 48 | CODE save2png(const FilePath& file_name, uint16_t bit_depth = 8); 49 | 50 | [[nodiscard]] png_bytep data() const {return _data; } 51 | 52 | [[nodiscard]] FilePath fileName() const { return _filename; } 53 | 54 | ~Image(); 55 | }; 56 | 57 | 58 | #endif //IO_IMAGE_H 59 | -------------------------------------------------------------------------------- /engine/io/Keyboard.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | Keyboard *Keyboard::_instance = nullptr; 7 | 8 | void Keyboard::init() { 9 | if(_instance) { 10 | Keyboard::free(); 11 | } 12 | 13 | _instance = new Keyboard(); 14 | 15 | Log::log("Keyboard::init(): keyboard was initialized"); 16 | } 17 | 18 | bool Keyboard::isKeyPressed(SDL_Keycode key) { 19 | if (!_instance) { 20 | return false; 21 | } 22 | 23 | auto it = _instance->_keys.find(key); 24 | 25 | if (it != _instance->_keys.end()) { 26 | return it->second; 27 | } 28 | 29 | return false; 30 | } 31 | 32 | bool Keyboard::isKeyTapped(SDL_Keycode key) { 33 | if (!_instance) { 34 | return false; 35 | } 36 | 37 | if (!Keyboard::isKeyPressed(key)) { 38 | return false; 39 | } 40 | 41 | if (_instance->_tappedKeys.count(key) == 0) { 42 | _instance->_tappedKeys.emplace(key, Time::time()); 43 | return true; 44 | } else if ((Time::time() - _instance->_tappedKeys[key]) > Consts::TAP_DELAY) { 45 | _instance->_tappedKeys[key] = Time::time(); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | void Keyboard::sendKeyboardEvent(const SDL_Event &event) { 52 | switch (event.type) { 53 | // exit if the window is closed 54 | case SDL_KEYDOWN: 55 | _instance->_keys[event.key.keysym.sym] = true; 56 | _instance->_keysDown.emplace_back(event.key.keysym.sym); 57 | break; 58 | case SDL_KEYUP: 59 | _instance->_keys[event.key.keysym.sym] = false; 60 | _instance->_keysUp.emplace_back(event.key.keysym.sym); 61 | break; 62 | case SDL_TEXTINPUT: 63 | _instance->_inputText = event.text.text; 64 | break; 65 | } 66 | } 67 | 68 | void Keyboard::free() { 69 | if(_instance) { 70 | _instance->_keys.clear(); 71 | _instance->_tappedKeys.clear(); 72 | delete _instance; 73 | 74 | _instance = nullptr; 75 | } 76 | 77 | Log::log("Keyboard::free(): keyboard was freed"); 78 | } 79 | 80 | void Keyboard::clear() { 81 | if (!_instance) { 82 | return; 83 | } 84 | 85 | _instance->_keysDown.clear(); 86 | _instance->_keysUp.clear(); 87 | _instance->_inputText.clear(); 88 | } 89 | 90 | bool Keyboard::isKeyDown() { 91 | if (!_instance) { 92 | return false; 93 | } 94 | 95 | return !_instance->_keysDown.empty(); 96 | } 97 | 98 | bool Keyboard::isKeyUp() { 99 | if (!_instance) { 100 | return false; 101 | } 102 | 103 | return !_instance->_keysUp.empty(); 104 | } 105 | 106 | std::vector Keyboard::keysDown() { 107 | if (!_instance) { 108 | return {}; 109 | } 110 | 111 | return _instance->_keysDown; 112 | } 113 | 114 | std::vector Keyboard::keysUp() { 115 | if (!_instance) { 116 | return {}; 117 | } 118 | 119 | return _instance->_keysUp; 120 | } 121 | 122 | std::string Keyboard::inputText() { 123 | if (!_instance) { 124 | return {}; 125 | } 126 | 127 | return _instance->_inputText; 128 | } 129 | -------------------------------------------------------------------------------- /engine/io/Keyboard.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_KEYBOARD_H 2 | #define IO_KEYBOARD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "SDL.h" 10 | 11 | class Keyboard final { 12 | private: 13 | std::map _keys; // 322 is the number of SDLK_DOWN events 14 | std::map _tappedKeys; 15 | std::vector _keysDown; 16 | std::vector _keysUp; 17 | std::string _inputText; 18 | 19 | static Keyboard *_instance; 20 | 21 | Keyboard() = default; 22 | public: 23 | Keyboard(const Keyboard &) = delete; 24 | Keyboard &operator=(Keyboard &) = delete; 25 | 26 | // returns true if this key is _pressed 27 | [[nodiscard]] static bool isKeyPressed(SDL_Keycode key); 28 | // returns true if this key is tapped and 1/5 sec passed (_button bouncing problem solved) 29 | [[nodiscard]] static bool isKeyTapped(SDL_Keycode key); 30 | 31 | [[nodiscard]] static bool isKeyDown(); 32 | [[nodiscard]] static bool isKeyUp(); 33 | [[nodiscard]] static std::vector keysDown(); 34 | [[nodiscard]] static std::vector keysUp(); 35 | [[nodiscard]] static std::string inputText(); 36 | 37 | static void sendKeyboardEvent(const SDL_Event& event); 38 | 39 | static void init(); 40 | static void clear(); 41 | static void free(); 42 | }; 43 | 44 | 45 | #endif //IO_KEYBOARD_H 46 | -------------------------------------------------------------------------------- /engine/io/Mouse.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_MOUSE_H 2 | #define IO_MOUSE_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | class Mouse final { 11 | private: 12 | std::map _buttons; 13 | std::map _tappedButtons; 14 | std::vector _buttonsDown; 15 | std::vector _buttonsUp; 16 | 17 | Vec2D _motion; 18 | Vec2D _scroll; 19 | 20 | static Mouse *_instance; 21 | Mouse() = default; 22 | public: 23 | 24 | // returns true if this _button is _pressed 25 | static bool isButtonPressed(uint8_t button); 26 | 27 | // returns true if this _button is tapped and 1/5 sec passed (_button bouncing problem solved) 28 | static bool isButtonTapped(uint8_t button); 29 | 30 | [[nodiscard]] static Vec2D getMousePosition(); 31 | [[nodiscard]] static Vec2D getMouseDisplacement(); 32 | [[nodiscard]] static Vec2D getMouseScroll(); 33 | [[nodiscard]] static bool isButtonDown(); 34 | [[nodiscard]] static bool isButtonUp(); 35 | [[nodiscard]] static std::vector buttonsDown(); 36 | [[nodiscard]] static std::vector buttonsUp(); 37 | 38 | void static setMouseDisplacement(const Vec2D& displacement = Vec2D(0)); 39 | void static setMouseScroll(const Vec2D& scroll = Vec2D(0)); 40 | 41 | static void sendMouseEvent(const SDL_Event& event); 42 | 43 | static void init(); 44 | static void clear(); 45 | static void free(); 46 | }; 47 | 48 | 49 | #endif //IO_MOUSE_H 50 | -------------------------------------------------------------------------------- /engine/linalg/Matrix3x3.h: -------------------------------------------------------------------------------- 1 | #ifndef LINALG_MATRIX3X3_H 2 | #define LINALG_MATRIX3X3_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | class Matrix3x3 final { 10 | private: 11 | std::array, 3> _arr{}; 12 | 13 | public: 14 | Matrix3x3() = default; 15 | explicit Matrix3x3(const std::array, 3>& matrix) : _arr(matrix) {}; 16 | Matrix3x3(const Vec3D& column1, const Vec3D& column2, const Vec3D& column3); 17 | 18 | Matrix3x3 &operator=(const Matrix3x3 &matrix3X3) = default; 19 | 20 | Matrix3x3 &operator+=(const Matrix3x3 &matrix3x3); 21 | 22 | [[nodiscard]] Matrix3x3 operator*(const Matrix3x3 &matrix3x3) const; 23 | [[nodiscard]] Matrix3x3 operator+(const Matrix3x3 &matrix3x3) const; 24 | [[nodiscard]] Matrix3x3 operator-(const Matrix3x3 &matrix3x3) const; 25 | 26 | [[nodiscard]] Matrix3x3 operator*(double number) const; 27 | 28 | [[nodiscard]] Vec3D operator*(const Vec3D &vec3D) const; 29 | 30 | friend std::ostream& operator<<(std::ostream& os, const Matrix3x3& matrix3X3); 31 | 32 | [[nodiscard]] Vec3D x() const; 33 | [[nodiscard]] Vec3D y() const; 34 | [[nodiscard]] Vec3D z() const; 35 | 36 | [[nodiscard]] Matrix3x3 inverse() const; 37 | 38 | [[nodiscard]] double abs() const; 39 | 40 | [[nodiscard]] Matrix3x3 static Identity(); 41 | [[nodiscard]] Matrix3x3 static Zero(); 42 | [[nodiscard]] Matrix3x3 static Constant(double value); 43 | [[nodiscard]] Matrix3x3 static Outer(const Vec3D &vec1, const Vec3D &vec2); // The outer product 44 | 45 | }; 46 | 47 | #include "Matrix3x3.inl" 48 | 49 | #endif //LINALG_MATRIX3X3_H 50 | -------------------------------------------------------------------------------- /engine/linalg/Matrix4x4.h: -------------------------------------------------------------------------------- 1 | #ifndef LINALG_MATRIX4X4_H 2 | #define LINALG_MATRIX4X4_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | class Matrix4x4 final { 10 | private: 11 | std::array, 4> _arr{}; 12 | 13 | [[nodiscard]] bool arePerpendicularAxis() const; 14 | public: 15 | Matrix4x4() = default; 16 | explicit Matrix4x4(const std::array, 4>& matrix) : _arr(matrix) {}; 17 | 18 | Matrix4x4 &operator=(const Matrix4x4 &matrix4X4) = default; 19 | 20 | [[nodiscard]] Matrix4x4 operator*(const Matrix4x4 &matrix4X4) const; 21 | [[nodiscard]] Matrix4x4 operator+(const Matrix4x4 &matrix4X4) const; 22 | [[nodiscard]] Matrix4x4 operator-(const Matrix4x4 &matrix4X4) const; 23 | 24 | [[nodiscard]] Vec4D operator*(const Vec4D &point4D) const; 25 | [[nodiscard]] Vec3D operator*(const Vec3D &vec) const; 26 | 27 | friend std::ostream& operator<<(std::ostream& os, const Matrix4x4& matrix4x4); 28 | 29 | [[nodiscard]] Vec3D x() const; 30 | [[nodiscard]] Vec3D y() const; 31 | [[nodiscard]] Vec3D z() const; 32 | [[nodiscard]] Vec3D w() const; 33 | 34 | /* 35 | * This function is computationally inefficient. 36 | * It is better to use View() method for 3D applications, where you do not need the inverse of 4x4 matrix, 37 | * but the inverse of 3x3 matrix + inverse translation. 38 | */ 39 | [[nodiscard]] Matrix4x4 inverse() const; 40 | 41 | [[nodiscard]] double abs() const; 42 | 43 | // Any useful matrix (static methods) 44 | Matrix4x4 static Identity(); 45 | Matrix4x4 static Zero(); 46 | Matrix4x4 static Constant(double value); 47 | Matrix4x4 static Scale(const Vec3D &factor); 48 | Matrix4x4 static Translation(const Vec3D &v); 49 | Matrix4x4 static Rotation(const Vec3D &r); 50 | Matrix4x4 static RotationX(double rx); 51 | Matrix4x4 static RotationY(double ry); 52 | Matrix4x4 static RotationZ(double rz); 53 | Matrix4x4 static Rotation(const Vec3D &v, double rv); 54 | Matrix4x4 static View(const Matrix4x4 &transformMatrix); 55 | Matrix4x4 static Projection(double fov = 90.0, double aspect = 1.0, double ZNear = 1.0, double ZFar = 10.0); 56 | Matrix4x4 static ScreenSpace(uint16_t width, uint16_t height, int shiftX=0, int shiftY=0); 57 | }; 58 | 59 | #include "Matrix4x4.inl" 60 | 61 | #endif //LINALG_MATRIX4X4_H 62 | -------------------------------------------------------------------------------- /engine/linalg/Vec2D.h: -------------------------------------------------------------------------------- 1 | #ifndef LINALG_VEC2D_H 2 | #define LINALG_VEC2D_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | class Vec2D final { 9 | private: 10 | std::array _arr_point{}; 11 | 12 | public: 13 | Vec2D() = default; 14 | Vec2D(const Vec2D &vec); 15 | explicit Vec2D(const Vec4D &vec); 16 | explicit Vec2D(double x, double y = 0.0); 17 | 18 | Vec2D &operator=(const Vec2D &) = default; 19 | 20 | [[nodiscard]] inline const double& x() const { return _arr_point[0]; } 21 | [[nodiscard]] inline const double& y() const { return _arr_point[1]; } 22 | 23 | [[nodiscard]] inline double& operator[](std::size_t i) { return _arr_point[i]; } 24 | [[nodiscard]] inline const double& operator[](std::size_t i) const { return _arr_point[i]; } 25 | 26 | [[nodiscard]] Vec2D operator-() const; 27 | 28 | // Boolean operations 29 | bool operator==(const Vec2D &vec) const; 30 | bool operator!=(const Vec2D &vec) const; 31 | 32 | // Operations with Vec2D 33 | Vec2D &operator+=(const Vec2D &vec); 34 | [[nodiscard]] Vec2D operator+(const Vec2D &vec) const; 35 | 36 | Vec2D &operator-=(const Vec2D &vec); 37 | [[nodiscard]] Vec2D operator-(const Vec2D &vec) const; 38 | 39 | [[nodiscard]] double dot(const Vec2D &vec) const; // Returns dot product 40 | 41 | // Operations with numbers 42 | Vec2D &operator/=(double number); 43 | [[nodiscard]] Vec2D operator/(double number) const; 44 | 45 | Vec2D &operator*=(double number); 46 | [[nodiscard]] Vec2D operator*(double number) const; 47 | 48 | // Other useful methods 49 | [[nodiscard]] double sqrAbs() const; // Returns squared vector length 50 | [[nodiscard]] double abs() const; // Returns vector length 51 | [[nodiscard]] Vec2D normalized() const; // Returns normalized vector without changing 52 | }; 53 | 54 | #include "Vec2D.inl" 55 | 56 | #endif //LINALG_VEC2D_H 57 | -------------------------------------------------------------------------------- /engine/linalg/Vec2D.inl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | inline Vec2D::Vec2D(const Vec2D &vec) : _arr_point{vec[0], vec[1]} {} 7 | 8 | inline Vec2D::Vec2D(const Vec4D &vec) : _arr_point{vec[0], vec[1]} {} 9 | 10 | inline Vec2D::Vec2D(double x, double y) : _arr_point{x, y} {} 11 | 12 | inline Vec2D Vec2D::operator-() const { 13 | return Vec2D(-x(), -y()); 14 | } 15 | 16 | 17 | inline bool Vec2D::operator==(const Vec2D &vec) const { 18 | return (*this - vec).sqrAbs() < Consts::EPS; 19 | } 20 | 21 | inline bool Vec2D::operator!=(const Vec2D &vec) const { 22 | return !(*this == vec); 23 | } 24 | 25 | // Operations with Vec2D 26 | 27 | inline Vec2D& Vec2D::operator+=(const Vec2D &vec) { 28 | _arr_point[0] += vec._arr_point[0]; 29 | _arr_point[1] += vec._arr_point[1]; 30 | return *this; 31 | } 32 | 33 | inline Vec2D& Vec2D::operator-=(const Vec2D &vec) { 34 | _arr_point[0] -= vec._arr_point[0]; 35 | _arr_point[1] -= vec._arr_point[1]; 36 | return *this; 37 | } 38 | 39 | inline Vec2D& Vec2D::operator*=(double number) { 40 | _arr_point[0] *= number; 41 | _arr_point[1] *= number; 42 | return *this; 43 | } 44 | 45 | inline Vec2D& Vec2D::operator/=(double number) { 46 | #ifndef NDEBUG 47 | if (std::abs(number) <= Consts::EPS) { 48 | throw std::domain_error{"Vec2D::operator/(double number): division by zero"}; 49 | } 50 | #endif 51 | _arr_point[0] /= number; 52 | _arr_point[1] /= number; 53 | return *this; 54 | } 55 | 56 | 57 | inline Vec2D Vec2D::operator+(const Vec2D &vec) const { 58 | Vec2D res = *this; 59 | res += vec; 60 | return res; 61 | } 62 | 63 | inline Vec2D Vec2D::operator-(const Vec2D &vec) const { 64 | Vec2D res = *this; 65 | res -= vec; 66 | return res; 67 | } 68 | 69 | inline Vec2D Vec2D::operator*(double number) const { 70 | Vec2D res = *this; 71 | res *= number; 72 | return res; 73 | } 74 | 75 | inline Vec2D Vec2D::operator/(double number) const { 76 | Vec2D res = *this; 77 | res /= number; 78 | return res; 79 | } 80 | 81 | // Other useful methods 82 | 83 | inline double Vec2D::sqrAbs() const { 84 | return x() * x() + y() * y(); 85 | } 86 | 87 | inline double Vec2D::abs() const { 88 | return sqrt(sqrAbs()); 89 | } 90 | 91 | inline Vec2D Vec2D::normalized() const { 92 | double vecAbs = sqrAbs(); 93 | if (vecAbs > Consts::EPS) { 94 | return *this / sqrt(vecAbs); 95 | } else { 96 | return Vec2D(0); 97 | } 98 | } 99 | 100 | inline double Vec2D::dot(const Vec2D &vec) const { 101 | return vec.x() * x() + vec.y() * y(); 102 | } 103 | -------------------------------------------------------------------------------- /engine/linalg/Vec3D.h: -------------------------------------------------------------------------------- 1 | #ifndef LINALG_VEC3D_H 2 | #define LINALG_VEC3D_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | class Vec3D final { 9 | private: 10 | std::array _arr_point{}; 11 | 12 | public: 13 | Vec3D() = default; 14 | Vec3D(const Vec3D &vec); 15 | explicit Vec3D(const Vec4D &vec); 16 | explicit Vec3D(double x, double y = 0.0, double z = 0.0); 17 | 18 | Vec3D &operator=(const Vec3D &) = default; 19 | 20 | [[nodiscard]] inline const double& x() const { return _arr_point[0]; } 21 | [[nodiscard]] inline const double& y() const { return _arr_point[1]; } 22 | [[nodiscard]] inline const double& z() const { return _arr_point[2]; } 23 | 24 | [[nodiscard]] inline double& operator[](std::size_t i) { return _arr_point[i]; } 25 | [[nodiscard]] inline const double& operator[](std::size_t i) const { return _arr_point[i]; } 26 | 27 | [[nodiscard]] Vec3D operator-() const; 28 | 29 | // Boolean operations 30 | bool operator==(const Vec3D &vec) const; 31 | bool operator!=(const Vec3D &vec) const; 32 | bool operator<(const Vec3D &vec) const; 33 | 34 | // Operations with Vec3D 35 | Vec3D &operator+=(const Vec3D &vec); 36 | [[nodiscard]] Vec3D operator+(const Vec3D &vec) const; 37 | 38 | Vec3D &operator-=(const Vec3D &vec); 39 | [[nodiscard]] Vec3D operator-(const Vec3D &vec) const; 40 | 41 | [[nodiscard]] double dot(const Vec3D &vec) const; // Returns dot product 42 | [[nodiscard]] Vec3D cross(const Vec3D &vec) const; // Returns cross product 43 | 44 | // Operations with numbers 45 | Vec3D &operator*=(double number); 46 | [[nodiscard]] Vec3D operator*(double number) const; 47 | 48 | Vec3D &operator/=(double number); 49 | [[nodiscard]] Vec3D operator/(double number) const; 50 | 51 | // Other useful methods 52 | [[nodiscard]] double sqrAbs() const; // Returns squared vector length 53 | [[nodiscard]] double abs() const; // Returns vector length 54 | [[nodiscard]] Vec3D normalized() const; // Returns normalized vector without changing 55 | [[nodiscard]] Vec4D makePoint4D() const; 56 | 57 | static Vec3D Random(); 58 | static Vec3D i() { return Vec3D(1, 0, 0); } 59 | static Vec3D j() { return Vec3D(0, 1, 0); } 60 | static Vec3D k() { return Vec3D(0, 0, 1); } 61 | static Vec3D EPS() { return Vec3D(Consts::EPS, Consts::EPS, Consts::EPS); } 62 | }; 63 | 64 | #include "Vec3D.inl" 65 | 66 | #endif //LINALG_VEC3D_H 67 | -------------------------------------------------------------------------------- /engine/linalg/Vec4D.h: -------------------------------------------------------------------------------- 1 | #ifndef LINALG_VEC4D_H 2 | #define LINALG_VEC4D_H 3 | 4 | #include 5 | 6 | class Vec4D final { 7 | private: 8 | std::array _arr_point{}; 9 | 10 | public: 11 | Vec4D() = default; 12 | Vec4D(const Vec4D &vec); 13 | explicit Vec4D(double x, double y = 0.0, double z = 0.0, double w = 0.0); 14 | 15 | Vec4D &operator=(const Vec4D &) = default; 16 | 17 | [[nodiscard]] inline const double& x() const { return _arr_point[0]; } 18 | [[nodiscard]] inline const double& y() const { return _arr_point[1]; } 19 | [[nodiscard]] inline const double& z() const { return _arr_point[2]; } 20 | [[nodiscard]] inline const double& w() const { return _arr_point[3]; } 21 | 22 | [[nodiscard]] inline double& operator[](std::size_t i) { return _arr_point[i]; } 23 | [[nodiscard]] inline const double& operator[](std::size_t i) const { return _arr_point[i]; } 24 | 25 | [[nodiscard]] Vec4D operator-() const; 26 | 27 | // Boolean operations 28 | bool operator==(const Vec4D &vec) const; 29 | bool operator!=(const Vec4D &vec) const; 30 | 31 | // Operations with Vec4D 32 | Vec4D &operator+=(const Vec4D &vec); 33 | [[nodiscard]] Vec4D operator+(const Vec4D &vec) const; 34 | 35 | Vec4D &operator-=(const Vec4D &vec); 36 | [[nodiscard]] Vec4D operator-(const Vec4D &vec) const; 37 | 38 | // Operations with numbers 39 | Vec4D &operator*=(double number); 40 | [[nodiscard]] Vec4D operator*(double number) const; 41 | 42 | Vec4D &operator/=(double number); 43 | [[nodiscard]] Vec4D operator/(double number) const; 44 | 45 | // Other useful methods 46 | [[nodiscard]] double sqrAbs() const; // Returns squared vector length 47 | [[nodiscard]] double abs() const; // Returns vector length 48 | [[nodiscard]] Vec4D normalized() const; // Returns normalized vector without changing 49 | }; 50 | 51 | #include "Vec4D.inl" 52 | 53 | #endif //LINALG_VEC4D_H 54 | -------------------------------------------------------------------------------- /engine/linalg/Vec4D.inl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | inline Vec4D::Vec4D(double x, double y, double z, double w) : _arr_point{x, y, z, w} {} 7 | 8 | inline Vec4D::Vec4D(const Vec4D &vec) : _arr_point{vec[0], vec[1], vec[2], vec[3]} {} 9 | 10 | 11 | inline Vec4D Vec4D::operator-() const { 12 | return Vec4D(-x(), -y(), -z(), -w()); 13 | } 14 | 15 | 16 | inline bool Vec4D::operator==(const Vec4D &vec) const { 17 | return (*this - vec).sqrAbs() < Consts::EPS; 18 | } 19 | 20 | inline bool Vec4D::operator!=(const Vec4D &vec) const { 21 | return !(*this == vec); 22 | } 23 | 24 | // Operations with Vec4D 25 | 26 | inline Vec4D &Vec4D::operator+=(const Vec4D &vec) { 27 | _arr_point[0] += vec._arr_point[0]; 28 | _arr_point[1] += vec._arr_point[1]; 29 | _arr_point[2] += vec._arr_point[2]; 30 | _arr_point[3] += vec._arr_point[3]; 31 | return *this; 32 | } 33 | 34 | inline Vec4D &Vec4D::operator-=(const Vec4D &vec) { 35 | _arr_point[0] -= vec._arr_point[0]; 36 | _arr_point[1] -= vec._arr_point[1]; 37 | _arr_point[2] -= vec._arr_point[2]; 38 | _arr_point[3] -= vec._arr_point[3]; 39 | return *this; 40 | } 41 | 42 | inline Vec4D &Vec4D::operator*=(double number) { 43 | _arr_point[0] *= number; 44 | _arr_point[1] *= number; 45 | _arr_point[2] *= number; 46 | _arr_point[3] *= number; 47 | return *this; 48 | } 49 | 50 | inline Vec4D &Vec4D::operator/=(double number) { 51 | #ifndef NDEBUG 52 | if (std::abs(number) <= Consts::EPS) { 53 | throw std::domain_error{"Vec4D::operator/(double number): division by zero"}; 54 | } 55 | #endif 56 | _arr_point[0] /= number; 57 | _arr_point[1] /= number; 58 | _arr_point[2] /= number; 59 | _arr_point[3] /= number; 60 | return *this; 61 | } 62 | 63 | 64 | inline Vec4D Vec4D::operator+(const Vec4D &vec) const { 65 | Vec4D res = *this; 66 | res += vec; 67 | return res; 68 | } 69 | 70 | inline Vec4D Vec4D::operator-(const Vec4D &vec) const { 71 | Vec4D res = *this; 72 | res -= vec; 73 | return res; 74 | } 75 | 76 | inline Vec4D Vec4D::operator*(double number) const { 77 | Vec4D res = *this; 78 | res *= number; 79 | return res; 80 | } 81 | 82 | inline Vec4D Vec4D::operator/(double number) const { 83 | Vec4D res = *this; 84 | res /= number; 85 | return res; 86 | } 87 | 88 | // Other useful methods 89 | 90 | inline double Vec4D::sqrAbs() const { 91 | return x() * x() + y() * y() + z() * z() + w() * w(); 92 | } 93 | 94 | inline double Vec4D::abs() const { 95 | return sqrt(sqrAbs()); 96 | } 97 | 98 | inline Vec4D Vec4D::normalized() const { 99 | double vecAbs = sqrAbs(); 100 | if (vecAbs > Consts::EPS) { 101 | return *this / sqrt(vecAbs); 102 | } else { 103 | return Vec4D(1); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /engine/objects/Camera.h: -------------------------------------------------------------------------------- 1 | #ifndef OBJECTS_CAMERA_H 2 | #define OBJECTS_CAMERA_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | class Camera final : public Object { 11 | private: 12 | std::vector _clipPlanes; 13 | double _znear = 0; 14 | double _zfar = 0; 15 | double _fov = 0; 16 | bool _ready = false; 17 | double _aspect = 0; 18 | 19 | // Internal variables to reduce allocations 20 | std::vector> _clipBuffer1; 21 | std::vector> _clipBuffer2; 22 | 23 | Matrix4x4 _SP; 24 | 25 | std::shared_ptr _transformMatrix; 26 | public: 27 | Camera() : Object(ObjectTag("Camera")) { 28 | _transformMatrix = addComponent(); 29 | }; 30 | 31 | Camera(const Camera &camera) = delete; 32 | 33 | void init(int width, int height, double fov = 90.0, double ZNear = 0.1, double ZFar = 5000.0); 34 | 35 | std::vector> project(const TriangleMesh& triangleMesh); 36 | std::vector project(const LineMesh& lineMesh); 37 | 38 | std::shared_ptr transformMatrix() const { return _transformMatrix; } 39 | }; 40 | 41 | 42 | #endif //OBJECTS_CAMERA_H 43 | -------------------------------------------------------------------------------- /engine/objects/Group.h: -------------------------------------------------------------------------------- 1 | #ifndef OBJECTS_GROUP_H 2 | #define OBJECTS_GROUP_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include "utils/FilePath.h" 9 | 10 | class Group : public Object { 11 | private: 12 | void copyObjectsFromGroup(const Group& group); 13 | public: 14 | explicit Group(const ObjectTag& tag): Object(tag) {}; 15 | explicit Group(const ObjectTag& tag, const FilePath &mesh_file, const Vec3D &scale = Vec3D{1, 1, 1}); 16 | 17 | Group(const Group& group); 18 | Group(const ObjectTag& tag, const Group& group); 19 | 20 | void add(std::shared_ptr object); 21 | void add(const Object& object); 22 | void add(const ObjectTag& tag, const FilePath &mesh_file, const Vec3D &scale = Vec3D{1, 1, 1}); 23 | 24 | void replace(std::shared_ptr object); 25 | void replace(const Object& object); 26 | 27 | bool remove(const ObjectTag &tag); 28 | void clear(); 29 | [[nodiscard]] uint16_t size() const { return numberOfAttached(); } 30 | std::shared_ptr find(const ObjectTag &tag); 31 | 32 | [[nodiscard]] TriangleMesh::IntersectionInformation intersect(const Vec3D &from, const Vec3D &to, 33 | const std::set &skipTags = {}) const; 34 | 35 | [[nodiscard]] std::shared_ptr copy(const ObjectTag& tag) const override { 36 | return std::make_shared(tag, *this); 37 | } 38 | 39 | ~Group() override; 40 | }; 41 | 42 | 43 | #endif //OBJECTS_GROUP_H 44 | -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-Black.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-BlackItalic.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-Bold.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-BoldItalic.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-Italic.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-Light.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-LightItalic.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-Medium.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-MediumItalic.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-Regular.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-Thin.ttf -------------------------------------------------------------------------------- /engine/resources/fonts/Roboto/Roboto-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/fonts/Roboto/Roboto-ThinItalic.ttf -------------------------------------------------------------------------------- /engine/resources/png/texture_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/engine/resources/png/texture_test.png -------------------------------------------------------------------------------- /engine/utils/EventHandler.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Ivan Ilin on 26/05/2023. 3 | // 4 | 5 | #include 6 | 7 | EventHandler *EventHandler::_instance = nullptr; 8 | 9 | void EventHandler::init() { 10 | delete _instance; 11 | _instance = new EventHandler(); 12 | 13 | Log::log("EventHandler::init(): event handler was initialized"); 14 | } 15 | -------------------------------------------------------------------------------- /engine/utils/EventHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Ivan Ilin on 26/05/2023. 3 | // 4 | 5 | #ifndef SHOOTER_EVENTHANDLER_H 6 | #define SHOOTER_EVENTHANDLER_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | class Event final { 18 | private: 19 | std::string s_event_name; 20 | public: 21 | explicit Event(std::string name) : s_event_name(std::move(name)) {} 22 | 23 | bool operator==(const Event &event) const { return s_event_name == event.s_event_name; } 24 | bool operator!=(const Event &event) const { return s_event_name != event.s_event_name; } 25 | bool operator<(const Event &event) const { return s_event_name < event.s_event_name; } 26 | 27 | [[nodiscard]] std::string str() const { return s_event_name; } 28 | }; 29 | 30 | class Function{}; 31 | 32 | template 33 | class CallBack final : public Function { 34 | private: 35 | std::function _callBack; 36 | public: 37 | explicit CallBack(const std::function& callBack): _callBack(callBack) {}; 38 | 39 | template 40 | void operator()(Args&&... a) { 41 | _callBack(a...); 42 | } 43 | }; 44 | 45 | class EventHandler final { 46 | private: 47 | std::map>> _callBacks; 48 | 49 | static EventHandler *_instance; 50 | 51 | EventHandler() = default; 52 | public: 53 | EventHandler(const EventHandler &) = delete; 54 | 55 | EventHandler &operator=(EventHandler &) = delete; 56 | 57 | static void init(); 58 | 59 | template 60 | static void call(const Event& event, Arguments... args) { 61 | if (_instance == nullptr) { 62 | return; 63 | } 64 | auto functionListIterator = _instance->_callBacks.find(event); 65 | 66 | if(functionListIterator != _instance->_callBacks.end()) { 67 | auto& functionList = functionListIterator->second; 68 | for (const auto& function : functionList) { 69 | auto callBack = *static_cast*>(function.get()); 70 | callBack(args...); 71 | } 72 | } 73 | 74 | Log::log("EventHandler::call(): event <" + event.str() 75 | + "> happened (" + std::to_string(_instance->_callBacks[event].size()) + " listeners)"); 76 | } 77 | 78 | template 79 | static void listen(const Event& event, const std::function& callBack) { 80 | if (_instance == nullptr) { 81 | return; 82 | } 83 | _instance->_callBacks[event].emplace_back(std::make_unique>(callBack)); 84 | 85 | Log::log("EventHandler::listen(): added event listener to <" + event.str() 86 | + "> (" + std::to_string(_instance->_callBacks[event].size()) + " listeners)"); 87 | } 88 | }; 89 | 90 | 91 | #endif //SHOOTER_EVENTHANDLER_H 92 | -------------------------------------------------------------------------------- /engine/utils/FilePath.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | FilePath::FilePath(const std::string& path) : _path(path) { 6 | 7 | } 8 | 9 | bool FilePath::contains(const FilePath &nameTag) const { 10 | if(_path.string().find(nameTag.str()) != std::string::npos) { 11 | return true; 12 | } 13 | return false; 14 | } 15 | 16 | std::string FilePath::parentPath() const { 17 | return _path.parent_path().string(); 18 | } 19 | 20 | std::string FilePath::fileName() const { 21 | return _path.filename().string(); 22 | } 23 | 24 | FilePath::FilePath(const std::string& path, const std::string& name) { 25 | _path = std::filesystem::path(path) / name; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /engine/utils/FilePath.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_FILEPATH_H 2 | #define UTILS_FILEPATH_H 3 | 4 | #include 5 | 6 | class FilePath final { 7 | private: 8 | std::filesystem::path _path; 9 | public: 10 | explicit FilePath(const std::string& name = ""); 11 | FilePath (const std::string& path, const std::string& name); 12 | 13 | [[nodiscard]] std::string str() const { return _path.string(); } 14 | 15 | [[nodiscard]] bool empty() const { return _path.empty(); } 16 | 17 | bool operator==(const FilePath &name) const { return _path == name._path; } 18 | bool operator!=(const FilePath &name) const { return _path != name._path; } 19 | bool operator<(const FilePath &name) const { return _path < name._path; } 20 | 21 | [[nodiscard]] bool contains(const FilePath& tag) const; 22 | 23 | [[nodiscard]] std::string parentPath() const; 24 | [[nodiscard]] std::string fileName() const; 25 | }; 26 | 27 | #endif //UTILS_FILEPATH_H 28 | -------------------------------------------------------------------------------- /engine/utils/Font.cpp: -------------------------------------------------------------------------------- 1 | #include "Font.h" 2 | #include 3 | 4 | bool FontTag::contains(const std::string& str) const { 5 | if(_name.find(str) != std::string::npos) { 6 | return true; 7 | } 8 | return false; 9 | } 10 | 11 | Font::Font(const FontTag& tag, const FilePath& fileName) : _tag(tag), _fileName(fileName) { 12 | 13 | } 14 | 15 | TTF_Font* Font::getFont(uint16_t fontSize) { 16 | 17 | if(_fonts.contains(fontSize) && _fonts[fontSize]) { 18 | return _fonts[fontSize]; 19 | } 20 | 21 | TTF_Font* font = TTF_OpenFont(_fileName.str().c_str(), fontSize); 22 | // Confirm that it was loaded 23 | if(!font){ 24 | Log::log("Font::getFont(): Could not load font " + _fileName.str()); 25 | return nullptr; 26 | } 27 | _fonts.insert({fontSize,font}); 28 | return font; 29 | } 30 | 31 | 32 | Font::~Font() { 33 | for(auto& f : _fonts) { 34 | if (f.second) { 35 | TTF_CloseFont(f.second); 36 | } 37 | } 38 | 39 | _fonts.clear(); 40 | } 41 | 42 | std::pair Font::getTextSize(const std::string &text, uint16_t fontSize) { 43 | TTF_Font* font = getFont(fontSize); 44 | if(!font) { 45 | return {0,0}; 46 | } 47 | 48 | int w, h; 49 | TTF_SizeText(font, text.c_str(), &w, &h); 50 | 51 | return {w, h}; 52 | } 53 | -------------------------------------------------------------------------------- /engine/utils/Font.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_FONT_H 2 | #define UTILS_FONT_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "SDL_ttf.h" 10 | 11 | class FontTag final { 12 | private: 13 | const std::string _name; 14 | public: 15 | explicit FontTag(const std::string& name = "") : _name(name) {} 16 | 17 | FontTag(const FontTag& other) : _name(other._name) {} 18 | 19 | [[nodiscard]] std::string str() const { return _name; } 20 | [[nodiscard]] bool empty() const { return _name.empty(); } 21 | 22 | bool operator==(const FontTag &tag) const { return _name == tag._name; } 23 | bool operator!=(const FontTag &tag) const { return _name != tag._name; } 24 | bool operator<(const FontTag &tag) const { return _name < tag._name; } 25 | 26 | [[nodiscard]] bool contains(const std::string& str) const; 27 | }; 28 | 29 | class Font { 30 | private: 31 | const FontTag _tag; 32 | const FilePath _fileName; 33 | 34 | // Here we store this font for different fontsize 35 | std::map _fonts; 36 | public: 37 | Font(const FontTag& tag, const FilePath& fileName); 38 | 39 | TTF_Font* getFont(uint16_t fontSize=14); 40 | 41 | [[nodiscard]] std::pair getTextSize(const std::string& text, uint16_t fontSize=14); 42 | 43 | ~Font(); 44 | }; 45 | 46 | 47 | #endif //ENGINE_FONT_H 48 | -------------------------------------------------------------------------------- /engine/utils/Log.cpp: -------------------------------------------------------------------------------- 1 | #define _CRT_SECURE_NO_WARNINGS 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Log { 14 | void log(const std::string &message) { 15 | if (Consts::USE_LOG_FILE) { 16 | auto dt = Time::getLocalTimeInfo(); 17 | std::fstream file("engine.log", std::ios::out | std::ios::app); 18 | file << dt << " | Mem: " << getProcessSizeMB() << "MB " << "\t" << message << " (" << Time::fps() << " fps)" << std::endl; 19 | std::cout << dt << " | Mem: " << getProcessSizeMB() << "MB " << "\t" << message << " (" << Time::fps() << " fps)" << std::endl; 20 | file.close(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /engine/utils/Log.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_LOG_H 2 | #define UTILS_LOG_H 3 | 4 | #include 5 | 6 | namespace Log { 7 | void log(const std::string &message); 8 | }; 9 | 10 | 11 | #endif //UTILS_LOG_H 12 | -------------------------------------------------------------------------------- /engine/utils/ObjectController.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | ObjectController::ObjectController(std::shared_ptr transformMatrix) : _object(transformMatrix){} 6 | 7 | void ObjectController::update() { 8 | double speed = 5.0; 9 | 10 | // Left and right 11 | if (Keyboard::isKeyPressed(SDLK_a)) 12 | _object->translate(_object->left()*Time::deltaTime()*speed); 13 | 14 | if (Keyboard::isKeyPressed(SDLK_d)) 15 | _object->translate(-_object->left()*Time::deltaTime()*speed); 16 | 17 | // Forward and backward 18 | if (Keyboard::isKeyPressed(SDLK_w)) 19 | _object->translate(_object->lookAt()*Time::deltaTime()*speed); 20 | 21 | if (Keyboard::isKeyPressed(SDLK_s)) 22 | _object->translate(-_object->lookAt()*Time::deltaTime()*speed); 23 | 24 | if (Keyboard::isKeyPressed(SDLK_LSHIFT)) 25 | _object->translate(Vec3D{0.0, -Time::deltaTime()*speed, 0}); 26 | 27 | if (Keyboard::isKeyPressed(SDLK_SPACE)) 28 | _object->translate(Vec3D{0.0, Time::deltaTime()*speed, 0}); 29 | 30 | // Mouse movement 31 | Vec2D mouseMotion = Mouse::getMouseDisplacement(); 32 | 33 | _object->rotateRelativePoint(_object->position(), Vec3D{0, -mouseMotion.x()/1000.0, 0}); 34 | _object->rotateLeft(mouseMotion.y()/1000.0); 35 | } -------------------------------------------------------------------------------- /engine/utils/ObjectController.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_OBJECTCONTROLLER_H 2 | #define UTILS_OBJECTCONTROLLER_H 3 | 4 | #include "components/TransformMatrix.h" 5 | #include 6 | #include 7 | 8 | class ObjectController { 9 | private: 10 | std::shared_ptr _object; 11 | 12 | public: 13 | ObjectController(std::shared_ptr transformMatrix); 14 | 15 | void update(); 16 | }; 17 | 18 | #endif //UTILS_OBJECTCONTROLLER_H 19 | -------------------------------------------------------------------------------- /engine/utils/ResourceManager.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_RESOURCEMANAGER_H 2 | #define UTILS_RESOURCEMANAGER_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | class ResourceManager final { 14 | private: 15 | std::map> _objects; 16 | std::map> _fonts; 17 | 18 | static ResourceManager *_instance; 19 | 20 | ResourceManager() = default; 21 | 22 | static void unloadObjects(); 23 | static void unloadFonts(); 24 | static void unloadAllResources(); 25 | 26 | // For now this function is only used in ResourceManager::loadObjects(), if it will be necessary 27 | // we can move it to the public domain. 28 | static std::map> loadMaterials(const FilePath &mtlFile); 29 | public: 30 | ResourceManager(const ResourceManager &) = delete; 31 | 32 | ResourceManager &operator=(ResourceManager &) = delete; 33 | 34 | 35 | static void init(); 36 | 37 | static void free(); 38 | 39 | // This function tries to load texture from the .obj file. 40 | // If it succeeded - the function returns a pointer to the texture. 41 | // Otherwise, it returns a nullptr. 42 | static std::shared_ptr loadTriangleMesh(const ObjectTag &tag, const FilePath &meshFile); 43 | 44 | static std::shared_ptr loadFont(const FilePath &fontFile); 45 | }; 46 | 47 | #endif //UTILS_RESOURCEMANAGER_H 48 | -------------------------------------------------------------------------------- /engine/utils/Time.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_TIME_H 2 | #define UTILS_TIME_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | class Time final { 14 | private: 15 | std::map _timers; 16 | 17 | // High precision time 18 | std::chrono::high_resolution_clock::time_point _start = std::chrono::high_resolution_clock::now(); 19 | std::chrono::high_resolution_clock::time_point _last = _start; 20 | 21 | // FPS counter 22 | std::chrono::high_resolution_clock::time_point _fpsStart{}; 23 | std::chrono::milliseconds _fpsCountTime = std::chrono::milliseconds(500); 24 | int _fpsCounter = 0; 25 | unsigned int _lastFps = 0; 26 | 27 | double _time = 0; 28 | double _deltaTime = 0; 29 | unsigned int _frame = 0; 30 | double _fixedDeltaTime = Consts::FIXED_UPDATE_INTERVAL; 31 | 32 | static Time *_instance; 33 | 34 | Time() = default; 35 | 36 | public: 37 | Time(const Time &) = delete; 38 | 39 | Time &operator=(Time &) = delete; 40 | 41 | static void update(); 42 | static void init(); 43 | static void free(); 44 | 45 | static void startTimer(const std::string& timerName); 46 | static void stopTimer(const std::string& timerName); 47 | static void pauseTimer(const std::string& timerName); 48 | 49 | static void setFixedUpdateInterval(double fixedDeltaTime); 50 | 51 | [[nodiscard]] static unsigned int fps(); 52 | [[nodiscard]] static double time(); 53 | [[nodiscard]] static unsigned int frame(); 54 | [[nodiscard]] static double deltaTime(); 55 | [[nodiscard]] static double fixedDeltaTime(); 56 | [[nodiscard]] static double elapsedTimerMilliseconds(const std::string& timerName); 57 | [[nodiscard]] static double elapsedTimerSeconds(const std::string& timerName); 58 | [[nodiscard]] static std::optional>> timers(); 59 | 60 | [[nodiscard]] static std::string getLocalTimeInfo(const std::string& format = "%F %T"); 61 | }; 62 | 63 | #endif //UTILS_TIME_H 64 | -------------------------------------------------------------------------------- /engine/utils/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std::chrono; 4 | 5 | void Timer::start() { 6 | if(!_isTicking) { 7 | _startTime = high_resolution_clock::now(); 8 | } 9 | if(_isStopped) { 10 | _elapsedSeconds = 0; 11 | } 12 | _isStopped = false; 13 | _isTicking = true; 14 | } 15 | 16 | void Timer::pause() { 17 | 18 | _endTime = high_resolution_clock::now(); 19 | _elapsedSeconds += duration(_endTime - _startTime).count(); 20 | 21 | _isTicking = false; 22 | } 23 | 24 | void Timer::stop() { 25 | if(_isTicking) { 26 | _endTime = high_resolution_clock::now(); 27 | _elapsedSeconds += duration(_endTime - _startTime).count(); 28 | } 29 | 30 | _isTicking = false; 31 | _isStopped = true; 32 | } 33 | 34 | double Timer::elapsedSeconds() const { 35 | if(_isTicking) { 36 | return _elapsedSeconds + duration(high_resolution_clock::now() - _startTime).count(); 37 | } 38 | 39 | return _elapsedSeconds; 40 | } 41 | 42 | double Timer::elapsedMilliseconds() const { 43 | return elapsedSeconds()*1000; 44 | } 45 | -------------------------------------------------------------------------------- /engine/utils/Timer.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_TIMER_H 2 | #define UTILS_TIMER_H 3 | 4 | #include 5 | 6 | class Timer { 7 | private: 8 | std::chrono::high_resolution_clock::time_point _startTime; 9 | std::chrono::high_resolution_clock::time_point _endTime; 10 | bool _isTicking = false; 11 | bool _isStopped = true; 12 | 13 | double _elapsedSeconds = 0; 14 | public: 15 | void start(); 16 | void stop(); 17 | void pause(); 18 | 19 | [[nodiscard]] double elapsedMilliseconds() const; 20 | [[nodiscard]] double elapsedSeconds() const; 21 | }; 22 | 23 | 24 | #endif //UTILS_TIMER_H 25 | -------------------------------------------------------------------------------- /engine/utils/WorldEditor.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_WORLDEDITOR_H 2 | #define UTILS_WORLDEDITOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | extern "C" { 10 | #include "io/microui/microui.h" 11 | } 12 | 13 | 14 | class WorldEditor { 15 | private: 16 | std::unique_ptr _ctx; 17 | 18 | std::shared_ptr _screen; 19 | std::shared_ptr _world; 20 | std::shared_ptr _camera; 21 | 22 | std::shared_ptr _selectedObject = nullptr; 23 | std::shared_ptr _selectedObjectBounds = nullptr; 24 | std::shared_ptr _redCube = nullptr; 25 | 26 | std::shared_ptr _objController = nullptr; 27 | std::shared_ptr _cameraController = nullptr; 28 | 29 | bool _enableLighting = true; 30 | bool _enableTrueLighting = false; 31 | bool _enableTransparency = true; 32 | bool _enableTriangleBorders = false; 33 | bool _enableTexturing = true; 34 | bool _enableMipmapping = true; 35 | bool _enableDepthTest = true; 36 | 37 | bool _objInFocus = false; 38 | bool _isControllerActive = true; 39 | bool _isRecording = false; 40 | 41 | int _operationTransformMatrix = -1; 42 | int _operationRigidObject = -1; 43 | 44 | float _lightingLODNearDistance = Consts::LIGHTING_LOD_NEAR_DISTANCE; 45 | float _lightingLODFarDistance = Consts::LIGHTING_LOD_FAR_DISTANCE; 46 | 47 | void handleInputEvents(); 48 | void drawUiIcon(int id, uint16_t x, uint16_t y); 49 | void processFrame(); 50 | void renderGui(); 51 | 52 | void controlPanel(); 53 | void objectTree(const std::shared_ptr& object); 54 | void renderSettings(); 55 | 56 | void objectEditor(); 57 | void transformMatrixEditor(); 58 | void triangleMeshEditor(); 59 | void lineMeshEditor(); 60 | void lightSourceEditor(); 61 | void rigidObjectEditor(); 62 | 63 | 64 | void updateScreenSettings(); 65 | void updateControllers(); 66 | public: 67 | WorldEditor(std::shared_ptr screen, std::shared_ptr world, std::shared_ptr camera); 68 | 69 | void update(); 70 | 71 | [[nodiscard]] std::shared_ptr selectedObject() { return _selectedObject; } 72 | }; 73 | 74 | 75 | #endif //UTILS_WORLDEDITOR_H 76 | -------------------------------------------------------------------------------- /engine/utils/math.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Neirokan on 14.02.2024. 3 | // 4 | 5 | #include "math.h" 6 | 7 | const int log2_values[64] = { 8 | 63, 0, 58, 1, 59, 47, 53, 2, 9 | 60, 39, 48, 27, 54, 33, 42, 3, 10 | 61, 51, 37, 40, 49, 18, 28, 20, 11 | 55, 30, 34, 11, 43, 14, 22, 4, 12 | 62, 57, 46, 52, 38, 26, 32, 41, 13 | 50, 36, 17, 19, 29, 10, 13, 21, 14 | 56, 45, 25, 31, 35, 16, 9, 12, 15 | 44, 24, 15, 8, 23, 7, 6, 5 16 | }; 17 | 18 | int log2_u64(uint64_t value) { 19 | value |= value >> 1; 20 | value |= value >> 2; 21 | value |= value >> 4; 22 | value |= value >> 8; 23 | value |= value >> 16; 24 | value |= value >> 32; 25 | value -= value >> 1; 26 | value = (value * 0x07EDD5E59A4E28C2U) >> 58; 27 | return log2_values[value]; 28 | } -------------------------------------------------------------------------------- /engine/utils/math.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Neirokan on 14.02.2024. 3 | // 4 | 5 | #ifndef UTILS_MATH_H 6 | #define UTILS_MATH_H 7 | 8 | #include 9 | 10 | int log2_u64(uint64_t value); 11 | 12 | #endif //UTILS_MATH_H 13 | -------------------------------------------------------------------------------- /engine/utils/monitoring.cpp: -------------------------------------------------------------------------------- 1 | #include "monitoring.h" 2 | #include "Consts.h" 3 | 4 | #if defined(_WIN32) || defined(_WIN64) 5 | #include 6 | #include 7 | int getProcessSizeMB() { 8 | PROCESS_MEMORY_COUNTERS_EX pmc; 9 | if (GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc))) { 10 | return pmc.WorkingSetSize / Consts::MB; 11 | } 12 | return -1; 13 | } 14 | #elif defined(__linux__) 15 | #include 16 | #include 17 | int getProcessSizeMB() { 18 | std::ifstream statmFile("/proc/self/statm"); 19 | long pageSizeMB = sysconf(_SC_PAGESIZE) / Consts::MB; 20 | unsigned long vmSize, residentSize; 21 | if (statmFile >> vmSize >> residentSize) { 22 | return residentSize * pageSizeMB; 23 | } 24 | return -1; 25 | } 26 | #elif defined(__APPLE__) && defined(__MACH__) 27 | #include 28 | int getProcessSizeMB() { 29 | mach_task_basic_info_data_t info; 30 | mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; 31 | if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info, &infoCount) == KERN_SUCCESS) { 32 | return info.resident_size / Consts::MB; 33 | } 34 | return -1; 35 | } 36 | #else 37 | int getProcessSizeMB() { 38 | return -1; 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /engine/utils/monitoring.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_MONITORING_H 2 | #define UTILS_MONITORING_H 3 | 4 | int getProcessSizeMB(); 5 | 6 | #endif //UTILS_MONITORING_H 7 | -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_0.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_1.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_10.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_11.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_12.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_13.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_14.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_15.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_16.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_17.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_18.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_19.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_2.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_20.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_21.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_22.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_3.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_4.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_5.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_6.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_7.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_8.png -------------------------------------------------------------------------------- /resources/obj/Dust/Dust_material_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/Dust/Dust_material_9.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mk_032k_pkaidanue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mk_032k_pkaidanue.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_008o_kuro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_008o_kuro.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032f_peye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032f_peye.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032f_yane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032f_yane.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032k_knphuti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032k_knphuti.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032k_knphuti2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032k_knphuti2.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032k_pkaidanue2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032k_pkaidanue2.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032k_pkaidanue3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032k_pkaidanue3.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032k_pnikaid01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032k_pnikaid01.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_032k_psansyoku.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_032k_psansyoku.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_ata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_ata.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_atab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_atab.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_atac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_atac.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_atowerc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_atowerc.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_doord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_doord.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_doorg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_doorg.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_puroe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_puroe.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_purof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_purof.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_toi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_toi.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_tugime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_tugime.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064f_tugimeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064f_tugimeb.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_knhashi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_knhashi.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_knkabem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_knkabem.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_knmizo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_knmizo.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_mizo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_mizo.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_mizok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_mizok.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_pcueye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_pcueye.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_piemae.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_piemae.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_pkaidanmae.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_pkaidanmae.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_pkaidanue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_pkaidanue.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_pkata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_pkata.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_pkata2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_pkata2.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_pkire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_pkire.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_pue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_pue.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_064k_ue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_064k_ue.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128f_minkabee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128f_minkabee.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128f_mosh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128f_mosh.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128f_wallna.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128f_wallna.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_knpknu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_knpknu.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_knpyane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_knpyane.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_knpyuka.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_knpyuka.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_knpyuka25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_knpyuka25.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_knpyuka3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_knpyuka3.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_krgake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_krgake.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_krgakehuti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_krgakehuti.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_krkaishita.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_krkaishita.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_kuzud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_kuzud.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_kuzure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_kuzure.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_kuzure3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_kuzure3.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_mrpkabe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_mrpkabe.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_mrpkabe2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_mrpkabe2.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_nikabe01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_nikabe01.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_phebi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_phebi.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_phebi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_phebi2.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_phuti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_phuti.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_pie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_pie.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_pmiti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_pmiti.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_pnakaheki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_pnakaheki.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_pnikabe01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_pnikabe01.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_128k_uekaba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_128k_uekaba.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256f_kaaikabe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256f_kaaikabe.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256f_minkabec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256f_minkabec.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256f_minkabed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256f_minkabed.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256k_krgakemoto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256k_krgakemoto.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256k_krgakeshi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256k_krgakeshi.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256k_krkusahara.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256k_krkusahara.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256k_pgaiheki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256k_pgaiheki.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mr_256k_uekiregake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mr_256k_uekiregake.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mrb_064k_criwac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mrb_064k_criwac.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mrb_128k_criwaa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mrb_128k_criwaa.png -------------------------------------------------------------------------------- /resources/obj/PastVillage/mrb_128k_criwab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/PastVillage/mrb_128k_criwab.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/Car1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car1.blend' 2 | # Material Count: 1 3 | 4 | newmtl car_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd car1.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car1/car1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car1.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_blue.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_gray.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_red.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snow.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snow_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snow_blue.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snow_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snow_gray.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snow_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snow_red.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snowcovered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snowcovered.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snowcovered_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snowcovered_blue.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snowcovered_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snowcovered_gray.png -------------------------------------------------------------------------------- /resources/obj/cars/car1/car_snowcovered_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car1/car_snowcovered_red.png -------------------------------------------------------------------------------- /resources/obj/cars/car2/Car2.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car2.blend' 2 | # Material Count: 1 3 | 4 | newmtl car2_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd car2.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car2/car2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car2/car2.png -------------------------------------------------------------------------------- /resources/obj/cars/car2/car2_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car2/car2_black.png -------------------------------------------------------------------------------- /resources/obj/cars/car2/car2_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car2/car2_red.png -------------------------------------------------------------------------------- /resources/obj/cars/car3/Car3.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car3.blend' 2 | # Material Count: 1 3 | 4 | newmtl car3_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd car3.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car3/car3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car3/car3.png -------------------------------------------------------------------------------- /resources/obj/cars/car3/car3_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car3/car3_red.png -------------------------------------------------------------------------------- /resources/obj/cars/car3/car3_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car3/car3_yellow.png -------------------------------------------------------------------------------- /resources/obj/cars/car4/Car4.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car4.blend' 2 | # Material Count: 1 3 | 4 | newmtl car4_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd car4.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car4/car4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car4/car4.png -------------------------------------------------------------------------------- /resources/obj/cars/car4/car4_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car4/car4_grey.png -------------------------------------------------------------------------------- /resources/obj/cars/car4/car4_lightgrey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car4/car4_lightgrey.png -------------------------------------------------------------------------------- /resources/obj/cars/car4/car4_lightorange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car4/car4_lightorange.png -------------------------------------------------------------------------------- /resources/obj/cars/car5/Car5.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car5.blend' 2 | # Material Count: 1 3 | 4 | newmtl car5_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd car5.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car5/Car5_Police.mtl: -------------------------------------------------------------------------------- 1 | # GGBot / ggbot.net / 2021-12-05 2 | 3 | newmtl car5_police_mat 4 | Ns 10.000000 5 | Ni 1.500000 6 | d 1.000000 7 | Tr 0.000000 8 | Tf 1.000000 1.000000 1.000000 9 | illum 2 10 | Ka 0.588000 0.588000 0.588000 11 | Kd 0.588000 0.588000 0.588000 12 | Ks 0.000000 0.000000 0.000000 13 | Ke 0.000000 0.000000 0.000000 14 | map_Ka car5_police.png 15 | map_Kd car5_police.png 16 | -------------------------------------------------------------------------------- /resources/obj/cars/car5/Car5_Taxi.mtl: -------------------------------------------------------------------------------- 1 | # GGBot / ggbot.net / 2021-12-05 2 | 3 | newmtl car5_taxi_mat 4 | Ns 10.000000 5 | Ni 1.500000 6 | d 1.000000 7 | Tr 0.000000 8 | Tf 1.000000 1.000000 1.000000 9 | illum 2 10 | Ka 0.588000 0.588000 0.588000 11 | Kd 0.588000 0.588000 0.588000 12 | Ks 0.000000 0.000000 0.000000 13 | Ke 0.000000 0.000000 0.000000 14 | map_Ka car5_taxi.png 15 | map_Kd car5_taxi.png 16 | -------------------------------------------------------------------------------- /resources/obj/cars/car5/car5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car5/car5.png -------------------------------------------------------------------------------- /resources/obj/cars/car5/car5_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car5/car5_green.png -------------------------------------------------------------------------------- /resources/obj/cars/car5/car5_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car5/car5_grey.png -------------------------------------------------------------------------------- /resources/obj/cars/car5/car5_police.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car5/car5_police.png -------------------------------------------------------------------------------- /resources/obj/cars/car5/car5_police_la.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car5/car5_police_la.png -------------------------------------------------------------------------------- /resources/obj/cars/car5/car5_taxi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car5/car5_taxi.png -------------------------------------------------------------------------------- /resources/obj/cars/car6/Car6.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car6.blend' 2 | # Material Count: 1 3 | 4 | newmtl car6_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd car6.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car6/car6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car6/car6.png -------------------------------------------------------------------------------- /resources/obj/cars/car7/Car7.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car7.blend' 2 | # Material Count: 1 3 | 4 | newmtl car7_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd car7.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car7/car7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car7/car7.png -------------------------------------------------------------------------------- /resources/obj/cars/car7/car7_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car7/car7_black.png -------------------------------------------------------------------------------- /resources/obj/cars/car7/car7_brown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car7/car7_brown.png -------------------------------------------------------------------------------- /resources/obj/cars/car7/car7_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car7/car7_green.png -------------------------------------------------------------------------------- /resources/obj/cars/car7/car7_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car7/car7_grey.png -------------------------------------------------------------------------------- /resources/obj/cars/car7/car7_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car7/car7_red.png -------------------------------------------------------------------------------- /resources/obj/cars/car8/Car8.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'Car8.blend' 2 | # Material Count: 1 3 | 4 | newmtl car8_mat 5 | Ns 11.111113 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.588000 0.588000 0.588000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.500000 11 | d 1.000000 12 | illum 1 13 | map_Kd Car8.png 14 | -------------------------------------------------------------------------------- /resources/obj/cars/car8/Car8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car8/Car8.png -------------------------------------------------------------------------------- /resources/obj/cars/car8/Car8_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car8/Car8_grey.png -------------------------------------------------------------------------------- /resources/obj/cars/car8/Car8_mail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car8/Car8_mail.png -------------------------------------------------------------------------------- /resources/obj/cars/car8/Car8_purple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/car8/Car8_purple.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_13_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_13_diffuse.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_20_0_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_20_0_diffuse.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_20_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_20_diffuse.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_2_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_2_diffuse.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_6_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_6_diffuse.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_8_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_8_diffuse.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_8_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_8_normal.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/auto_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/cheetah/auto_diffuse.png -------------------------------------------------------------------------------- /resources/obj/cars/cheetah/cheetah.mtl: -------------------------------------------------------------------------------- 1 | # Blender 3.6.5 MTL File: 'None' 2 | # www.blender.org 3 | 4 | newmtl auto 5 | Ns 360.000000 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.800000 0.800000 0.800000 8 | Ks 0.500000 0.500000 0.500000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.000000 11 | d 1.000000 12 | illum 2 13 | map_Kd auto_diffuse.png 14 | 15 | newmtl auto_13 16 | Ns 360.000000 17 | Ka 1.000000 1.000000 1.000000 18 | Kd 0.800000 0.800000 0.800000 19 | Ks 0.500000 0.500000 0.500000 20 | Ke 0.000000 0.000000 0.000000 21 | Ni 1.000000 22 | d 1.000000 23 | illum 2 24 | map_Kd auto_13_diffuse.png 25 | 26 | newmtl auto_2 27 | Ns 360.000000 28 | Ka 1.000000 1.000000 1.000000 29 | Kd 0.800000 0.800000 0.800000 30 | Ks 0.500000 0.500000 0.500000 31 | Ke 0.000000 0.000000 0.000000 32 | Ni 1.000000 33 | d 1.000000 34 | illum 2 35 | map_Kd auto_2_diffuse.png 36 | 37 | newmtl auto_20 38 | Ns 360.000000 39 | Ka 1.000000 1.000000 1.000000 40 | Kd 0.800000 0.800000 0.800000 41 | Ks 0.500000 0.500000 0.500000 42 | Ke 0.000000 0.000000 0.000000 43 | Ni 1.000000 44 | d 1.000000 45 | illum 2 46 | map_Kd auto_20_diffuse.png 47 | 48 | newmtl auto_20_0 49 | Ns 360.000000 50 | Ka 1.000000 1.000000 1.000000 51 | Kd 0.800000 0.800000 0.800000 52 | Ks 0.500000 0.500000 0.500000 53 | Ke 0.000000 0.000000 0.000000 54 | Ni 1.000000 55 | d 1.000000 56 | illum 2 57 | map_Kd auto_20_0_diffuse.png 58 | 59 | newmtl auto_6 60 | Ns 360.000000 61 | Ka 1.000000 1.000000 1.000000 62 | Kd 0.800000 0.800000 0.800000 63 | Ks 0.500000 0.500000 0.500000 64 | Ke 0.000000 0.000000 0.000000 65 | Ni 1.000000 66 | d 1.000000 67 | illum 2 68 | map_Kd auto_6_diffuse.png 69 | 70 | newmtl auto_8 71 | Ns 360.000000 72 | Ka 1.000000 1.000000 1.000000 73 | Kd 0.800000 0.800000 0.800000 74 | Ks 0.500000 0.500000 0.500000 75 | Ke 0.000000 0.000000 0.000000 76 | Ni 1.000000 77 | d 1.000000 78 | illum 2 79 | map_Kd auto_8_diffuse.png 80 | 81 | newmtl edge_color000255 82 | Ns 360.000000 83 | Ka 1.000000 1.000000 1.000000 84 | Kd 0.800000 0.800000 0.800000 85 | Ks 0.500000 0.500000 0.500000 86 | Ke 0.000000 0.000000 0.000000 87 | Ni 1.000000 88 | d 1.000000 89 | illum 2 -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/greenwoo92interior128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/greenwoo92interior128.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/greenwoo92wheel64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/greenwoo92wheel64.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/plateback3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/plateback3.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/platecharset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/platecharset.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehicledash32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehicledash32.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehiclegeneric256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehiclegeneric256.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehiclegrunge256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehiclegrunge256.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehiclegrunge256_primary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehiclegrunge256_primary.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehiclegrunge256_secondary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehiclegrunge256_secondary.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehiclelights128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehiclelights128.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehiclesteering128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehiclesteering128.png -------------------------------------------------------------------------------- /resources/obj/cars/greenwood/vehicletyres128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/cars/greenwood/vehicletyres128.png -------------------------------------------------------------------------------- /resources/obj/skybox/midday/MidSkyTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/skybox/midday/MidSkyTop.png -------------------------------------------------------------------------------- /resources/obj/skybox/midday/MidwayClouds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/skybox/midday/MidwayClouds.png -------------------------------------------------------------------------------- /resources/obj/skybox/midday/MidwaySkyBack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/skybox/midday/MidwaySkyBack.png -------------------------------------------------------------------------------- /resources/obj/skybox/midday/skybox1Shape.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl NC_sky_midway_m1 5 | Ns 0.000000 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 1.000000 1.000000 1.000000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 1.000000 12 | illum 2 13 | map_Kd MidwayClouds.png 14 | -------------------------------------------------------------------------------- /resources/obj/skybox/midday/skybox1Shape.obj: -------------------------------------------------------------------------------- 1 | # Blender v3.6.5 OBJ File: '' 2 | # www.blender.org 3 | mtllib skybox1Shape.mtl 4 | o skybox1Shape 5 | v -829.558289 478.945709 -0.000036 6 | v -677.331482 -49.204891 677.331482 7 | v -957.891296 -49.204941 0.000004 8 | v -586.586304 478.945740 586.586121 9 | v -0.000024 -49.204868 957.891296 10 | v 0.000000 478.945770 829.558228 11 | v 677.331482 -49.204891 677.331482 12 | v 586.586304 478.945740 586.586243 13 | v 957.891479 -49.204941 0.000004 14 | v 829.558289 478.945709 -0.000036 15 | v 957.891479 -49.204941 0.000004 16 | v 829.558289 478.945709 -0.000036 17 | v 677.331482 -49.204990 -677.331482 18 | v 586.586182 478.945679 -586.586365 19 | v 0.000000 -49.205013 -957.891296 20 | v 0.000000 478.945648 -829.558350 21 | v -677.331482 -49.204990 -677.331482 22 | v -586.586304 478.945679 -586.586365 23 | v -957.891296 -49.204941 0.000004 24 | v -829.558289 478.945709 -0.000036 25 | vt 2.000016 0.974079 26 | vt 1.250008 0.002339 27 | vt 2.000016 0.002339 28 | vt 1.250008 0.974079 29 | vt 0.500000 0.002339 30 | vt 0.500000 0.974079 31 | vt -0.250008 0.002339 32 | vt -0.250008 0.974079 33 | vt -1.000016 0.002339 34 | vt -1.000016 0.974079 35 | vt 2.000016 0.002339 36 | vt 2.000016 0.974079 37 | vt 1.250008 0.002339 38 | vt 1.250008 0.974079 39 | vt 0.500000 0.002339 40 | vt 0.500000 0.974079 41 | vt -0.250008 0.002339 42 | vt -0.250008 0.974079 43 | vt -1.000016 0.002339 44 | vt -1.000016 0.974079 45 | g skybox1Shape_skybox1Shape_NC_sky_midway_m1 46 | usemtl NC_sky_midway_m1 47 | s 1 48 | f 1/1 2/2 3/3 49 | f 2/2 1/1 4/4 50 | f 2/2 4/4 5/5 51 | f 5/5 4/4 6/6 52 | f 5/5 6/6 7/7 53 | f 7/7 6/6 8/8 54 | f 7/7 8/8 9/9 55 | f 9/9 8/8 10/10 56 | f 11/11 12/12 13/13 57 | f 13/13 12/12 14/14 58 | f 13/13 14/14 15/15 59 | f 15/15 14/14 16/16 60 | f 15/15 16/16 17/17 61 | f 17/17 16/16 18/18 62 | f 17/17 18/18 19/19 63 | f 19/19 18/18 20/20 64 | -------------------------------------------------------------------------------- /resources/obj/skybox/midday/skybox2Shape.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl NC_sky_midway_m2 5 | Ns 0.000000 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 1.000000 1.000000 1.000000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 1.000000 12 | illum 2 13 | map_Kd MidSkyTop.png 14 | -------------------------------------------------------------------------------- /resources/obj/skybox/midday/skybox2Shape.obj: -------------------------------------------------------------------------------- 1 | # Blender v3.6.5 OBJ File: '' 2 | # www.blender.org 3 | mtllib skybox2Shape.mtl 4 | o skybox2Shape 5 | v -628.557007 185.538498 -0.000014 6 | v -518.686523 0.000039 518.686523 7 | v -733.533508 0.000000 0.000000 8 | v -444.457886 185.538528 444.457886 9 | v -0.000018 0.000055 733.533508 10 | v 0.000000 185.538544 628.556885 11 | v 518.686584 0.000039 518.686523 12 | v 444.457886 185.538528 444.457886 13 | v 733.533630 0.000000 0.000000 14 | v 628.557129 185.538498 -0.000014 15 | v 733.533630 0.000000 0.000000 16 | v 628.557129 185.538498 -0.000014 17 | v 518.686523 -0.000039 -518.686523 18 | v 444.457886 185.538467 -444.457886 19 | v 0.000000 -0.000055 -733.533508 20 | v 0.000000 185.538452 -628.556885 21 | v -518.686523 -0.000039 -518.686523 22 | v -444.457886 185.538467 -444.457886 23 | v -733.533508 0.000000 0.000000 24 | v -628.557007 185.538498 -0.000014 25 | vt 2.000016 0.869124 26 | vt 1.250008 0.445046 27 | vt 2.000016 0.445046 28 | vt 1.250008 0.869124 29 | vt 0.500000 0.445046 30 | vt 0.500000 0.869124 31 | vt -0.250008 0.445046 32 | vt -0.250008 0.869124 33 | vt -1.000016 0.445046 34 | vt -1.000016 0.869124 35 | vt 2.000016 0.445046 36 | vt 2.000016 0.869124 37 | vt 1.250008 0.445046 38 | vt 1.250008 0.869124 39 | vt 0.500000 0.445046 40 | vt 0.500000 0.869124 41 | vt -0.250008 0.445046 42 | vt -0.250008 0.869124 43 | vt -1.000016 0.445046 44 | vt -1.000016 0.869124 45 | g skybox2Shape_skybox2Shape_NC_sky_midway_m2 46 | usemtl NC_sky_midway_m2 47 | s 1 48 | f 1/1 2/2 3/3 49 | f 2/2 1/1 4/4 50 | f 2/2 4/4 5/5 51 | f 5/5 4/4 6/6 52 | f 5/5 6/6 7/7 53 | f 7/7 6/6 8/8 54 | f 7/7 8/8 9/9 55 | f 9/9 8/8 10/10 56 | f 11/11 12/12 13/13 57 | f 13/13 12/12 14/14 58 | f 13/13 14/14 15/15 59 | f 15/15 14/14 16/16 60 | f 15/15 16/16 17/17 61 | f 17/17 16/16 18/18 62 | f 17/17 18/18 19/19 63 | f 19/19 18/18 20/20 64 | -------------------------------------------------------------------------------- /resources/obj/skybox/midday/skyboxShape.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl NC_sky_midway_m 5 | Ns 0.000000 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 1.000000 1.000000 1.000000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 1.000000 12 | illum 2 13 | map_Kd MidwaySkyBack.png 14 | -------------------------------------------------------------------------------- /resources/obj/skybox/midday/skyboxShape.obj: -------------------------------------------------------------------------------- 1 | # Blender v3.6.5 OBJ File: '' 2 | # www.blender.org 3 | mtllib skyboxShape.mtl 4 | o skyboxShape 5 | v 529.827576 966.644226 -0.000073 6 | v 0.000000 966.644287 529.827515 7 | v 0.000000 1039.767944 -0.000079 8 | v 648.903625 548.997986 648.903564 9 | v 917.688171 548.997925 -0.000041 10 | v 749.289429 0.000057 749.289307 11 | v 1059.655029 0.000000 0.000000 12 | v 0.000000 -492.206299 0.000037 13 | v -0.000026 0.000080 1059.655029 14 | v 0.000000 548.997986 917.688110 15 | v -648.903625 548.997986 648.903442 16 | v -529.827515 966.644226 -0.000073 17 | v 0.000000 1039.767944 -0.000079 18 | v 0.000000 966.644165 -529.827576 19 | v -529.827515 966.644226 -0.000073 20 | v -648.903625 548.997864 -648.903687 21 | v -917.688171 548.997925 -0.000041 22 | v -749.289307 -0.000057 -749.289307 23 | v -1059.655029 0.000000 0.000000 24 | v 0.000000 -0.000080 -1059.655029 25 | v 0.000000 548.997864 -917.688232 26 | v 648.903503 548.997864 -648.903687 27 | v 529.827576 966.644226 -0.000073 28 | v -1059.655029 0.000000 0.000000 29 | v -917.688171 548.997925 -0.000041 30 | v -749.289307 0.000057 749.289307 31 | v 0.000000 -492.206299 0.000037 32 | v 1059.655029 0.000000 0.000000 33 | v 917.688171 548.997925 -0.000041 34 | v 749.289307 -0.000057 -749.289307 35 | vt -1.000016 0.950000 36 | vt 0.500000 0.950000 37 | vt -0.250008 0.994965 38 | vt -0.250008 0.868832 39 | vt -1.000016 0.868832 40 | vt -0.250008 0.074845 41 | vt -1.000016 0.074845 42 | vt -0.250008 0.005000 43 | vt 0.500000 0.074845 44 | vt 0.500000 0.868832 45 | vt 1.250008 0.868832 46 | vt 2.000016 0.950000 47 | vt 1.250008 0.994965 48 | vt 0.500000 0.950000 49 | vt -1.000016 0.950000 50 | vt -0.250008 0.868832 51 | vt -1.000016 0.868832 52 | vt -0.250008 0.074845 53 | vt -1.000016 0.074845 54 | vt 0.500000 0.074845 55 | vt 0.500000 0.868832 56 | vt 1.250008 0.868832 57 | vt 2.000016 0.950000 58 | vt 2.000016 0.074845 59 | vt 2.000016 0.868832 60 | vt 1.250008 0.074845 61 | vt 1.250008 0.005000 62 | vt 2.000016 0.074845 63 | vt 2.000016 0.868832 64 | vt 1.250008 0.074845 65 | g skyboxShape_skyboxShape_NC_sky_midway_m 66 | usemtl NC_sky_midway_m 67 | s 1 68 | f 1/1 2/2 3/3 69 | f 2/2 1/1 4/4 70 | f 4/4 1/1 5/5 71 | f 4/4 5/5 6/6 72 | f 6/6 5/5 7/7 73 | f 6/6 7/7 8/8 74 | f 6/6 8/8 9/9 75 | f 6/6 9/9 10/10 76 | f 6/6 10/10 4/4 77 | f 4/4 10/10 2/2 78 | f 2/2 10/10 11/11 79 | f 2/2 11/11 12/12 80 | f 2/2 12/12 13/13 81 | f 14/14 3/3 15/15 82 | f 14/14 15/15 16/16 83 | f 16/16 15/15 17/17 84 | f 16/16 17/17 18/18 85 | f 18/18 17/17 19/19 86 | f 18/18 19/19 8/8 87 | f 18/18 8/8 20/20 88 | f 18/18 20/20 21/21 89 | f 18/18 21/21 16/16 90 | f 16/16 21/21 14/14 91 | f 14/14 21/21 22/22 92 | f 14/14 22/22 23/23 93 | f 14/14 23/23 13/13 94 | f 24/24 25/25 26/26 95 | f 24/24 26/26 27/27 96 | f 27/27 26/26 9/9 97 | f 9/9 26/26 10/10 98 | f 10/10 26/26 11/11 99 | f 11/11 26/26 25/25 100 | f 11/11 25/25 12/12 101 | f 28/28 29/29 30/30 102 | f 28/28 30/30 27/27 103 | f 27/27 30/30 20/20 104 | f 20/20 30/30 21/21 105 | f 21/21 30/30 22/22 106 | f 22/22 30/30 29/29 107 | f 22/22 29/29 23/23 108 | -------------------------------------------------------------------------------- /resources/obj/skybox/sunset/EgyptBack.bmp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/skybox/sunset/EgyptBack.bmp.png -------------------------------------------------------------------------------- /resources/obj/skybox/sunset/EgyptClouds.tga.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/skybox/sunset/EgyptClouds.tga.png -------------------------------------------------------------------------------- /resources/obj/skybox/sunset/EgyptHaze.tga.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/skybox/sunset/EgyptHaze.tga.png -------------------------------------------------------------------------------- /resources/obj/skybox/sunset/EgyptWisps.tga.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vectozavr/3dzavr/04cb1e438afb27c092b99262c99779fc3042e447/resources/obj/skybox/sunset/EgyptWisps.tga.png -------------------------------------------------------------------------------- /resources/obj/skybox/sunset/skybox.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 4 3 | 4 | newmtl NC_EgyptClouds_clouds1 5 | Ns 86.470578 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 1.000000 1.000000 1.000000 8 | Ks 0.000000 0.000000 0.000000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 0.000000 12 | illum 1 13 | map_Kd EgyptClouds.tga.png 14 | map_d EgyptClouds.tga.png 15 | 16 | newmtl NC_EgyptClouds_clouds2 17 | Ns 86.470578 18 | Ka 1.000000 1.000000 1.000000 19 | Kd 1.000000 1.000000 1.000000 20 | Ks 0.000000 0.000000 0.000000 21 | Ke 0.000000 0.000000 0.000000 22 | Ni 1.450000 23 | d 0.000000 24 | illum 1 25 | map_Kd EgyptWisps.tga.png 26 | map_d EgyptWisps.tga.png 27 | 28 | newmtl NC_EgyptHaze_clouds 29 | Ns 86.470578 30 | Ka 1.000000 1.000000 1.000000 31 | Kd 1.000000 1.000000 1.000000 32 | Ks 0.000000 0.000000 0.000000 33 | Ke 0.000000 0.000000 0.000000 34 | Ni 1.450000 35 | d 0.000000 36 | illum 1 37 | map_Kd EgyptHaze.tga.png 38 | map_d EgyptHaze.tga.png 39 | 40 | newmtl NC_Egypt_Back_Sky 41 | Ns 86.470578 42 | Ka 1.000000 1.000000 1.000000 43 | Kd 1.000000 1.000000 1.000000 44 | Ks 0.000000 0.000000 0.000000 45 | Ke 0.000000 0.000000 0.000000 46 | Ni 1.450000 47 | d 0.000000 48 | illum 1 49 | map_Kd EgyptBack.bmp.png 50 | map_d EgyptBack.bmp.png 51 | -------------------------------------------------------------------------------- /test_scenes/animations.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Test final : public Engine { 10 | private: 11 | std::shared_ptr _worldEditor; 12 | 13 | void start() override { 14 | _worldEditor = std::make_shared(screen, world, camera); 15 | 16 | auto car = world->loadObject(ObjectTag("car_1"), 17 | FilePath("resources/obj/cars/car1/Car1.obj")); 18 | car->getComponent()->rotate(Vec3D{0, Consts::PI, 0}); 19 | car->getComponent()->translate(Vec3D(0, 0, 10)); 20 | 21 | Timeline::addAnimation(0); 22 | Timeline::addAnimation(car->getComponent(), Vec3D(0), -3); 23 | Timeline::addAnimation(0); 24 | Timeline::addAnimation(car->getComponent(), Vec3D(0), 3); 25 | Timeline::addAnimation(0); 26 | 27 | auto carMesh = car->attached(ObjectTag("Car_car_mat_0")); 28 | if(carMesh) { 29 | Timeline::addAnimation(carMesh->getComponent(), 5); 30 | Timeline::addAnimation(0); 31 | Timeline::addAnimation(carMesh->getComponent(), 5); 32 | Timeline::addAnimation(0); 33 | Timeline::addAnimation(carMesh->getComponent(), 1); 34 | Timeline::addAnimation(0); 35 | Timeline::addAnimation(carMesh->getComponent(), -1); 36 | } 37 | 38 | Timeline::addAnimation(car->getComponent(), car->getComponent()->position(), Vec3D{0, 2*Consts::PI, 0}, 3); 39 | Timeline::addAnimation(0); 40 | Timeline::addAnimation(car->getComponent(), Vec3D{0, 2*Consts::PI, 0}, 2); 41 | Timeline::addAnimation(0); 42 | Timeline::addAnimation(car->getComponent(), 2*Consts::PI, 2); 43 | Timeline::addAnimation(0); 44 | Timeline::addAnimation(car->getComponent(), Vec3D(0, 0, 2*Consts::PI), 2); 45 | Timeline::addAnimation(car->getComponent(), Vec3D(1.5, 1.3, 0.4), 2); 46 | Timeline::addAnimation(0); 47 | Timeline::addAnimation(car->getComponent(), Vec3D(0, 0, 5)); 48 | Timeline::addAnimation(0); 49 | Timeline::addAnimation(car->getComponent(), Vec3D(0, 0, 15)); 50 | Timeline::addAnimation(0); 51 | Timeline::addAnimation([car](){ 52 | Log::log("Function test call"); 53 | car->getComponent()->translate(Vec3D(0, 0, 1)); 54 | }, 3, 5); 55 | 56 | 57 | auto dirLight = std::make_shared(ObjectTag("Directional Light 1")); 58 | dirLight->addComponent(Vec3D(1, -1, 1), Color::WHITE, 1.5); 59 | world->add(dirLight); 60 | }; 61 | 62 | void update() override { 63 | screen->setTitle("3dzavr, " + std::to_string(Time::fps()) + "fps"); 64 | 65 | _worldEditor->update(); 66 | 67 | if(Keyboard::isKeyTapped(SDLK_TAB)) { 68 | setDebugInfo(!showDebugInfo()); 69 | } 70 | }; 71 | 72 | public: 73 | Test() = default; 74 | }; 75 | 76 | int main(int argc, char *argv[]) { 77 | Test test; 78 | test.create(); 79 | return 0; 80 | } -------------------------------------------------------------------------------- /test_scenes/physics.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class Test final : public Engine { 9 | private: 10 | std::shared_ptr _worldEditor; 11 | 12 | void start() override { 13 | _worldEditor = std::make_shared(screen, world, camera); 14 | 15 | auto transparentYellow = std::make_shared(MaterialTag("yellow"), 16 | nullptr, Color(255, 200, 170, 100)); 17 | 18 | auto cube1 = std::make_shared(ObjectTag("cube_1")); 19 | cube1->addComponent()->setCollision(true); 20 | cube1->addComponent(TriangleMesh::Cube())->setMaterial(transparentYellow); 21 | 22 | //cube1->getComponent()->translate(Vec3D(-0.1, 0.45, 3.4)); 23 | cube1->getComponent()->translate(Vec3D(1, 0, 3)); 24 | 25 | world->add(cube1); 26 | 27 | auto cube2 = std::make_shared(ObjectTag("cube_2")); 28 | cube2->addComponent(); 29 | cube2->addComponent(TriangleMesh::Cube())->setMaterial(transparentYellow); 30 | 31 | cube2->getComponent()->translate(Vec3D(-1, 0, 3)); 32 | world->add(cube2); 33 | 34 | auto dirLight = std::make_shared(ObjectTag("Directional Light 1")); 35 | dirLight->addComponent(Vec3D(1, -1, 1), Color::WHITE, 1.5); 36 | world->add(dirLight); 37 | }; 38 | 39 | void update() override { 40 | screen->setTitle("3dzavr, " + std::to_string(Time::fps()) + "fps"); 41 | 42 | _worldEditor->update(); 43 | 44 | if(Keyboard::isKeyTapped(SDLK_TAB)) { 45 | setDebugInfo(!showDebugInfo()); 46 | } 47 | }; 48 | 49 | public: 50 | Test() = default; 51 | }; 52 | 53 | int main(int argc, char *argv[]) { 54 | Test test; 55 | test.create(); 56 | return 0; 57 | } 58 | --------------------------------------------------------------------------------