Commit 265e8c00 authored by Philip Trettner's avatar Philip Trettner
Browse files

added mesh loader

parent 7fb57662
#include "formats.hh"
#include <algorithm>
#include "formats/obj.hh"
#include "formats/off.hh"
#include "formats/pm.hh"
#include "formats/stl.hh"
void polymesh::load(const std::string &filename, polymesh::Mesh &m, vertex_attribute<glm::vec3> &pos)
{
if (filename.find('.') == std::string::npos)
{
std::cerr << "could not find extension of " << filename << std::endl;
return;
}
auto ext = filename.substr(filename.rfind('.') + 1);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
if (ext == "obj")
{
read_obj(filename, m, pos);
}
else if (ext == "off")
{
read_off(filename, m, pos);
}
else if (ext == "stl")
{
read_stl(filename, m, pos);
}
else
{
std::cerr << "unknown extension: " << ext << " (of " << filename << ")" << std::endl;
}
}
#pragma once
#include <glm/vec3.hpp>
#include "Mesh.hh"
namespace polymesh
{
/// loads a mesh from a file
void load(std::string const& filename, Mesh& m, vertex_attribute<glm::vec3>& pos);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment