Update code and models

This commit is contained in:
2020-04-02 00:55:18 +02:00
parent b9a007dd51
commit d85c6073ec
10 changed files with 51 additions and 7 deletions

View File

@@ -1,6 +1,18 @@
#include <opengl-playground/material.hpp>
std::ostream &operator<<(std::ostream &os, glm::vec3 const &vec3)
{
return os << "(" << vec3.r << "|" << vec3.g << "|" << vec3.b << ")";
}
std::ostream &operator<<(std::ostream &os, Material const &material)
{
return os << "Diffuse Color: " << material.diff_color << ", "
<< "Ambient Color: " << material.ambient_color << ", "
<< "Specular Color: " << material.specular_color << ", "
<< "Texture counts (diff, amb, spec): " << material.diffuse_textures.size()
<< ", " << material.ambient_textures.size() << ", " << material.specular_textures.size();
}
Material::Material()
{

View File

@@ -135,6 +135,7 @@ Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene)
material->Get(AI_MATKEY_SHININESS, mesh_material.shininess);
material->Get(AI_MATKEY_SHININESS_STRENGTH, mesh_material.shininess_strength);
std::cout << "Material: " << mesh_material << std::endl;
}

View File

@@ -3,6 +3,7 @@
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h>
#include <iostream>
#include <filesystem>
OpenGlTexture::OpenGlTexture(const std::string &texture_path)
{
@@ -36,8 +37,14 @@ void OpenGlTexture::setRGBDataFromBytes(unsigned int width, unsigned int height,
void OpenGlTexture::loadFromImagePath(const std::string &base_directory)
{
int width, height, nrChannels;
std::string filename = this->texture_path;
filename = base_directory + '/' + filename;
std::filesystem::path base_path(base_directory);
std::filesystem::path tex_path(this->texture_path);
std::string filename;
if (tex_path.is_relative())
filename = base_path / tex_path;
else
filename = tex_path;
unsigned char *data = stbi_load(filename.c_str(), &width, &height, &nrChannels, 0);
if (data) {

View File

@@ -1 +1,10 @@
#include <opengl-playground/vertex.hpp>
Vertex operator+(Vertex const &a, Vertex const &b)
{
Vertex out = a;
out.Position + b.Position;
return out;
}