Calculate normals if there aren't any, texture store file path
This commit is contained in:
parent
ab09107d23
commit
e0049c61ba
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
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<aiTextureType, std::vector<Texture>> load_all_textures(aiMaterial* material) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stb_image.h>
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue