Browse Source

python: add more getters to trade.MeshDataXD.

Was not sure if properties or methods, but this thing is scheduled for a
rewrite anyway.
pull/8/head
Vladimír Vondruš 7 years ago
parent
commit
70fe4e8a25
  1. 6
      src/python/magnum/test/test_primitives.py
  2. 5
      src/python/magnum/trade.cpp

6
src/python/magnum/test/test_primitives.py

@ -49,6 +49,12 @@ class Square(unittest.TestCase):
a = primitives.square_solid(primitives.SquareTextureCoords.GENERATE)
self.assertEqual(a.primitive, MeshPrimitive.TRIANGLE_STRIP)
self.assertFalse(a.is_indexed())
self.assertTrue(a.has_texture_coords2d())
b = primitives.square_solid()
self.assertEqual(b.primitive, MeshPrimitive.TRIANGLE_STRIP)
self.assertFalse(b.is_indexed())
self.assertFalse(b.has_texture_coords2d())
def test_wireframe(self):
a = primitives.square_wireframe()

5
src/python/magnum/trade.cpp

@ -140,7 +140,9 @@ template<UnsignedInt dimensions> void imageData(py::class_<Trade::ImageData<dime
template<class T> void meshData(py::class_<T>& c) {
c
.def_property_readonly("primitive", &T::primitive, "Primitive")
.def("is_indexed", &T::isIndexed, "Whether the mesh is indexed");
.def("is_indexed", &T::isIndexed, "Whether the mesh is indexed")
.def("has_texture_coords2d", &T::hasTextureCoords2D, "Whether the data contain any 2D texture coordinates")
.def("has_colors", &T::hasColors, "Whether the data contain any vertex colors");
}
/* For some reason having ...Args as the second (and not last) template
@ -209,6 +211,7 @@ void trade(py::module& m) {
py::class_<Trade::MeshData3D> meshData3D{m, "MeshData3D", "Three-dimensional mesh data"};
meshData(meshData2D);
meshData(meshData3D);
meshData3D.def("has_normals", &Trade::MeshData3D::hasNormals, "Whether the data contain any normals");
py::class_<Trade::ImageData1D> imageData1D{m, "ImageData1D", "One-dimensional image data"};
py::class_<Trade::ImageData2D> imageData2D{m, "ImageData2D", "Two-dimensional image data"};

Loading…
Cancel
Save