From bdf645a5270f72f275f566971a51be8b906f919e Mon Sep 17 00:00:00 2001 From: ZacharyH777 <93843297+ZacharyH777@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:46:51 -0800 Subject: [PATCH] Josh update branch (#63) * Josh update branch (#58) * build: successful editor build * Pushing MeshChanges * Changed and fixed the cmake list. Changed vulkan model, spriterenderer3d(unfinished) --------- Co-authored-by: Josh Aponte <38165111+JoshuaM928@users.noreply.github.com> Co-authored-by: ZacharyH777 <143478753+ZHowe1@users.noreply.github.com> Co-authored-by: Aaron <56617292+SpinnerX@users.noreply.github.com> --- CMakeLists.txt | 2 +- TestApp/CMakeLists.txt | 21 +++- .../Components/Bodies/BodyContainer.hpp | 11 -- .../Components/Bodies/Shapes/BoxShaper.hpp | 6 - .../Components/Bodies/Shapes/SphereShaper.hpp | 6 - .../Components/Physics/PhysicsBody3D.hpp | 34 ------ .../Scenes/Assets/Components/testComp.hpp | 16 --- .../SceneInstances/ShowCaseSceneInstance.hpp | 14 --- .../Components/Bodies/BodyContainer.cpp | 6 - .../Components/Bodies/Shapes/BoxShaper.cpp | 19 --- .../Components/Bodies/Shapes/SphereShaper.cpp | 21 ---- .../Components/Physics/PhysicsBody3D.cpp | 111 ------------------ .../src/Scenes/Assets/Components/testComp.cpp | 49 -------- .../SceneInstances/ShowCaseSceneInstance.cpp | 41 ------- .../Meshes/ChildrenMeshes/CubeMesh.hpp | 8 ++ .../Meshes/ChildrenMeshes/SphereMesh.hpp | 8 ++ .../Graphics/Meshes/MeshContainer.hpp | 18 +++ .../Components/Graphics/SpriteRender3D.hpp | 22 ++++ .../SceneInstances/ShowCaseSceneInstance.hpp | 1 + .../Meshes/ChildrenMeshes/CubeMesh.cpp | 80 +++++++++++++ .../Meshes/ChildrenMeshes/SphereMesh.cpp | 51 ++++++++ .../Graphics/Meshes/MeshContainer.cpp | 12 ++ .../Components/Graphics/SpriteRender3D.cpp | 34 ++++++ .../Components/Physics/PhysicsBody3D.cpp | 18 +-- .../src/Scenes/Assets/Components/testComp.cpp | 2 +- .../SceneInstances/ShowCaseSceneInstance.cpp | 11 +- conanfile.py | 7 +- .../internal/Vulkan2Showcase/VulkanModel.hpp | 5 +- src/CMakeLists.txt | 9 +- .../TimeManagement/GlobalUpdateManager.cpp | 4 +- .../internal/Vulkan2Showcase/VulkanModel.cpp | 28 +++++ 31 files changed, 307 insertions(+), 368 deletions(-) delete mode 100644 TestApp/SceneTest/Scenes/Assets/Components/Bodies/BodyContainer.hpp delete mode 100644 TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.hpp delete mode 100644 TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.hpp delete mode 100644 TestApp/SceneTest/Scenes/Assets/Components/Physics/PhysicsBody3D.hpp delete mode 100644 TestApp/SceneTest/Scenes/Assets/Components/testComp.hpp delete mode 100644 TestApp/SceneTest/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp delete mode 100644 TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/BodyContainer.cpp delete mode 100644 TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.cpp delete mode 100644 TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.cpp delete mode 100644 TestApp/SceneTest/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp delete mode 100644 TestApp/SceneTest/src/Scenes/Assets/Components/testComp.cpp delete mode 100644 TestApp/SceneTest/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp create mode 100644 TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp create mode 100644 TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp create mode 100644 TestApp/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.hpp create mode 100644 TestApp/Scenes/Assets/Components/Graphics/SpriteRender3D.hpp create mode 100644 TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.cpp create mode 100644 TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.cpp create mode 100644 TestApp/src/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.cpp create mode 100644 TestApp/src/Scenes/Assets/Components/Graphics/SpriteRender3D.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 46550a7..7024885 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,4 +6,4 @@ set(ENGINE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/engine3d) build_library( DIRECTORIES src Editor TestApp -) +) \ No newline at end of file diff --git a/TestApp/CMakeLists.txt b/TestApp/CMakeLists.txt index 7cf153b..bb6e9a7 100644 --- a/TestApp/CMakeLists.txt +++ b/TestApp/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 3.25) project(TestApp CXX) -set(SCENE_TEST_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/SceneTest) - build_demos( SOURCES Application.cpp @@ -30,8 +28,19 @@ build_demos( Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp - LINK_LIBRARIES engine3d -) + #Graphics + Scenes/Assets/Components/Graphics/SpriteRender3D.hpp + src/Scenes/Assets/Components/Graphics/SpriteRender3D.cpp -# target_include_directories(${PROJECT_NAME} PUBLIC ${SCENE_TEST_INCLUDE_DIR}) -target_include_directories(${PROJECT_NAME} PUBLIC ./ ../) + #Graphics Meshes ChildrenMeshes + Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp + src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.cpp + Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp + # src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.cpp + src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.cpp + Scenes/Assets/Components/Graphics/Meshes/MeshContainer.hpp + src/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.cpp + + + LINK_LIBRARIES engine3d +) \ No newline at end of file diff --git a/TestApp/SceneTest/Scenes/Assets/Components/Bodies/BodyContainer.hpp b/TestApp/SceneTest/Scenes/Assets/Components/Bodies/BodyContainer.hpp deleted file mode 100644 index 2fcd601..0000000 --- a/TestApp/SceneTest/Scenes/Assets/Components/Bodies/BodyContainer.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -// Jolt Includes -class BodyContainer -{ - public: - BodyContainer(); - - operator JPH::BodyID() { return m_BodyID; } - JPH::BodyCreationSettings m_BodySettings; - JPH::BodyID m_BodyID; -}; \ No newline at end of file diff --git a/TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.hpp b/TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.hpp deleted file mode 100644 index 5ec67a1..0000000 --- a/TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -class BoxShaper : public BodyContainer -{ - public: - BoxShaper(); -}; \ No newline at end of file diff --git a/TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.hpp b/TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.hpp deleted file mode 100644 index 472f82d..0000000 --- a/TestApp/SceneTest/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -class SphereShaper : public BodyContainer -{ - public: - SphereShaper(); -}; \ No newline at end of file diff --git a/TestApp/SceneTest/Scenes/Assets/Components/Physics/PhysicsBody3D.hpp b/TestApp/SceneTest/Scenes/Assets/Components/Physics/PhysicsBody3D.hpp deleted file mode 100644 index 4b4fc6c..0000000 --- a/TestApp/SceneTest/Scenes/Assets/Components/Physics/PhysicsBody3D.hpp +++ /dev/null @@ -1,34 +0,0 @@ - -#pragma once - -#include "Core/SceneManagment/Components/GameComponent.hpp" -#include -#include -#include -#include - -#include -// This is a test version of this class as there is to much -class PhysicsBody3D: public engine3d::GameComponent -{ - public: - PhysicsBody3D(BodyContainer * p_bodyCon); - ~PhysicsBody3D(); - void OnIntegrate(); - void Update(); - void LateUpdate(); - void PhysicsUpdate(); - void Begin(); - BodyContainer* GetBody(); - - void SetScale(float x, float y, float z); - void SetPosition(float x, float y, float z); - void SetRotation(Quat quaternion); - - private: - engine3d::Transform* m_Transform; - PhysicsBody3D() = default; - BodyContainer * bodyType; - JPH::BodyInterface* m_interface; - bool once = false; -}; diff --git a/TestApp/SceneTest/Scenes/Assets/Components/testComp.hpp b/TestApp/SceneTest/Scenes/Assets/Components/testComp.hpp deleted file mode 100644 index f0cf5d5..0000000 --- a/TestApp/SceneTest/Scenes/Assets/Components/testComp.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "Scenes/Assets/Components/Physics/PhysicsBody3D.hpp" -#include - - class testComp : public engine3d::GameComponent - { - public: - void OnIntegrate(); - void Update(); - void LateUpdate(); - void PhysicsUpdate(); - private: - bool t_Secret = false; - BodyContainer * m_rb; - }; \ No newline at end of file diff --git a/TestApp/SceneTest/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp b/TestApp/SceneTest/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp deleted file mode 100644 index 2195ca0..0000000 --- a/TestApp/SceneTest/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "Core/ApplicationManager/Scene.hpp" -#include "Core/SceneManagment/SceneObjects/SceneObject.hpp" -class ShowCaseSceneInstance -{ - public: - ShowCaseSceneInstance(); - ~ShowCaseSceneInstance(); - engine3d::Scene* m_Scene; - std::vector m_SceneObjects; - engine3d::Scene* GetScene(); - - private: - void CreateObjects(); -}; \ No newline at end of file diff --git a/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/BodyContainer.cpp b/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/BodyContainer.cpp deleted file mode 100644 index a4284db..0000000 --- a/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/BodyContainer.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -BodyContainer::BodyContainer() -{ - // will add more settings and configurations later -} diff --git a/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.cpp b/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.cpp deleted file mode 100644 index 566bb88..0000000 --- a/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -using namespace JPH; -using namespace JPH::literals; -using namespace engine3d; -BoxShaper::BoxShaper() -{ - JoltHandler * temp = engine3d::JoltHandler::GetInstance(); - m_BodySettings = BodyCreationSettings( - temp->m_BoxShapeScaled, - RVec3(0.0_r, -1.0_r, 0.0_r), - Quat::sIdentity(), - EMotionType::Static, - Engine3DLayers::Static - ); - - m_BodyID = temp->getInterface()->CreateAndAddBody( - m_BodySettings, - EActivation::DontActivate); -} \ No newline at end of file diff --git a/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.cpp b/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.cpp deleted file mode 100644 index eec65a1..0000000 --- a/TestApp/SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -using namespace JPH; -using namespace JPH::literals; -using namespace engine3d; -SphereShaper::SphereShaper() -{ - JoltHandler * temp = engine3d::JoltHandler::GetInstance(); - - - m_BodySettings = BodyCreationSettings( - temp->m_SphereShapeScaled, - RVec3(0.0_r, 4.0_r, 0.0_r), - Quat::sIdentity(), - EMotionType::Dynamic, - Engine3DLayers::Dynamic - ); - - m_BodyID = temp->getInterface()->CreateAndAddBody( - m_BodySettings, - EActivation::Activate); -} \ No newline at end of file diff --git a/TestApp/SceneTest/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp b/TestApp/SceneTest/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp deleted file mode 100644 index 3701bd8..0000000 --- a/TestApp/SceneTest/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include -using namespace engine3d; -PhysicsBody3D::PhysicsBody3D(BodyContainer * p_bodyCon) -{ - bodyType = p_bodyCon; -} - -void PhysicsBody3D::OnIntegrate() -{ - SyncUpdateManager::GetInstance()->Subscribe - (this, &PhysicsBody3D::Update); - SyncUpdateManager::GetInstance()->Subscribe - (this, &PhysicsBody3D::LateUpdate); - SyncUpdateManager::GetInstance()->Subscribe - (this, &PhysicsBody3D::PhysicsUpdate); - - // Probably should be an event or called when activated - //! @note For now just calling Begin on integrate - - Begin(); -} - -void PhysicsBody3D::Begin() -{ - m_interface = engine3d::JoltHandler::GetInstance()->getInterface(); - m_Transform = &m_GameObjectRef->SceneGetComponent(); -} - -void PhysicsBody3D::Update() -{ - - //Convert Posiitons - m_Transform->m_Position.x = m_interface-> - GetCenterOfMassPosition(bodyType->m_BodyID).GetX(); - m_Transform->m_Position.y = m_interface-> - GetCenterOfMassPosition(bodyType->m_BodyID).GetY(); - m_Transform->m_Position.z = m_interface-> - GetCenterOfMassPosition(bodyType->m_BodyID).GetZ(); - - //Convert Rotations - m_Transform->m_QuaterionRot.x = m_interface-> - GetRotation(bodyType->m_BodyID).GetX(); - m_Transform->m_QuaterionRot.y = m_interface-> - GetRotation(bodyType->m_BodyID).GetY(); - m_Transform->m_QuaterionRot.z = m_interface-> - GetRotation(bodyType->m_BodyID).GetZ(); - m_Transform->m_QuaterionRot.w = m_interface-> - GetRotation(bodyType->m_BodyID).GetW(); - - //Convert Rotations - m_Transform->m_AxisRotation.x = m_interface-> - GetRotation(bodyType->m_BodyID).GetEulerAngles().GetX(); - m_Transform->m_AxisRotation.y = m_interface-> - GetRotation(bodyType->m_BodyID).GetEulerAngles().GetY(); - m_Transform->m_AxisRotation.z = m_interface-> - GetRotation(bodyType->m_BodyID).GetEulerAngles().GetZ(); - - // std::print("Rotation: (X: {0}, Y: {1}, Z: {2})\n", - // m_Transform->m_AxisRotation.x, - // m_Transform->m_AxisRotation.y, - // m_Transform->m_AxisRotation.z); - -} - -void PhysicsBody3D::SetScale(float x, float y, float z) -{ - m_interface->GetShape(bodyType->m_BodyID)->ScaleShape(RVec3(x,y,z)); -} - -void PhysicsBody3D::SetPosition(float x, float y, float z) -{ - m_interface->SetPosition( - bodyType->m_BodyID, - RVec3(x,y,z), - JPH::EActivation::Activate); -} - -void PhysicsBody3D::SetRotation(Quat quaternion) -{ - m_interface->SetRotation( - bodyType->m_BodyID, - quaternion, - JPH::EActivation::Activate); -} - -void PhysicsBody3D::LateUpdate() -{ - -} - -void PhysicsBody3D::PhysicsUpdate() -{ - -} - -BodyContainer* PhysicsBody3D::GetBody() -{ - return bodyType; -} - -PhysicsBody3D::~PhysicsBody3D() -{ - delete bodyType; -} \ No newline at end of file diff --git a/TestApp/SceneTest/src/Scenes/Assets/Components/testComp.cpp b/TestApp/SceneTest/src/Scenes/Assets/Components/testComp.cpp deleted file mode 100644 index 91a6bc4..0000000 --- a/TestApp/SceneTest/src/Scenes/Assets/Components/testComp.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// #include -#include "Core/SceneManagment/Components/GameComponent.hpp" -#include "Physics/JoltHandler.hpp" -#include "Scenes/Assets/Components/Physics/PhysicsBody3D.hpp" -#include -#include -#include -#include -#include -#include -// #include "Scene" - -using namespace engine3d; - void testComp::OnIntegrate() - {; - SyncUpdateManager::GetInstance()->Subscribe - (this, &testComp::Update); - SyncUpdateManager::GetInstance()->Subscribe - (this, &testComp::LateUpdate); - SyncUpdateManager::GetInstance()->Subscribe - (this, &testComp::PhysicsUpdate); - - // Need an activation and start funciton - m_rb = m_GameObjectRef->SceneGetComponent().GetBody(); - - } - - void testComp::Update() - { - if(InputPoll::IsKeyPressed(KeyCode::F5)) - { - JoltHandler::GetInstance()-> - getInterface()->AddForce( - m_rb->m_BodyID, - RVec3(0.0f,100000.0f,0.0f), - EActivation::Activate - ); - } - } - - void testComp::LateUpdate() - { - - } - - void testComp::PhysicsUpdate() - { - - } \ No newline at end of file diff --git a/TestApp/SceneTest/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp b/TestApp/SceneTest/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp deleted file mode 100644 index 1e2706e..0000000 --- a/TestApp/SceneTest/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "Core/ApplicationManager/Scene.hpp" -#include "Core/SceneManagment/SceneObjects/SceneObject.hpp" -#include "Scenes/Assets/Components/Physics/PhysicsBody3D.hpp" -#include "Scenes/Assets/Components/testComp.hpp" -#include -#include -#include - -ShowCaseSceneInstance::ShowCaseSceneInstance() -{ - m_Scene = new engine3d::Scene(); - printf("getting here\n"); - CreateObjects(); - -} - -void ShowCaseSceneInstance::CreateObjects() -{ - //Platform - m_SceneObjects.push_back(new engine3d::SceneObject(m_Scene)); - BodyContainer * l_Body = new BoxShaper(); - m_SceneObjects[0]->AddComponent(l_Body); - m_SceneObjects[0]->name = "Platform1"; - - //Sphere - m_SceneObjects.push_back(new engine3d::SceneObject(m_Scene)); - l_Body = new SphereShaper(); - m_SceneObjects[1]->AddComponent(l_Body); - m_SceneObjects[1]->AddComponent(); - m_SceneObjects[1]->name = "Ball"; - -} - -ShowCaseSceneInstance::~ShowCaseSceneInstance() -{ - delete m_Scene; - for(auto obj : m_SceneObjects) - { - delete obj; - } -} \ No newline at end of file diff --git a/TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp b/TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp new file mode 100644 index 0000000..ef91d32 --- /dev/null +++ b/TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp @@ -0,0 +1,8 @@ +#pragma once +#include +class CubeMesh : public MeshContainer +{ + public: + CubeMesh(); + +}; \ No newline at end of file diff --git a/TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp b/TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp new file mode 100644 index 0000000..554f674 --- /dev/null +++ b/TestApp/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp @@ -0,0 +1,8 @@ +#pragma once +#include + +class SphereMesh : public MeshContainer +{ + public: + SphereMesh(int Radius, int SectorCount, int StackCount); +}; \ No newline at end of file diff --git a/TestApp/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.hpp b/TestApp/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.hpp new file mode 100644 index 0000000..8491f0c --- /dev/null +++ b/TestApp/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.hpp @@ -0,0 +1,18 @@ +#pragma once +#include +#include +#include +//! @brief Factory +class MeshContainer +{ + public: + MeshContainer() = default; + std::vector* GetVertices(){return vertices;} + std::vector GetNormals(){return normals;} + std::vector GettexCoords(){return texCoords;} + + protected: + std::vector* vertices; + std::vector normals; + std::vector texCoords; +}; \ No newline at end of file diff --git a/TestApp/Scenes/Assets/Components/Graphics/SpriteRender3D.hpp b/TestApp/Scenes/Assets/Components/Graphics/SpriteRender3D.hpp new file mode 100644 index 0000000..d04dc5f --- /dev/null +++ b/TestApp/Scenes/Assets/Components/Graphics/SpriteRender3D.hpp @@ -0,0 +1,22 @@ + +#include +#include +#include + +class SpriteRender3D : public engine3d::GameComponent +{ + public: + SpriteRender3D(MeshContainer* meshBody); + void OnIntegrate(); + void Update(); + void LateUpdate(); + void PhysicsUpdate(); + std::vector vertices; + std::vector normals; + std::vector texCoords; + + private: + MeshContainer* m_MeshContainer; + engine3d::Transform m_Transform; + glm::vec3* m_TransformPosition; +}; \ No newline at end of file diff --git a/TestApp/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp b/TestApp/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp index 5572927..8797153 100644 --- a/TestApp/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp +++ b/TestApp/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp @@ -1,4 +1,5 @@ #include "Core/ApplicationManager/Scene.hpp" + // #include "Core/SceneManagment/SceneObjects/SceneObject.hpp" diff --git a/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.cpp b/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.cpp new file mode 100644 index 0000000..a3cedb6 --- /dev/null +++ b/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.cpp @@ -0,0 +1,80 @@ + +#include "Core/internal/Vulkan2Showcase/VulkanModel.hpp" +#include +#include +#include + +CubeMesh::CubeMesh() +{ + std::vector verts = + { + {.5f, -.5f, -.5f}, + {.5f, -.5f, .5f}, + {.5f, -.5f, -.5f}, + {.5f, .5f, -.5f}, + {.5f, .5f, .5f}, + {-.5f, -.5f, -.5}, + {.5f, -.5f, .5f}, + {-.5f, -.5f, .5f}, + {-.5f, -.5f, -.5}, + {.5f, -.5f, -.5f}, + {.5f, -.5f, .5f}, + {-.5f, .5f, -.5f}, + {.5f, .5f, .5f}, + {-.5f, .5f, .5f}, + {-.5f, .5f, -.5f}, + {.5f, .5f, -.5f}, + {.5f, .5f, .5f}, + {-.5f, -.5f, 0.5}, + {.5f, .5f, 0.5f}, + {-.5f, .5f, 0.5f}, + {-.5f, -.5f, 0.5}, + {.5f, -.5f, 0.5f}, + {.5f, .5f, 0.5f}, + {-.5f, -.5f, -0.5}, + {.5f, .5f, -0.5f}, + {-.5f, .5f, -0.5}, + {-.5f, -.5f, -0.5}, + {.5f, -.5f, -0.5}, + {.5f, .5f, -0.5f} + + }; + + std::vector colors = + { + {.8f, .8f, .1f}, + {.8f, .8f, .1f}, + {.8f, .8f, .1f}, + {.8f, .8f, .1f}, + {.8f, .8f, .1f}, + {.9f, .6f, .1f}, + {.9f, .6f, .1f}, + {.9f, .6f, .1f}, + {.9f, .6f, .1f}, + {.9f, .6f, .1f}, + {.9f, .6f, .1f}, + {.8f, .1f, .1f}, + {.8f, .1f, .1f}, + {.8f, .1f, .1f}, + {.8f, .1f, .1f}, + {.8f, .1f, .1f}, + {.8f, .1f, .1f}, + + {.1f, .1f, .8f}, + {.1f, .1f, .8f}, + {.1f, .1f, .8f}, + {.1f, .1f, .8f}, + {.1f, .1f, .8f}, + {.1f, .1f, .8f}, + + {.1f, .8f, .1}, + {.1f, .8f, .1f}, + {.1f, .8f, .1f}, + {.1f, .8f, .1}, + {.1f, .8f, .1f}, + {.1f, .8f, .1f} + }; + + vertices = engine3d::vk::VulkanModel::CreateVertexVector(verts, colors); + +} diff --git a/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.cpp b/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.cpp new file mode 100644 index 0000000..58bbc1d --- /dev/null +++ b/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.cpp @@ -0,0 +1,51 @@ +#include "Core/internal/Vulkan2Showcase/VulkanModel.hpp" +#include +#include +SphereMesh::SphereMesh(int Radius, int SectorCount, int StackCount) +{ + + std::vector verts; + std::vector().swap(normals); + std::vector().swap(verts); + std::vector().swap(texCoords); + float nx, ny, nz, LengthInv = 1.0f / Radius; //vertex normal + float x, y, z, xy; //vertex position + float s, t; //vertex texCoord + float SectorStep = 2 * std::numbers::pi / SectorCount; + float StackStep = std::numbers::pi / StackCount; + float SectorAngle, StackAngle; + for(int i = 0; i <= StackCount; ++i) + { + // starting from pi/2 to -pi/2 + StackAngle = std::numbers::pi / 2 - i * StackStep; + xy = Radius * cosf(StackAngle); // r * cos(u) + z = Radius * sinf(StackAngle); // r * sin(u) + + // add (SectorCount+1) vertices per stack + // first and last vertices have same position + // and normal, but different tex coords + for(int j = 0; j <= SectorCount; ++j) + { + + SectorAngle = j * SectorStep; // starting from 0 to 2pi + + // vertex position (x, y, z) + x = xy * cosf(SectorAngle); // r * cos(u) * cos(v) + y = xy * sinf(SectorAngle); // r * cos(u) * sin(v) + verts.push_back(glm::vec3(x,y,z)); + + // normalized vertex normal (nx, ny, nz) + nx = x * LengthInv; + ny = y * LengthInv; + nz = z * LengthInv; + normals.push_back(glm::vec3(nx,ny,nz)); + + // vertex tex coord (s, t) range between [0, 1] + s = (float)j / SectorCount; + t = (float)i / StackCount; + texCoords.push_back(glm::vec2(s,t)); + } + } + + vertices = engine3d::vk::VulkanModel::CreateVertexVector(verts); +} \ No newline at end of file diff --git a/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.cpp b/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.cpp new file mode 100644 index 0000000..efab518 --- /dev/null +++ b/TestApp/src/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.cpp @@ -0,0 +1,12 @@ +#include +#include +// void MeshContainer::SphereBlueprint() +// { +// // For loop is used for printing out the position vectors +// for (auto position : vertices) +// { +// ConsoleLogInfo("vector positions: ({0}, {1}, {2})", position.x, +// position.y, position.z); +// } +//}; + diff --git a/TestApp/src/Scenes/Assets/Components/Graphics/SpriteRender3D.cpp b/TestApp/src/Scenes/Assets/Components/Graphics/SpriteRender3D.cpp new file mode 100644 index 0000000..dea4607 --- /dev/null +++ b/TestApp/src/Scenes/Assets/Components/Graphics/SpriteRender3D.cpp @@ -0,0 +1,34 @@ +#include +// #include "Scene" + +using namespace engine3d; + const int Radius = 1; + const int SectorCount = 10; + const int StackCount = 10; + +SpriteRender3D::SpriteRender3D(MeshContainer* meshBody) : m_MeshContainer(meshBody){} + +void SpriteRender3D::OnIntegrate() +{ + + SyncUpdateManager::GetInstance()->Subscribe( + this, &SpriteRender3D::Update); + SyncUpdateManager::GetInstance()->Subscribe + (this, &SpriteRender3D::LateUpdate); + SyncUpdateManager::GetInstance()->Subscribe( + this, &SpriteRender3D::PhysicsUpdate); + + // Need an activation and start fuction + m_Transform = m_GameObjectRef->SceneGetComponent(); + m_TransformPosition = &m_Transform.m_Position; +}; + +void SpriteRender3D::Update() +{ + //! @note needs to be sent to the vulkanmodal + m_MeshContainer->GetVertices(); +}; + +void SpriteRender3D::LateUpdate() {}; + +void SpriteRender3D::PhysicsUpdate() {}; \ No newline at end of file diff --git a/TestApp/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp b/TestApp/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp index e5bfc6b..ce97f59 100644 --- a/TestApp/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp +++ b/TestApp/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp @@ -1,12 +1,9 @@ #include - #include -#include #include -#include -#include #include using namespace engine3d; + PhysicsBody3D::PhysicsBody3D(BodyContainer * p_bodyCon) { bodyType = p_bodyCon; @@ -30,12 +27,15 @@ void PhysicsBody3D::OnIntegrate() void PhysicsBody3D::Begin() { m_interface = engine3d::JoltHandler::GetInstance()->getInterface(); - // m_Transform = &m_GameObjectRef->SceneGetComponent(); - // m_Transform = m_GameObjectRef + m_Transform = &m_GameObjectRef->SceneGetComponent(); } void PhysicsBody3D::Update() { + m_Transform->m_Position.x = m_interface->GetCenterOfMassPosition(bodyType->m_BodyID).GetX(); + m_Transform->m_Position.y = m_interface->GetCenterOfMassPosition(bodyType->m_BodyID).GetY(); + m_Transform->m_Position.z = m_interface->GetCenterOfMassPosition(bodyType->m_BodyID).GetZ(); + //Convert Posiitons m_Transform->m_Position.x = m_interface-> @@ -62,12 +62,6 @@ void PhysicsBody3D::Update() GetRotation(bodyType->m_BodyID).GetEulerAngles().GetY(); m_Transform->m_AxisRotation.z = m_interface-> GetRotation(bodyType->m_BodyID).GetEulerAngles().GetZ(); - - // std::print("Rotation: (X: {0}, Y: {1}, Z: {2})\n", - // m_Transform->m_AxisRotation.x, - // m_Transform->m_AxisRotation.y, - // m_Transform->m_AxisRotation.z); - } void PhysicsBody3D::SetScale(float x, float y, float z) diff --git a/TestApp/src/Scenes/Assets/Components/testComp.cpp b/TestApp/src/Scenes/Assets/Components/testComp.cpp index 1afa5bd..91a6bc4 100644 --- a/TestApp/src/Scenes/Assets/Components/testComp.cpp +++ b/TestApp/src/Scenes/Assets/Components/testComp.cpp @@ -21,7 +21,7 @@ using namespace engine3d; (this, &testComp::PhysicsUpdate); // Need an activation and start funciton - // m_rb = m_GameObjectRef->SceneGetComponent().GetBody(); + m_rb = m_GameObjectRef->SceneGetComponent().GetBody(); } diff --git a/TestApp/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp b/TestApp/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp index 603a92b..43ebc28 100644 --- a/TestApp/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp +++ b/TestApp/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp @@ -6,10 +6,14 @@ #include #include +#include +#include +#include + + ShowCaseSceneInstance::ShowCaseSceneInstance() { m_Scene = new engine3d::Scene(); - printf("getting here\n"); CreateObjects(); } @@ -26,6 +30,11 @@ void ShowCaseSceneInstance::CreateObjects() m_SceneObjects.push_back(new engine3d::SceneObject(m_Scene)); l_Body = new SphereShaper(); m_SceneObjects[1]->AddComponent(l_Body); + + // why is l_Mesh assigned the address of SphereMesh() + // the first index of m_SceneObjects is assigned the value of + // SpriteRender3D instance?? But what does l_mesh do in this line? + m_SceneObjects[1]->AddComponent(); m_SceneObjects[1]->name = "Ball"; diff --git a/conanfile.py b/conanfile.py index 88f7b45..3e77402 100644 --- a/conanfile.py +++ b/conanfile.py @@ -102,9 +102,4 @@ def package(self): def package_info(self): self.cpp_info.set_property("cmake_target_name", "engine3d::engine3d") self.cpp_info.libs = ["engine3d"] - self.cpp_info.includedirs = ['./', './engine3d'] # Ordered list of include paths - - - - - + self.cpp_info.includedirs = ['./', './engine3d'] # Ordered list of include paths \ No newline at end of file diff --git a/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.hpp b/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.hpp index e8a8a29..daf1ccc 100644 --- a/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.hpp +++ b/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.hpp @@ -1,4 +1,5 @@ #pragma once +#include #include #include @@ -30,7 +31,9 @@ namespace engine3d::vk{ void Bind(VkCommandBuffer p_Command); void Draw(VkCommandBuffer p_Command); - + static std::vector* CreateVertexVector(std::vector p_Vertices, std::vector p_Colors); + static std::vector* CreateVertexVector(std::vector p_Vertices); + private: void initialize_vertex_buffers(const std::vector& p_Vertices); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a29ffa6..8c3377c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,9 +7,10 @@ set(VULKAN_SRC_DIR ${ENGINE_SRC_DIR}/Core/internal/Vulkan2Showcase) set(VULKAN_SHADERS_INCLUDE_DIR ${VULKAN_INCLUDE_DIR}/Shaders) set(VULKAN_SHADERS_SRC_DIR ${VULKAN_SRC_DIR}/Shaders) -add_library( - ${PROJECT_NAME} - ${ENGINE_INCLUDE_NAME}/Core/ApplicationInstance.hpp + +build_library( + SOURCES + ${ENGINE_SRC_DIR}/Core/ApplicationInstance.cpp ${ENGINE_INCLUDE_NAME}/Core/EngineLogger.hpp ${ENGINE_INCLUDE_NAME}/Core/Window.hpp @@ -113,4 +114,4 @@ add_library( ${ENGINE_SRC_DIR}/Math/Interpolation.cpp ${ENGINE_SRC_DIR}/Physics/JoltHandler.cpp -) +) \ No newline at end of file diff --git a/src/engine3d/Core/TimeManagement/GlobalUpdateManager.cpp b/src/engine3d/Core/TimeManagement/GlobalUpdateManager.cpp index 0505f85..6281e57 100644 --- a/src/engine3d/Core/TimeManagement/GlobalUpdateManager.cpp +++ b/src/engine3d/Core/TimeManagement/GlobalUpdateManager.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -33,8 +34,7 @@ namespace engine3d m_GlobalDeltaTime = 0.0; m_UpdateTime = m_GlobalTimer->GetCurrentTime(); - // m_MaxFPS = 5000; - m_MaxFPS = 500; + m_MaxFPS = 100; m_FPSCounter = 1; //! @note syncupdatemanager will not work until the thread manager works. diff --git a/src/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.cpp b/src/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.cpp index 12a2857..c99705c 100644 --- a/src/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.cpp +++ b/src/engine3d/Core/internal/Vulkan2Showcase/VulkanModel.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include namespace engine3d::vk{ @@ -106,4 +107,31 @@ namespace engine3d::vk{ return attribute_description; } + std::vector* VulkanModel::CreateVertexVector + (std::vector p_Vertices, std::vector p_Colors) + { + std::vector* temp = new std::vector; + int i = 0; + for(auto verticies : p_Vertices) + { + //! if does not work vertex needs a constructor + temp[i].push_back(VulkanModel::Vertex(p_Vertices[i], p_Colors[i])); + i++; + } + return temp; + } + + std::vector* VulkanModel::CreateVertexVector + (std::vector p_Vertices) + { + std::vector* temp = new std::vector; + int i = 0; + for(auto verticies : p_Vertices) + { + //! if does not work vertex needs a constructor + temp[i].push_back(VulkanModel::Vertex(p_Vertices[i], {1.0f,1.0f,1.0f})); + i++; + } + return temp; + } }; \ No newline at end of file