diff --git a/docs/readwrite.rst b/docs/readwrite.rst index 75dffb7..c47743e 100644 --- a/docs/readwrite.rst +++ b/docs/readwrite.rst @@ -16,3 +16,15 @@ OpenMesh provides functions that read and write meshes from and to files: om.write_mesh(trimesh, "bunny.ply") OpenMesh currently supports five file types: .obj, .off, .ply, .stl and .om + +For writing .obj files there is also support for textures. You can pass the path of a texture image and +optionally the suffix for the material file, default is ".mat", but some programs, e.g. Blender expect ".mtl" as suffix + +.. code:: python + + om.write_mesh( + "out.obj", + trimesh, + texture_file="moon.png", + material_file_extension=".mtl" # default is ".mat", blender needs ".mtl" + ) diff --git a/src/InputOutput.cc b/src/InputOutput.cc index 0c840c0..4eca199 100644 --- a/src/InputOutput.cc +++ b/src/InputOutput.cc @@ -148,7 +148,9 @@ void def_write_mesh(py::module& m) { bool _face_normal, bool _face_color, bool _color_alpha, - bool _color_float + bool _color_float, + const std::string& _texture_file = "", + const std::string& _material_file_extension = ".mat" ) { OM::IO::Options options; @@ -168,6 +170,8 @@ void def_write_mesh(py::module& m) { if (_color_alpha) options += OM::IO::Options::ColorAlpha; if (_color_float) options += OM::IO::Options::ColorFloat; + options.texture_file = _texture_file; + options.material_file_extension = _material_file_extension; const bool ok = OM::IO::write_mesh(_mesh, _filename, options); @@ -191,7 +195,9 @@ void def_write_mesh(py::module& m) { py::arg("face_normal")=false, py::arg("face_color")=false, py::arg("color_alpha")=false, - py::arg("color_float")=false + py::arg("color_float")=false, + py::arg("texture_file")="", + py::arg("material_file_extension")=".mat" ); } diff --git a/src/Mesh.hh b/src/Mesh.hh index 7af6043..2169537 100644 --- a/src/Mesh.hh +++ b/src/Mesh.hh @@ -719,10 +719,21 @@ void expose_mesh(py::module& m, const char *_name) { _self.status(_h).set_deleted(_val); }) - .def("is_deleted", [](Mesh& _self, OM::HalfedgeHandle _h) { - if (!_self.has_halfedge_status()) return false; - return _self.status(_h).deleted(); - }) + .def("is_locked", [](Mesh& _self, OM::VertexHandle _h) { + if (!_self.has_vertex_status()) return false; + return _self.status(_h).locked(); + }) + + .def("set_locked", [](Mesh& _self, OM::VertexHandle _h, bool _val) { + if (!_self.has_vertex_status()) _self.request_vertex_status(); + _self.status(_h).set_locked(_val); + + }) + + .def("is_deleted", [](Mesh& _self, OM::HalfedgeHandle _h) { + if (!_self.has_halfedge_status()) return false; + return _self.status(_h).deleted(); + }) .def("set_deleted", [](Mesh& _self, OM::HalfedgeHandle _h, bool _val) { if (!_self.has_halfedge_status()) _self.request_halfedge_status(); @@ -749,7 +760,7 @@ void expose_mesh(py::module& m, const char *_name) { _self.status(_h).set_deleted(_val); }) - .def("request_vertex_normals", &Mesh::request_vertex_normals) + .def("request_vertex_normals", &Mesh::request_vertex_normals) .def("request_vertex_colors", &Mesh::request_vertex_colors) .def("request_vertex_texcoords1D", &Mesh::request_vertex_texcoords1D) .def("request_vertex_texcoords2D", &Mesh::request_vertex_texcoords2D)