def test_assign_to_face(self): cube = self.create_cube() mat, shading_group = self.create_material() result = cube.shadingGroups() self.assertEqual(1, len(result)) materialutils.assign_material(cube.f[0], mat, shading_group) result = cube.shadingGroups() self.assertEqual(2, len(result))
def test_two_mats_one_mesh(self): cube = self.create_cube() mat, shading_group = self.create_material() mat2, shading_group2 = self.create_material() materialutils.assign_material(cube, mat) materialutils.assign_material(cube.f[0], mat2) result = materialutils.get_shading_groups_from_pynode(cube) self.assertListEqual([shading_group, shading_group2], result)
def test_one_mesh_two_used_mats(self): new_mat, shading_group = self.create_material() new_mat2, shading_group2 = self.create_material() cube = self.create_cube() materialutils.assign_material(cube, new_mat) materialutils.assign_material(cube.f[0], new_mat2) used_mats = materialutils.get_used_materials_in_scene() expected = [new_mat, new_mat2] expected.sort() used_mats.sort() self.assertListEqual(expected, used_mats)
def test_multiple_mats_assigned_to_skinned_mesh(self): test_skinned_cube = self.create_cube() test_joints = [self.create_joint() for _ in range(5)] skincl = skinutils.bind_mesh_to_joints(test_skinned_cube, test_joints, maximumInfluences=5) mat1, _ = matutils.create_material('foo') mat2, _ = matutils.create_material('bar') matutils.assign_material(test_skinned_cube, mat1) matutils.assign_material(test_skinned_cube.f[0], mat2) skinned_meshes_from_scene = skinutils.get_skinned_meshes_from_scene() self.assertListEqual([test_skinned_cube], skinned_meshes_from_scene)
def test_get_from_material(self): cube = self.create_cube() mat, shading_group = self.create_material() materialutils.assign_material(cube, mat) result = materialutils.get_shading_groups_from_pynode(cube) self.assertListEqual([shading_group], result)
def test_one_used_mat(self): new_mat, shading_group = self.create_material() cube = self.create_cube() materialutils.assign_material(cube, new_mat) used_mats = materialutils.get_used_materials_in_scene() self.assertListEqual([new_mat], used_mats)
def test_one_mesh_both_mat_and_sg(self): cube = self.create_cube() mat, shading_group = self.create_material() materialutils.assign_material(cube, mat, shading_group) result = cube.shadingGroups()[0].surfaceShader.listConnections()[0] self.assertEqual(mat, result)
def test_asserts_if_mat_or_shading_group_missing(self): cube = self.create_cube() self.create_material() self.assertRaises(AssertionError, lambda: materialutils.assign_material(cube))