12#include "Space/Shape/Point.hpp"
14#ifdef HAVE_TINYOBJLOADER
15#include "tiny_obj_loader.h"
29 tinyobj::attrib_t attrib;
30 std::vector<tinyobj::shape_t> shapes;
31 std::vector<tinyobj::material_t> materials;
50 bool read(std::string file)
60 bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, file.c_str());
63 {std::cerr << err << std::endl;}
68 end_shape = shapes.size();
79 ObjReader & operator++()
81 index_offset += getFaceNVertex();
84 if (face_counter >= shapes[shape_counter].mesh.num_face_vertices.size())
100 return shape_counter < end_shape;
109 inline void setObject(
int i)
111 if (i >= shapes.size())
113 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" you selected object " << i <<
" but the file contain " << shapes.size() <<
" objects" << std::endl;
125 unsigned int getFaceNVertex()
127 return shapes[shape_counter].mesh.num_face_vertices[face_counter];
139 tinyobj::index_t idx = shapes[shape_counter].mesh.indices[index_offset + v];
141 p.
get(0) = attrib.vertices[3*idx.vertex_index+0];
142 p.
get(1) = attrib.vertices[3*idx.vertex_index+1];
143 p.
get(2) = attrib.vertices[3*idx.vertex_index+2];
157 tinyobj::index_t idx = shapes[shape_counter].mesh.indices[index_offset + v];
159 p.
get(0) = attrib.normals[3*idx.normal_index+0];
160 p.
get(1) = attrib.normals[3*idx.normal_index+1];
161 p.
get(2) = attrib.normals[3*idx.normal_index+2];
177 tinyobj::index_t idx = shapes[shape_counter].mesh.indices[index_offset + v];
179 p.
get(0) = attrib.texcoords[2*idx.texcoord_index+0];
180 p.
get(1) = attrib.texcoords[2*idx.texcoord_index+1];
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.