Skip to content

Commit ba70318

Browse files
committed
Refactor v2 API.
Add API to parse .obj and .mtl from a string.
1 parent f750f74 commit ba70318

File tree

2 files changed

+98
-99
lines changed

2 files changed

+98
-99
lines changed

python/bindings.cc

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,22 @@ namespace py = pybind11;
88

99
using namespace tinyobj;
1010

11-
// Simple wrapper for LoadMtl.
12-
// TODO(syoyo): Make it more pythonic.
13-
void load_mtl(std::map<std::string, int> *material_map,
14-
std::vector<material_t> *materials, std::istream *inStream,
15-
std::string *warning, std::string *err) {
16-
LoadMtl(material_map, materials, inStream, warning, err);
17-
}
18-
19-
2011
PYBIND11_MODULE(tinyobjloader, tobj_module)
2112
{
2213
tobj_module.doc() = "Python bindings for TinyObjLoader.";
2314

2415
// register struct
2516
// py::init<>() for default constructor
26-
py::class_<ObjLoader>(tobj_module, "ObjLoader")
17+
py::class_<ObjReader>(tobj_module, "ObjReader")
2718
.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);
19+
.def("ParseFromFile", &ObjReader::ParseFromFile)
20+
.def("ParseFromString", &ObjReader::ParseFromString)
21+
.def("Valid", &ObjReader::Valid)
22+
.def("GetAttrib", &ObjReader::GetAttrib)
23+
.def("GetShapes", &ObjReader::GetShapes)
24+
.def("GetMaterials", &ObjReader::GetMaterials)
25+
.def("Warning", &ObjReader::Warning)
26+
.def("Error", &ObjReader::Error);
3527

3628
py::class_<attrib_t>(tobj_module, "attrib_t")
3729
.def(py::init<>())
@@ -43,7 +35,7 @@ PYBIND11_MODULE(tinyobjloader, tobj_module)
4335
py::class_<material_t>(tobj_module, "material_t")
4436
.def(py::init<>());
4537

46-
py::class_<ObjLoaderConfig>(tobj_module, "ObjLoaderConfig")
38+
py::class_<ObjReaderConfig>(tobj_module, "ObjReaderConfig")
4739
.def(py::init<>());
4840

4941
}

0 commit comments

Comments
 (0)