diff --git a/src/camera.cpp b/src/camera.cpp index 6ee76b7..5400a5c 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -63,19 +63,19 @@ namespace simpleengine { } if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS) { - rotation.z += camera_speed; + rotation.z += camera_speed * .3; } if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS) { - rotation.z -= camera_speed; + rotation.z -= camera_speed * .3; } if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS) { - rotation.y -= camera_speed; + rotation.y -= camera_speed * .3; } if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS) { - rotation.y += camera_speed; + rotation.y += camera_speed * .3; } // Limit the pitch of the camera. diff --git a/src/gfx/model.cpp b/src/gfx/model.cpp index 44ccea2..98d8f7a 100644 --- a/src/gfx/model.cpp +++ b/src/gfx/model.cpp @@ -73,8 +73,10 @@ namespace simpleengine::gfx { simpleengine::Vectorf position(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z); vertex.position = position; - glm::vec3 normal(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z); - vertex.normal = normal; + if (mesh->HasNormals()) { + glm::vec3 normal(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z); + vertex.normal = normal; + } if (mesh->mTextureCoords[0]) { glm::vec2 tex_coord(mesh->mTextureCoords[0][i].x, mesh->mTextureCoords[0][i].y); @@ -142,7 +144,13 @@ namespace simpleengine::gfx { } } - return Mesh(vertices, indices, mat); + Mesh se_mesh(vertices, indices, mat); + + if (!mesh->HasNormals()) { + se_mesh.calculate_normals(); + } + + return se_mesh; } std::unordered_map> load_all_textures(aiMaterial* material) { diff --git a/src/gfx/texture.cpp b/src/gfx/texture.cpp index 72923b5..ad0bede 100644 --- a/src/gfx/texture.cpp +++ b/src/gfx/texture.cpp @@ -4,7 +4,7 @@ #include namespace simpleengine::gfx { - Texture::Texture(const char* path, aiTextureType type, int flags): type(type) { + Texture::Texture(const char* path, aiTextureType type, int flags): type(type), path(path) { bool img_2d = flags & TextureFlags::TexFlags_IMG_2D; bool flip_vertically = flags & TextureFlags::TexFlags_FLIP_VERTICALLY; bool mipmap = flags & TextureFlags::TexFlags_MIPMAP; @@ -23,7 +23,7 @@ namespace simpleengine::gfx { stbi_set_flip_vertically_on_load(flip_vertically); - // Read 4 channels (RGBA) + // Read 4 channels (RGBA) img_data = stbi_load(path, &width, &height, &channels, 4); if(!img_data) { const char* failure = stbi_failure_reason();