Changeset View
Changeset View
Standalone View
Standalone View
tests/python/alembic_tests.py
| Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | class CurveExportTest(AbstractAlembicTest): | ||||
| @with_tempdir | @with_tempdir | ||||
| def test_export_single_curve(self, tempdir: pathlib.Path): | def test_export_single_curve(self, tempdir: pathlib.Path): | ||||
| abc = tempdir / 'single-curve.abc' | abc = tempdir / 'single-curve.abc' | ||||
| script = "import bpy; bpy.ops.wm.alembic_export(filepath='%s', start=1, end=1, " \ | script = "import bpy; bpy.ops.wm.alembic_export(filepath='%s', start=1, end=1, " \ | ||||
| "renderable_only=True, visible_objects_only=True, flatten=False)" % abc.as_posix() | "renderable_only=True, visible_objects_only=True, flatten=False)" % abc.as_posix() | ||||
| self.run_blender('single-curve.blend', script) | self.run_blender('single-curve.blend', script) | ||||
| # Now check the resulting Alembic file. | # Now check the resulting Alembic file. | ||||
| abcprop = self.abcprop(abc, '/NurbsCurve/NurbsCurveShape/.geom') | abcprop = self.abcprop(abc, '/NurbsCurve/CurveData/.geom') | ||||
| self.assertEqual(abcprop['.orders'], [4]) | self.assertEqual(abcprop['.orders'], [4]) | ||||
| abcprop = self.abcprop(abc, '/NurbsCurve/NurbsCurveShape/.geom/.userProperties') | abcprop = self.abcprop(abc, '/NurbsCurve/CurveData/.geom/.userProperties') | ||||
| self.assertEqual(abcprop['blender:resolution'], 10) | self.assertEqual(abcprop['blender:resolution'], 10) | ||||
| class HairParticlesExportTest(AbstractAlembicTest): | class HairParticlesExportTest(AbstractAlembicTest): | ||||
| """Tests exporting with/without hair/particles. | """Tests exporting with/without hair/particles. | ||||
| Just a basic test to ensure that the enabling/disabling works, and that export | Just a basic test to ensure that the enabling/disabling works, and that export | ||||
| works at all. NOT testing the quality/contents of the exported file. | works at all. NOT testing the quality/contents of the exported file. | ||||
| Show All 13 Lines | def test_with_both(self, tempdir: pathlib.Path): | ||||
| abc = self._do_test(tempdir, True, True) | abc = self._do_test(tempdir, True, True) | ||||
| abcprop = self.abcprop(abc, '/Suzanne/Hair system/.geom') | abcprop = self.abcprop(abc, '/Suzanne/Hair system/.geom') | ||||
| self.assertIn('nVertices', abcprop) | self.assertIn('nVertices', abcprop) | ||||
| abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom') | abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom') | ||||
| self.assertIn('.velocities', abcprop) | self.assertIn('.velocities', abcprop) | ||||
| abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom') | abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') | ||||
| self.assertIn('.faceIndices', abcprop) | self.assertIn('.faceIndices', abcprop) | ||||
| @with_tempdir | @with_tempdir | ||||
| def test_with_hair_only(self, tempdir: pathlib.Path): | def test_with_hair_only(self, tempdir: pathlib.Path): | ||||
| abc = self._do_test(tempdir, True, False) | abc = self._do_test(tempdir, True, False) | ||||
| abcprop = self.abcprop(abc, '/Suzanne/Hair system/.geom') | abcprop = self.abcprop(abc, '/Suzanne/Hair system/.geom') | ||||
| self.assertIn('nVertices', abcprop) | self.assertIn('nVertices', abcprop) | ||||
| self.assertRaises(AbcPropError, self.abcprop, abc, | self.assertRaises(AbcPropError, self.abcprop, abc, | ||||
| '/Suzanne/Non-hair particle system/.geom') | '/Suzanne/Non-hair particle system/.geom') | ||||
| abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom') | abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') | ||||
| self.assertIn('.faceIndices', abcprop) | self.assertIn('.faceIndices', abcprop) | ||||
| @with_tempdir | @with_tempdir | ||||
| def test_with_particles_only(self, tempdir: pathlib.Path): | def test_with_particles_only(self, tempdir: pathlib.Path): | ||||
| abc = self._do_test(tempdir, False, True) | abc = self._do_test(tempdir, False, True) | ||||
| self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair system/.geom') | self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair system/.geom') | ||||
| abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom') | abcprop = self.abcprop(abc, '/Suzanne/Non-hair particle system/.geom') | ||||
| self.assertIn('.velocities', abcprop) | self.assertIn('.velocities', abcprop) | ||||
| abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom') | abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') | ||||
| self.assertIn('.faceIndices', abcprop) | self.assertIn('.faceIndices', abcprop) | ||||
| @with_tempdir | @with_tempdir | ||||
| def test_with_neither(self, tempdir: pathlib.Path): | def test_with_neither(self, tempdir: pathlib.Path): | ||||
| abc = self._do_test(tempdir, False, False) | abc = self._do_test(tempdir, False, False) | ||||
| self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair system/.geom') | self.assertRaises(AbcPropError, self.abcprop, abc, '/Suzanne/Hair system/.geom') | ||||
| self.assertRaises(AbcPropError, self.abcprop, abc, | self.assertRaises(AbcPropError, self.abcprop, abc, | ||||
| '/Suzanne/Non-hair particle system/.geom') | '/Suzanne/Non-hair particle system/.geom') | ||||
| abcprop = self.abcprop(abc, '/Suzanne/SuzanneShape/.geom') | abcprop = self.abcprop(abc, '/Suzanne/MonkeyMesh/.geom') | ||||
| self.assertIn('.faceIndices', abcprop) | self.assertIn('.faceIndices', abcprop) | ||||
| class LongNamesExportTest(AbstractAlembicTest): | class LongNamesExportTest(AbstractAlembicTest): | ||||
| @with_tempdir | @with_tempdir | ||||
| def test_export_long_names(self, tempdir: pathlib.Path): | def test_export_long_names(self, tempdir: pathlib.Path): | ||||
| abc = tempdir / 'long-names.abc' | abc = tempdir / 'long-names.abc' | ||||
| script = "import bpy; bpy.ops.wm.alembic_export(filepath='%s', start=1, end=1, " \ | script = "import bpy; bpy.ops.wm.alembic_export(filepath='%s', start=1, end=1, " \ | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | def test_export_long_names(self, tempdir: pathlib.Path): | ||||
| abcprop = self.abcprop(abc, '%s/.xform' % name) | abcprop = self.abcprop(abc, '%s/.xform' % name) | ||||
| self.assertEqual(abcprop['.vals'], [ | self.assertEqual(abcprop['.vals'], [ | ||||
| 1.0, 0.0, 0.0, 0.0, | 1.0, 0.0, 0.0, 0.0, | ||||
| 0.0, 1.0, 0.0, 0.0, | 0.0, 1.0, 0.0, 0.0, | ||||
| 0.0, 0.0, 1.0, 0.0, | 0.0, 0.0, 1.0, 0.0, | ||||
| 0.0, 3.0, 0.0, 1.0, | 0.0, 3.0, 0.0, 1.0, | ||||
| ]) | ]) | ||||
| abcprop = self.abcprop(abc, '%s/CubeShape/.geom' % name) | abcprop = self.abcprop(abc, '%s/Cube/.geom' % name) | ||||
| self.assertIn('.faceCounts', abcprop) | self.assertIn('.faceCounts', abcprop) | ||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||
| parser = argparse.ArgumentParser() | parser = argparse.ArgumentParser() | ||||
| parser.add_argument('--blender', required=True) | parser.add_argument('--blender', required=True) | ||||
| parser.add_argument('--testdir', required=True) | parser.add_argument('--testdir', required=True) | ||||
| parser.add_argument('--alembic-root', required=True) | parser.add_argument('--alembic-root', required=True) | ||||
| args, remaining = parser.parse_known_args() | args, remaining = parser.parse_known_args() | ||||
| unittest.main(argv=sys.argv[0:1] + remaining) | unittest.main(argv=sys.argv[0:1] + remaining) | ||||