| 103 | }; |
| 104 | |
| 105 | static void PrintInfo(const tinyobj::attrib_t& attrib, |
| 106 | const std::vector<tinyobj::shape_t>& shapes, |
| 107 | const std::vector<tinyobj::material_t>& materials) { |
| 108 | std::cout << "# of vertices : " << (attrib.vertices.size() / 3) << std::endl; |
| 109 | std::cout << "# of normals : " << (attrib.normals.size() / 3) << std::endl; |
| 110 | std::cout << "# of texcoords : " << (attrib.texcoords.size() / 2) |
| 111 | << std::endl; |
| 112 | |
| 113 | std::cout << "# of shapes : " << shapes.size() << std::endl; |
| 114 | std::cout << "# of materials : " << materials.size() << std::endl; |
| 115 | |
| 116 | for (size_t v = 0; v < attrib.vertices.size() / 3; v++) { |
| 117 | printf(" v[%ld] = (%f, %f, %f)\n", static_cast<long>(v), |
| 118 | static_cast<const double>(attrib.vertices[3 * v + 0]), |
| 119 | static_cast<const double>(attrib.vertices[3 * v + 1]), |
| 120 | static_cast<const double>(attrib.vertices[3 * v + 2])); |
| 121 | } |
| 122 | |
| 123 | for (size_t v = 0; v < attrib.normals.size() / 3; v++) { |
| 124 | printf(" n[%ld] = (%f, %f, %f)\n", static_cast<long>(v), |
| 125 | static_cast<const double>(attrib.normals[3 * v + 0]), |
| 126 | static_cast<const double>(attrib.normals[3 * v + 1]), |
| 127 | static_cast<const double>(attrib.normals[3 * v + 2])); |
| 128 | } |
| 129 | |
| 130 | for (size_t v = 0; v < attrib.texcoords.size() / 2; v++) { |
| 131 | printf(" uv[%ld] = (%f, %f)\n", static_cast<long>(v), |
| 132 | static_cast<const double>(attrib.texcoords[2 * v + 0]), |
| 133 | static_cast<const double>(attrib.texcoords[2 * v + 1])); |
| 134 | } |
| 135 | |
| 136 | // For each shape |
| 137 | for (size_t i = 0; i < shapes.size(); i++) { |
| 138 | printf("shape[%ld].name = %s\n", static_cast<long>(i), |
| 139 | shapes[i].name.c_str()); |
| 140 | printf("Size of shape[%ld].mesh.indices: %lu\n", static_cast<long>(i), |
| 141 | static_cast<unsigned long>(shapes[i].mesh.indices.size())); |
| 142 | printf("Size of shape[%ld].lines.indices: %lu\n", static_cast<long>(i), |
| 143 | static_cast<unsigned long>(shapes[i].lines.indices.size())); |
| 144 | printf("Size of shape[%ld].points.indices: %lu\n", static_cast<long>(i), |
| 145 | static_cast<unsigned long>(shapes[i].points.indices.size())); |
| 146 | |
| 147 | size_t index_offset = 0; |
| 148 | |
| 149 | assert(shapes[i].mesh.num_face_vertices.size() == |
| 150 | shapes[i].mesh.material_ids.size()); |
| 151 | |
| 152 | assert(shapes[i].mesh.num_face_vertices.size() == |
| 153 | shapes[i].mesh.smoothing_group_ids.size()); |
| 154 | |
| 155 | printf("shape[%ld].num_faces: %lu\n", static_cast<long>(i), |
| 156 | static_cast<unsigned long>(shapes[i].mesh.num_face_vertices.size())); |
| 157 | |
| 158 | // For each face |
| 159 | for (size_t f = 0; f < shapes[i].mesh.num_face_vertices.size(); f++) { |
| 160 | size_t fnum = shapes[i].mesh.num_face_vertices[f]; |
| 161 | |
| 162 | printf(" face[%ld].fnum = %ld\n", static_cast<long>(f), |