Skip to content
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 ICE/Assets/src/AssetBank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "AssetBank.h"

#include <ICEException.h>
#include <OBJLoader.h>
#include <MeshLoader.h>

#include "MaterialLoader.h"
#include "MeshLoader.h"
Expand Down
23 changes: 20 additions & 3 deletions ICE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ set(ICE_LIBS assets core graphics graphics_api io math platform scene storage sy
add_library(${PROJECT_NAME} INTERFACE)

if(APPLE)
target_link_libraries(${PROJECT_NAME} INTERFACE glfw ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${IOKIT_LIBRARY} ${ICE_LIBS})
target_link_libraries(${PROJECT_NAME}
INTERFACE
glfw
${COCOA_LIBRARY}
${OPENGL_LIBRARY}
${IOKIT_LIBRARY}
${ICE_LIBS}
)
elseif(WIN32)
target_link_libraries(${PROJECT_NAME} INTERFACE glfw ${ICE_LIBS})
target_link_libraries(${PROJECT_NAME}
INTERFACE
glfw
${ICE_LIBS}
)
else()
find_package(GTK REQUIRED)
include_directories(${GTK3_INCLUDE_DIRS})
Expand All @@ -34,5 +45,11 @@ else()
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})

target_link_libraries(${PROJECT_NAME} INTERFACE glfw ${GTK3_LIBRARIES} ${OPENGL_LIBRARIES} stdc++fs)
target_link_libraries(${PROJECT_NAME}
INTERFACE
glfw
${GTK3_LIBRARIES}
${OPENGL_LIBRARIES}
stdc++fs
)
endif()
1 change: 0 additions & 1 deletion ICE/Core/src/ICEEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <ForwardRenderer.h>
#include <GLFW/glfw3.h>
#include <Logger.h>
#include <OBJLoader.h>
#include <PerspectiveCamera.h>
#include <TransformComponent.h>

Expand Down
1 change: 1 addition & 0 deletions ICE/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ target_link_libraries(${PROJECT_NAME}
scene
assets
graphics_api
assimp
)

target_include_directories(${PROJECT_NAME} PUBLIC
Expand Down
34 changes: 32 additions & 2 deletions ICE/IO/src/MeshLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,42 @@

#include "MeshLoader.h"

#include <OBJLoader.h>
#include <BufferUtils.h>
#include <assimp/postprocess.h>
#include <assimp/scene.h>

#include <assimp/Importer.hpp>
#include <cassert>

namespace ICE {
std::shared_ptr<Mesh> MeshLoader::load(const std::vector<std::filesystem::path> &file) {
auto mesh = OBJLoader::loadFromOBJ(file[0].string());
Assimp::Importer importer;

const aiScene *scene = importer.ReadFile(
file[0].string(), aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);

auto vertices = std::vector<Eigen::Vector3f>();
auto normals = std::vector<Eigen::Vector3f>();
auto uvs = std::vector<Eigen::Vector2f>();
auto indices = std::vector<Eigen::Vector3i>();
// Loop over faces(polygon)
auto mesh0 = scene->mMeshes[0];
for (int i = 0; i < mesh0->mNumVertices; i++) {
auto v = mesh0->mVertices[i];
auto n = mesh0->mNormals[i];
auto uv = mesh0->mTextureCoords[0][i];
vertices.emplace_back(v.x, v.y, v.z);
normals.emplace_back(n.x, n.y, n.z);
uvs.emplace_back(uv.x, uv.y);
}
for (int i = 0; i < mesh0->mNumFaces; i++) {
auto f = mesh0->mFaces[i];
assert(f.mNumIndices == 3);
indices.emplace_back(f.mIndices[0], f.mIndices[1], f.mIndices[2]);
}

auto mesh = std::make_shared<Mesh>(vertices, normals, uvs, indices);

mesh->setSources(file);

auto vertexArray = graphics_factory->createVertexArray();
Expand Down
17 changes: 16 additions & 1 deletion ICE/IO/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.19)
project(materials-tests)
project(io-tests)

message(STATUS "Building ${PROJECT_NAME} suite")
include(CTest)
Expand All @@ -18,4 +18,19 @@ target_link_libraries(MaterialsTestSuite
gtest_main
io)

add_executable(MeshLoaderTestSuite
MeshLoaderTest.cpp
)

add_test(NAME MeshLoaderTestSuite
COMMAND MeshLoaderTestSuite
WORKING_DIRECTORY $<TARGET_FILE_DIR:MeshLoaderTestSuite>)

target_link_libraries(MeshLoaderTestSuite
PRIVATE
gtest_main
io)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/cube.obj DESTINATION ${CMAKE_CURRENT_BINARY_DIR})


13 changes: 13 additions & 0 deletions ICE/IO/test/MeshLoaderTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <gtest/gtest.h>

#include "MeshLoader.h"
#include <NoneGraphicsFactory.h>

using namespace ICE;

TEST(MeshLoaderTest, LoadFromObj) {
auto gr_f = std::make_shared<NoneGraphicsFactory>();
auto mesh = MeshLoader(gr_f).load({"cube.obj"});
EXPECT_EQ(mesh->getVertices().size(), 24);
EXPECT_EQ(mesh->getIndices().size(), 12);
}
44 changes: 44 additions & 0 deletions ICE/IO/test/cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
o Cube
v 0.500097 0.500097 -0.500097
v 0.500097 -0.500097 -0.500097
v 0.500097 0.500097 0.500097
v 0.500097 -0.500097 0.500097
v -0.500097 0.500097 -0.500097
v -0.500097 -0.500097 -0.500097
v -0.500097 0.500097 0.500097
v -0.500097 -0.500097 0.500097
vt 0.875000 0.500000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
s off
f 5/1/1 3/2/1 1/3/1
f 3/2/2 8/4/2 4/5/2
f 7/6/3 6/7/3 8/8/3
f 2/9/4 8/10/4 6/11/4
f 1/3/5 4/5/5 2/9/5
f 5/12/6 2/9/6 6/7/6
f 5/1/1 7/13/1 3/2/1
f 3/2/2 7/14/2 8/4/2
f 7/6/3 5/12/3 6/7/3
f 2/9/4 4/5/4 8/10/4
f 1/3/5 3/2/5 4/5/5
f 5/12/6 1/3/6 2/9/6
4 changes: 1 addition & 3 deletions ICE/Util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ target_sources(${PROJECT_NAME} PRIVATE
src/BufferUtils.cpp
src/ICEException.cpp
src/Logger.cpp
src/OBJLoader.cpp
src/WindowFactory.cpp
src/GLFWWindow.cpp
)
src/GLFWWindow.cpp)

target_link_libraries(${PROJECT_NAME}
PUBLIC
Expand Down
19 changes: 0 additions & 19 deletions ICE/Util/include/OBJLoader.h

This file was deleted.

110 changes: 0 additions & 110 deletions ICE/Util/src/OBJLoader.cpp

This file was deleted.

26 changes: 26 additions & 0 deletions ICEBERG/Components/UniformInputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,32 @@ class UniformInputs {
ImGui::PopID();
}

void render(Eigen::Vector2f &v) {
ImGui::PushID(m_label.c_str());
ImGui::PushItemWidth(60);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f);

ImGui::BeginGroup();
renderLabel("X", 0x990000FF);
if (ImGui::InputFloat("##X", &v.x())) {
m_callback(v);
}
ImGui::EndGroup();
ImGui::SameLine();

ImGui::BeginGroup();
renderLabel("Y", 0x9900FF00);
if (ImGui::InputFloat("##Y", &v.y())) {
m_callback(v);
}
ImGui::EndGroup();
ImGui::SameLine();

ImGui::PopStyleVar();
ImGui::PopItemWidth();
ImGui::PopID();
}

void renderLabel(const char *text, uint32_t backgroundColor) {
auto dl = ImGui::GetWindowDrawList();
ImVec2 rectSize = ImGui::CalcTextSize(text);
Expand Down
10 changes: 10 additions & 0 deletions cmake/fetch_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ FetchContent_MakeAvailable(googletest)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

message(STATUS "Fetching GLFW")
include(FetchContent)
FetchContent_Declare(
GLFW
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG master
)
FetchContent_MakeAvailable(GLFW)

message(STATUS "Fetching Assimp")
include(FetchContent)
FetchContent_Declare(
Assimp
GIT_REPOSITORY https://github.com/assimp/assimp.git
GIT_TAG master
)
FetchContent_MakeAvailable(Assimp)
Loading