@@ -8,19 +8,6 @@ namespace py = pybind11;
8
8
9
9
using namespace tinyobj ;
10
10
11
- // Simple wrapper for LoadObj.
12
- // TODO(syoyo): Make it more pythonic.
13
- bool load_obj (attrib_t *attrib, std::vector<shape_t > *shapes,
14
- std::vector<material_t > *materials,
15
- std::string *warn, std::string *err,
16
- const std::string &filename,
17
- const std::string &mtl_basedir = " ./" ,
18
- bool triangulate = true ,
19
- bool default_vcols_fallback = true )
20
- {
21
- return LoadObj (attrib, shapes, materials, warn, err, filename.c_str (), mtl_basedir.c_str (), triangulate, default_vcols_fallback);
22
- }
23
-
24
11
// Simple wrapper for LoadMtl.
25
12
// TODO(syoyo): Make it more pythonic.
26
13
void load_mtl (std::map<std::string, int > *material_map,
@@ -36,14 +23,28 @@ PYBIND11_MODULE(tinyobjloader, tobj_module)
36
23
37
24
// register struct
38
25
// py::init<>() for default constructor
39
- py::class_<attrib_t >(tobj_module, " Attrib" )
26
+ py::class_<ObjLoader>(tobj_module, " ObjLoader" )
27
+ .def (py::init<>())
28
+ .def (" Load" , &ObjLoader::Load)
29
+ .def (" Valid" , &ObjLoader::Valid)
30
+ .def (" GetAttrib" , &ObjLoader::GetAttrib)
31
+ .def (" GetShapes" , &ObjLoader::GetShapes)
32
+ .def (" GetMaterials" , &ObjLoader::GetMaterials)
33
+ .def (" Warning" , &ObjLoader::Warning)
34
+ .def (" Error" , &ObjLoader::Error);
35
+
36
+ py::class_<attrib_t >(tobj_module, " attrib_t" )
37
+ .def (py::init<>())
38
+ .def_property_readonly (" vertices" , &attrib_t ::GetVertices);
39
+
40
+ py::class_<shape_t >(tobj_module, " shape_t" )
40
41
.def (py::init<>());
41
- py::class_<shape_t >(tobj_module, " Shape" )
42
+
43
+ py::class_<material_t >(tobj_module, " material_t" )
42
44
.def (py::init<>());
43
- py::class_<material_t >(tobj_module, " Material" )
45
+
46
+ py::class_<ObjLoaderConfig>(tobj_module, " ObjLoaderConfig" )
44
47
.def (py::init<>());
45
48
46
- tobj_module.def (" load_obj" , &load_obj, " Load wavefront .obj file." );
47
- tobj_module.def (" load_mtl" , &load_mtl, " Load wavefront material file." );
48
49
}
49
50
0 commit comments