Imported tool for loading models

This commit is contained in:
Warwick 2022-04-29 12:09:25 +01:00
parent 5c96f8b90d
commit 644ac26403
5 changed files with 16 additions and 9 deletions

View file

@ -23,15 +23,15 @@ find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED) find_package(SDL2_image REQUIRED)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED) find_package(GLEW REQUIRED)
find_package(GLM REQUIRED) find_package(GLM REQUIRED)
message(STATUS "GLM included: ${GLM_INCLUDE_DIR}") find_package(assimp REQUIRED)
include_directories( include_directories(
${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}
${SDL2_IMAGE_DIRS} ${SDL2_IMAGE_DIRS}
${OPENGL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}) ${GLEW_INCLUDE_DIRS}
${ASSIMP_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES}) add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
@ -39,4 +39,5 @@ target_link_libraries(${PROJECT_NAME}
${SDL2_LIBRARIES} ${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES} ${SDL2_IMAGE_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}) ${GLEW_LIBRARIES}
${ASSIMP_LIBRARIES})

View file

@ -59,5 +59,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG
IF(GLM_FOUND) IF(GLM_FOUND)
SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") #MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}")
ENDIF(GLM_FOUND) ENDIF(GLM_FOUND)

View file

@ -1,5 +1,6 @@
#include "Model.h" #include "Model.h"
Model::Model(char *path) {}
Model::Model(Mesh mesh) { this->meshes.push_back(mesh); } Model::Model(Mesh mesh) { this->meshes.push_back(mesh); }
Model::Model(std::vector<Mesh> meshes) { this->meshes = meshes; } Model::Model(std::vector<Mesh> meshes) { this->meshes = meshes; }
@ -19,3 +20,5 @@ void Model::translate(glm::vec3 translation) {
// set model transform // set model transform
this->model = glm::translate(glm::mat4(1.0f), glm::vec3(this->position)); this->model = glm::translate(glm::mat4(1.0f), glm::vec3(this->position));
} }
void Model::loadModel(char *path) {}

View file

@ -2,6 +2,9 @@
#include "Error.h" #include "Error.h"
#include "Mesh.h" #include "Mesh.h"
#include "ShaderLoader.h" #include "ShaderLoader.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <vector> #include <vector>
@ -19,7 +22,11 @@ private:
// Position // Position
glm::vec4 position = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f); glm::vec4 position = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
void loadModel(char *path);
public: public:
// Create a model from file
Model(char *path);
// Used to create a mesh out of a single mesh. // Used to create a mesh out of a single mesh.
Model(Mesh mesh); Model(Mesh mesh);
// Used to create a mesh out of multiple meshes. // Used to create a mesh out of multiple meshes.

View file

@ -236,10 +236,6 @@ int main(int argc, char **argv) {
// glBindVertexArray(VAO); // glBindVertexArray(VAO);
// TODO: Run game here lol // TODO: Run game here lol
// Draw triangle
// glDrawArrays(GL_TRIANGLES, 0, 3);
// glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
// glBindVertexArray(0);
SDL_GL_SwapWindow(window); SDL_GL_SwapWindow(window);
}; };