Skip to content

Commit

Permalink
Josh update branch (#58)
Browse files Browse the repository at this point in the history
* build: successful editor build

* Pushing MeshChanges
  • Loading branch information
JoshuaM928 authored Nov 22, 2024
1 parent 3adf7fe commit 02bbc49
Show file tree
Hide file tree
Showing 74 changed files with 357 additions and 151 deletions.
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

0 comments on commit 02bbc49

Please sign in to comment.