@@ -8,19 +8,6 @@ namespace py = pybind11;
88
99using namespace tinyobj ;
1010
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-
2411// Simple wrapper for LoadMtl.
2512// TODO(syoyo): Make it more pythonic.
2613void load_mtl (std::map<std::string, int > *material_map,
@@ -36,14 +23,28 @@ PYBIND11_MODULE(tinyobjloader, tobj_module)
3623
3724 // register struct
3825 // 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" )
4041 .def (py::init<>());
41- py::class_<shape_t >(tobj_module, " Shape" )
42+
43+ py::class_<material_t >(tobj_module, " material_t" )
4244 .def (py::init<>());
43- py::class_<material_t >(tobj_module, " Material" )
45+
46+ py::class_<ObjLoaderConfig>(tobj_module, " ObjLoaderConfig" )
4447 .def (py::init<>());
4548
46- tobj_module.def (" load_obj" , &load_obj, " Load wavefront .obj file." );
47- tobj_module.def (" load_mtl" , &load_mtl, " Load wavefront material file." );
4849}
4950
0 commit comments