-
-
Notifications
You must be signed in to change notification settings - Fork 624
Closed
Description
Given below minimal obj file
test.obj
v -126.4800033569 12.4945001602 -173.8119964600
v -126.6900024414 21.4505004883 -170.0980072021
v -108.1169967651 -28.3661003113 -170.7310028076
f 1 2 3
Please see below minimal code
void ReadOBJ(const std::string &obj_file,
std::vector<double> &vert_pos,
std::vector<int> &tri_ind){
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string warn;
std::string err;
tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, obj_file.c_str());
for (double vertice : attrib.vertices){
vert_pos.emplace_back(vertice);
std::cout << vertice << std::endl;
}
for (auto &shape : shapes){
for (auto &indice : shape.mesh.indices){
tri_ind.emplace_back(indice.vertex_index);
}
}
}
int main(){
std::vector<double> vert_pos;
std::vector<int> tri_ind;
ReadOBJ("test.obj", vert_pos, tri_ind);
std::cout << "total verts: " << vert_pos.size() << std::endl;
return 0;
}
If TINYOBJLOADER_USE_DOUBLE
is set to on in CMake while compiling tinyobjloader, the output is all wrong as shown below:
3.68883e+19
-3.49406
1.08357e-19
2.64045
-3.68995e+19
-3.58948
-nan
-3.49488
7.39465e-42
2.83516
-3.68897e+19
-3.58222
-3.68878e+19
-3.42233
-2.00139
-2.94322
3.68922e+19
-3.58346
total verts: 18
whereas if TINYOBJLOADER_USE_DOUBLE
is set to off in CMake while compiling tinyobjloader, the output is as expected like below:
-126.48
12.4945
-173.812
-126.69
21.4505
-170.098
-108.117
-28.3661
-170.731
total verts: 9
Metadata
Metadata
Assignees
Labels
No labels