Entrega final para teoría, este incluye mejoras y añadidos como:
- Animación por funciones
- Avatar con bone-rigging
- Audio
What's Changed
- Bone Rigging animation by @Azrielx86 in #12
- 3rd person camera added by @Azrielx86 in #14
- animación 90% by @EnriqueAranda in #13
- animción canicas 100% acabadas by @EnriqueAranda in #15
- Terminado primitiva por codigo by @EnriqueAranda in #16
New Contributors
- @EnriqueAranda made their first contribution in #13
Full Changelog: 1.0...2.0
Notas 2025
Warning
Esta versión se compiló con glm-1.0.1
y assimp-5.2.5-r1
, al intentar usar versiones más actuales el modelo que utiliza bone rigging se carga incorrectamente. Igualmente, para compilarlo en Linux sin vcpkg, es necesario agregar algunas líneas en el CMakeLists.txt
El siguiente diff permite la compilación en Linux, así como también corrige los errores del modelo con bone rigging, utilizando la versión necesaria de assimp, así como también se corrige el error de las texturas siendo incorrectamente cargadas en Linux (Ya que el modelo se exportó en Windows, utilizando regex se recupera únicamente el nombre de la textura).
Se puede aplicar fácilmente guardando el contenido en un archivo patch.diff
y ejecutando git apply patch.diff
.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea695c9..08e0996 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,17 +1,30 @@
cmake_minimum_required(VERSION 3.26)
project(ProyectoFinal_CGeIHC)
+
+include(FetchContent)
+
set(CMAKE_CXX_STANDARD 17)
+FetchContent_Declare(assimp
+ GIT_REPOSITORY https://github.com/assimp/assimp.git
+ GIT_TAG v5.2.5)
+set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
+set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
+set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "" FORCE)
+set(ASSIMP_INSTALL OFF CACHE BOOL "" FORCE)
+FetchContent_MakeAvailable(assimp)
+
if (MSVC)
message(STATUS "Usando MSVC en Visual Studio")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(STATUS "Usando Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(WARNING "Compilando la versión debug.")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -DDEBUG")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gfull -O0 -DDEBUG")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DRELEASE")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -Wdouble-promotion -Wno-sign-conversion -Wno-unknown-pragmas -fsanitize=address -fsanitize-trap")
+ add_link_options(-Wall -Wextra -Wconversion -Wdouble-promotion -Wno-sign-conversion -Wno-unknown-pragmas -fsanitize=address -fsanitize-trap)
endif ()
endif ()
@@ -36,22 +49,24 @@ if (glm_FOUND)
message(STATUS "glm Found")
endif ()
-find_package(assimp CONFIG REQUIRED)
-if (assimp_FOUND)
- message(STATUS "Assimp Found")
-endif ()
-
find_package(OpenAL CONFIG REQUIRED)
-find_package(FreeALUT CONFIG REQUIRED)
if (OpenAL_FOUND)
message(STATUS "OpenAL Found")
endif ()
-find_package(Stb REQUIRED)
-if (Stb_FOUND)
- message(STATUS "STB Found")
+if (vcpkg)
+ find_package(FreeALUT CONFIG REQUIRED)
+ find_package(Stb REQUIRED)
+ if (Stb_FOUND)
+ message(STATUS "STB Found")
+ endif ()
+else ()
+ include_directories("/usr/include/stb")
+ include_directories("/usr/include/AL")
+ add_link_options(-lalut -lopenal)
endif ()
+
find_package(Boost REQUIRED)
if (Boost_FOUND)
message(STATUS "Boost found")
@@ -166,9 +181,13 @@ file(COPY assets/Audios DESTINATION ${CMAKE_BINARY_DIR}/assets)
target_include_directories(ProyectoFinal_CGeIHC PRIVATE ${Stb_INCLUDE_DIR})
target_link_libraries(ProyectoFinal_CGeIHC PRIVATE GLEW::GLEW)
target_link_libraries(ProyectoFinal_CGeIHC PRIVATE glfw)
+target_link_libraries(ProyectoFinal_CGeIHC PRIVATE OpenGL)
target_link_libraries(ProyectoFinal_CGeIHC PRIVATE assimp::assimp)
target_link_libraries(ProyectoFinal_CGeIHC PRIVATE OpenAL::OpenAL)
target_link_libraries(ProyectoFinal_CGeIHC PRIVATE glm::glm)
target_link_libraries(ProyectoFinal_CGeIHC PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(ProyectoFinal_CGeIHC PRIVATE Boost::boost)
-target_link_libraries(ProyectoFinal_CGeIHC PRIVATE FreeALUT::alut)
\ No newline at end of file
+
+if (vcpkg)
+ target_link_libraries(ProyectoFinal_CGeIHC PRIVATE FreeALUT::alut)
+endif ()
diff --git a/src/model/BoneModel.cpp b/src/model/BoneModel.cpp
index b45b135..b2002e3 100644
--- a/src/model/BoneModel.cpp
+++ b/src/model/BoneModel.cpp
@@ -4,6 +4,8 @@
#include "BoneModel.h"
+#include <regex>
+
namespace Model
{
void BoneModel::render()
@@ -92,7 +94,18 @@ void BoneModel::loadMaterials(const aiScene *scene)
aiString path;
if (material->GetTexture(aiTextureType_DIFFUSE, 0, &path) == AI_SUCCESS)
{
- auto file = std::filesystem::path(path.data).filename().string();
+ std::cmatch results;
+ std::regex_search(path.C_Str(), results, std::regex(R"([^\/|\\]+\.\w+$)"));
+
+ if (results.empty())
+ {
+ std::cerr << boost::format("No texture for: %s\n") % path.C_Str();
+ continue;
+ }
+
+ auto texName = results[0].str();
+
+ auto file = std::filesystem::path(texName).filename().string();
auto searchPath = Utils::PathUtils::getTexturesPath() + "/" + file;
textureList[i] = new Texture(searchPath.c_str());
if (std::filesystem::exists(searchPath))
Note
Como este es un proyecto de un semestre anterior, no se corregirán los errores encontrados tiempo después en algún commit, pero se deja como documentación aquí por si a alguien le sirve :P