Skip to content

Commit d6e9bfa

Browse files
committed
Add few python binding.
1 parent c03fdac commit d6e9bfa

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

python/bindings.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ PYBIND11_MODULE(tinyobj, tobj_module)
3636
.def_readonly("lines", &shape_t::lines)
3737
.def_readonly("points", &shape_t::points);
3838

39+
py::class_<index_t>(tobj_module, "index_t")
40+
.def(py::init<>())
41+
.def_readonly("vertex_index", &index_t::vertex_index)
42+
.def_readonly("normal_index", &index_t::normal_index)
43+
.def_readonly("texcoord_index", &index_t::texcoord_index)
44+
;
45+
3946
// TODO(syoyo): write more bindings
4047
py::class_<material_t>(tobj_module, "material_t")
4148
.def(py::init<>());
4249

4350
py::class_<mesh_t>(tobj_module, "mesh_t")
44-
.def(py::init<>());
51+
.def(py::init<>())
52+
.def_readonly("indices", &mesh_t::indices);
4553

4654
py::class_<lines_t>(tobj_module, "lines_t")
4755
.def(py::init<>());

python/sample.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
# TODO(syoyo): print mesh
2222
for shape in reader.GetShapes():
2323
print(shape.name)
24-
print(len(shape.mesh.indices))
24+
for idx in shape.mesh.indices:
25+
print("v_idx ", idx.vertex_index)

0 commit comments

Comments
 (0)