forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_obj.h
41 lines (37 loc) · 1.29 KB
/
read_obj.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include <Eigen/Core>
namespace drake {
namespace geometry {
namespace internal {
/** Reads the OBJ file with the given `filename` into a collection of data. It
* includes the vertex positions, face encodings (see TinyObjToFclFaces), and
* number of faces.
* @param filename The name of the obj file.
* @param scale Scale to coordinates.
* @param triangulate Whether triangulate polygon face in .obj or not. Refer to
* LoadObj function in
* https://github.com/tinyobjloader/tinyobjloader/blob/master/tiny_obj_loader.h
* for more details.
* @return (vertices, faces, num_faces) vertices[i] is the i'th vertex in the
* mesh. faces is interpreted as
*
* faces = { n0, v0_0,v0_1,...,v0_n0-1,
* n1, v1_0,v1_1,...,v1_n1-1,
* n2, v2_0,v2_1,...,v2_n2-1,
* ...}
*
* where n_i is the number of vertices of face_i, vi_j is the index in
* `vertices` for a vertex on face i. Note that the size of faces is larger than
* num_faces.
*
*/
std::tuple<std::shared_ptr<std::vector<Eigen::Vector3d>>,
std::shared_ptr<std::vector<int>>, int>
ReadObjFile(const std::string& filename, double scale, bool triangulate);
} // namespace internal
} // namespace geometry
} // namespace drake