@@ -38,6 +38,12 @@ PYBIND11_MODULE(tinyobjloader, tobj_module)
3838 py::class_<attrib_t >(tobj_module, " attrib_t" )
3939 .def (py::init<>())
4040 .def_readonly (" vertices" , &attrib_t ::vertices)
41+ .def (" numpy_vertices" , [] (attrib_t &instance) {
42+ auto ret = py::array_t <real_t >(instance.vertices .size ());
43+ py::buffer_info buf = ret.request ();
44+ memcpy (buf.ptr , instance.vertices .data (), instance.vertices .size () * sizeof (real_t ));
45+ return ret;
46+ })
4147 .def_readonly (" normals" , &attrib_t ::normals)
4248 .def_readonly (" texcoords" , &attrib_t ::texcoords)
4349 .def_readonly (" colors" , &attrib_t ::colors)
@@ -115,6 +121,13 @@ PYBIND11_MODULE(tinyobjloader, tobj_module)
115121
116122 py::class_<mesh_t >(tobj_module, " mesh_t" )
117123 .def (py::init<>())
124+ .def_readonly (" num_face_vertices" , &mesh_t ::num_face_vertices)
125+ .def (" numpy_num_face_vertices" , [] (mesh_t &instance) {
126+ auto ret = py::array_t <unsigned char >(instance.num_face_vertices .size ());
127+ py::buffer_info buf = ret.request ();
128+ memcpy (buf.ptr , instance.num_face_vertices .data (), instance.num_face_vertices .size () * sizeof (unsigned char ));
129+ return ret;
130+ })
118131 .def_readonly (" indices" , &mesh_t ::indices)
119132 .def (" numpy_indices" , [] (mesh_t &instance) {
120133 auto ret = py::array_t <int >(instance.indices .size () * 3 );
0 commit comments