forked from DLR-RM/BlenderProc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MeshObject): Rework material manipulation
closes DLR-RM#1082
- Loading branch information
1 parent
eaf6d86
commit 84fc5e7
Showing
4 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from blenderproc.python.material.MaterialLoaderUtility import add_alpha, add_alpha_channel_to_textures, \ | ||
add_alpha_texture_node, add_ambient_occlusion, add_base_color, add_bump, add_displacement, add_metal, \ | ||
add_normal, add_roughness, add_specular, change_to_texture_less_render, collect_all, connect_uv_maps, \ | ||
convert_to_materials, create_image_node, create, is_material_used, create_new_cc_material, \ | ||
create_procedural_texture, find_cc_material_by_name, create_material_from_texture | ||
convert_to_material, convert_to_materials, create_image_node, create, is_material_used, \ | ||
create_new_cc_material, create_procedural_texture, find_cc_material_by_name, create_material_from_texture | ||
from blenderproc.python.material.Dust import add_dust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import blenderproc as bproc | ||
|
||
import unittest | ||
|
||
from blenderproc.python.tests.SilentMode import SilentMode | ||
from blenderproc.python.types.MeshObjectUtility import create_primitive | ||
from blenderproc.python.material import MaterialLoaderUtility | ||
|
||
|
||
class UnitTestCheckUtility(unittest.TestCase): | ||
def test_materials(self): | ||
bproc.clean_up(True) | ||
|
||
mat1 = MaterialLoaderUtility.create("mat1") | ||
mat2 = MaterialLoaderUtility.create("mat2") | ||
|
||
obj = create_primitive("CUBE") | ||
self.assertTrue(obj.has_materials() == False) | ||
|
||
obj.add_material(mat1) | ||
self.assertTrue(obj.materials() == 1) | ||
self.assertTrue(obj.get_material_slot_link(0) == "DATA") | ||
self.assertTrue(obj.get_material(0, "DATA").get_name() == "mat1") | ||
self.assertTrue(obj.get_material(0, "OBJECT") is None) | ||
self.assertTrue(obj.get_material(0, "VISIBLE").get_name() == "mat1") | ||
|
||
obj.set_material(0, mat2, "OBJECT") | ||
self.assertTrue(obj.get_material(0, "DATA").get_name() == "mat1") | ||
self.assertTrue(obj.get_material(0, "OBJECT").get_name() == "mat2") | ||
self.assertTrue(obj.get_material(0, "VISIBLE").get_name() == "mat1") | ||
|
||
obj.set_material_slot_link(0, "OBJECT") | ||
self.assertTrue(obj.get_material(0, "DATA").get_name() == "mat1") | ||
self.assertTrue(obj.get_material(0, "OBJECT").get_name() == "mat2") | ||
self.assertTrue(obj.get_material(0, "VISIBLE").get_name() == "mat2") | ||
|
||
obj.set_material(0, None, "OBJECT") | ||
self.assertTrue(obj.get_material(0, "DATA").get_name() == "mat1") | ||
self.assertTrue(obj.get_material(0, "OBJECT") is None) | ||
self.assertTrue(obj.get_material(0, "VISIBLE").get_name() == "mat1") |