| 53 | } |
| 54 | |
| 55 | void BindNormalMap(pybind11::module& m) { |
| 56 | py::classh<NormalMap>(m, "NormalMap") |
| 57 | .def(py::init<>()) |
| 58 | .def(py::init<size_t, size_t>(), "width"_a, "height"_a) |
| 59 | .def("to_array", &ArrayFromNormalMap) |
| 60 | .def_static("from_array", |
| 61 | &NormalMapFromArray, |
| 62 | "array"_a, |
| 63 | "Create normal map as a copy of array. Returns normal map " |
| 64 | "with shape (H, W, 3) where the 3 channels represent the " |
| 65 | "x, y, z components of the normal vectors.") |
| 66 | .def("rescale", &NormalMap::Rescale, "factor"_a, "Rescale normal map.") |
| 67 | .def("downsize", |
| 68 | &NormalMap::Downsize, |
| 69 | "max_width"_a, |
| 70 | "max_height"_a, |
| 71 | "Downsize normal map to fit maximum dimensions.") |
| 72 | .def("to_bitmap", |
| 73 | &NormalMap::ToBitmap, |
| 74 | "Convert normal map to bitmap for visualization.") |
| 75 | .def_property_readonly( |
| 76 | "width", &NormalMap::GetWidth, "Width of the normal map.") |
| 77 | .def_property_readonly( |
| 78 | "height", &NormalMap::GetHeight, "Height of the normal map.") |
| 79 | .def("read", |
| 80 | &NormalMap::Read, |
| 81 | "path"_a, |
| 82 | "Read normal map from file at given path.") |
| 83 | .def("write", |
| 84 | &NormalMap::Write, |
| 85 | "path"_a, |
| 86 | "Write normal map to file at given path.") |
| 87 | .def("__repr__", &CreateRepresentation<NormalMap>); |
| 88 | } |