Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Josh update branch #58

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TestApp/Application.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Core/EngineLogger.hpp"
#include <engine3d/Core/ApplicationInstance.hpp>
#include "SceneTest/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp"
#include "Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp"
#include <string>

namespace engine3d{
Expand Down
71 changes: 34 additions & 37 deletions TestApp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,79 +1,76 @@
cmake_minimum_required(VERSION 3.15)
project(TestApp CXX)


# find_package(Vulkan REQUIRED)

# find_package(engine3d CONFIG REQUIRED)
add_executable(${PROJECT_NAME}
Application.cpp

#To Test
SceneTest/Scenes/Assets/Components/testComp.hpp
SceneTest/src/Scenes/Assets/Components/testComp.cpp
Scenes/Assets/Components/testComp.hpp
src/Scenes/Assets/Components/testComp.cpp

#Physics
SceneTest/Scenes/Assets/Components/Physics/PhysicsBody3D.hpp
SceneTest/src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp
Scenes/Assets/Components/Physics/PhysicsBody3D.hpp
src/Scenes/Assets/Components/Physics/PhysicsBody3D.cpp

SceneTest/Scenes/Assets/Components/Bodies/BodyContainer.hpp
SceneTest/src/Scenes/Assets/Components/Bodies/BodyContainer.cpp
Scenes/Assets/Components/Bodies/BodyContainer.hpp
src/Scenes/Assets/Components/Bodies/BodyContainer.cpp


#Body Shapes
SceneTest/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.hpp
SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.cpp
Scenes/Assets/Components/Bodies/Shapes/BoxShaper.hpp
src/Scenes/Assets/Components/Bodies/Shapes/BoxShaper.cpp

SceneTest/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.hpp
SceneTest/src/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.cpp
Scenes/Assets/Components/Bodies/Shapes/SphereShaper.hpp
src/Scenes/Assets/Components/Bodies/Shapes/SphereShaper.cpp

#Scenes
SceneTest/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp
SceneTest/src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp

Scenes/Assets/SceneInstances/ShowCaseSceneInstance.hpp
src/Scenes/Assets/SceneInstances/ShowCaseSceneInstance.cpp

#Graphics
Scenes/Assets/Components/Graphics/SpriteRender3D.hpp
src/Scenes/Assets/Components/Graphics/SpriteRender3D.cpp

#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

)
)

target_include_directories(${PROJECT_NAME} PUBLIC SceneTest)
target_include_directories(${PROJECT_NAME} PUBLIC ./ SceneTest)
target_include_directories(${PROJECT_NAME} PRIVATE ../)

target_compile_definitions(${PROJECT_NAME} PRIVATE ${dev_definitions})

find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)

find_package(Vulkan REQUIRED)
find_package(VulkanHeaders REQUIRED)

if(LINUX)
find_package(VulkanLoader REQUIRED)
endif(LINUX)

# target_include_directories(${PROJECT_NAME} PUBLIC ${ENGINE_INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ../)
find_package(glm REQUIRED)
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
find_package(glm REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(imguidocking REQUIRED)
find_package(box2d REQUIRED)
find_package(Vulkan REQUIRED)
find_package(joltphysics REQUIRED)
find_package(EnTT REQUIRED)
find_package(imguidocking REQUIRED)


target_link_libraries(
${PROJECT_NAME}
PRIVATE
glfw
${OPENGL_LIBRARIES}
Vulkan::Vulkan
vulkan-headers::vulkan-headers
glm::glm
fmt::fmt
spdlog::spdlog
glm::glm
yaml-cpp::yaml-cpp
imguidocking::imguidocking
box2d::box2d
Vulkan::Vulkan
Jolt::Jolt
EnTT::EnTT
imguidocking::imguidocking
engine3d
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once
class CubeMesh
{
public:
CubeMesh();
void Draw();

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
#include "Core/SceneManagment/Components/GameComponent.hpp"
#include "Scenes/Assets/Components/Physics/PhysicsBody3D.hpp"

class SphereMesh : public engine3d::GameComponent
{
public:
SphereMesh(int Radius, int SectorCount, int StackCount)
void CreateSphere();

private:
engine3d::Transform m_Transform;
glm::vec3* m_TransformPosition;
};
17 changes: 17 additions & 0 deletions TestApp/Scenes/Assets/Components/Graphics/Meshes/MeshContainer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <Scenes/Assets/Components/Physics/PhysicsBody3D.hpp>
#include <Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp>
#include <Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp>

//! @brief Factory
class MeshContainer
{
public:
MeshContainer();


private:

std::vector<glm::vec3> vertices;
std::vector<glm::vec3> normals;
std::vector<glm::vec2> texCoords;
};
22 changes: 22 additions & 0 deletions TestApp/Scenes/Assets/Components/Graphics/SpriteRender3D.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#include <Core/SceneManagment/Components/GameComponent.hpp>
#include <Scenes/Assets/Components/Physics/PhysicsBody3D.hpp>
#include <Scenes/Assets/Components/Graphics/Meshes/MeshContainer.hpp>

class SpriteRender3D : public engine3d::GameComponent
{
public:
SpriteRender3D(MeshContainer* meshBody);
void OnIntegrate();
void Update();
void LateUpdate();
void PhysicsUpdate();
std::vector<glm::vec3> vertices;
std::vector<glm::vec3> normals;
std::vector<glm::vec2> texCoords;

private:
MeshContainer m_MeshContainer;
engine3d::Transform m_Transform;
glm::vec3* m_TransformPosition;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp>
#include <Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/CubeMesh.hpp>
#include <vulkan/vulkan_core.h>

void CubeMesh::Draw()
{
Ref<vk::VulkanModel> CreateCubeMesh(glm::vec3 offset){
std::vector<vk::VulkanModel::Vertex> vertices{
// left face (white)
{{-.5f, -.5f, -.5f}, {.9f, .9f, .9f}},
{{-.5f, .5f, .5f}, {.9f, .9f, .9f}},
{{-.5f, -.5f, .5f}, {.9f, .9f, .9f}},
{{-.5f, -.5f, -.5f}, {.9f, .9f, .9f}},
{{-.5f, .5f, -.5f}, {.9f, .9f, .9f}},
{{-.5f, .5f, .5f}, {.9f, .9f, .9f}},

// right face (yellow)
{{.5f, -.5f, -.5f}, {.8f, .8f, .1f}},
{{.5f, .5f, .5f}, {.8f, .8f, .1f}},
{{.5f, -.5f, .5f}, {.8f, .8f, .1f}},
{{.5f, -.5f, -.5f}, {.8f, .8f, .1f}},
{{.5f, .5f, -.5f}, {.8f, .8f, .1f}},
{{.5f, .5f, .5f}, {.8f, .8f, .1f}},

// top face (orange, remember y axis points down)
{{-.5f, -.5f, -.5f}, {.9f, .6f, .1f}},
{{.5f, -.5f, .5f}, {.9f, .6f, .1f}},
{{-.5f, -.5f, .5f}, {.9f, .6f, .1f}},
{{-.5f, -.5f, -.5f}, {.9f, .6f, .1f}},
{{.5f, -.5f, -.5f}, {.9f, .6f, .1f}},
{{.5f, -.5f, .5f}, {.9f, .6f, .1f}},

// bottom face (red)
{{-.5f, .5f, -.5f}, {.8f, .1f, .1f}},
{{.5f, .5f, .5f}, {.8f, .1f, .1f}},
{{-.5f, .5f, .5f}, {.8f, .1f, .1f}},
{{-.5f, .5f, -.5f}, {.8f, .1f, .1f}},
{{.5f, .5f, -.5f}, {.8f, .1f, .1f}},
{{.5f, .5f, .5f}, {.8f, .1f, .1f}},

// nose face (blue)
{{-.5f, -.5f, 0.5f}, {.1f, .1f, .8f}},
{{.5f, .5f, 0.5f}, {.1f, .1f, .8f}},
{{-.5f, .5f, 0.5f}, {.1f, .1f, .8f}},
{{-.5f, -.5f, 0.5f}, {.1f, .1f, .8f}},
{{.5f, -.5f, 0.5f}, {.1f, .1f, .8f}},
{{.5f, .5f, 0.5f}, {.1f, .1f, .8f}},

// tail face (green)
{{-.5f, -.5f, -0.5f}, {.1f, .8f, .1f}},
{{.5f, .5f, -0.5f}, {.1f, .8f, .1f}},
{{-.5f, .5f, -0.5f}, {.1f, .8f, .1f}},
{{-.5f, -.5f, -0.5f}, {.1f, .8f, .1f}},
{{.5f, -.5f, -0.5f}, {.1f, .8f, .1f}},
{{.5f, .5f, -0.5f}, {.1f, .8f, .1f}},
};

for (auto& v : vertices) {
v.Position += offset;
}
return CreateRef<vk::VulkanModel>(vertices, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// #include "Core/EngineLogger.hpp"
// #include <TestApp/SceneTest/Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp>
// #include <numbers>
#include <Scenes/Assets/Components/Graphics/Meshes/ChildrenMeshes/SphereMesh.hpp>
using namespace engine3d;

void SphereMesh::CreateSphere(){
m_Transform = m_GameObjectRef->SceneGetComponent<Transform>();
m_TransformPosition = &m_Transform.m_Position;
}
Loading