mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 05:40:34 +08:00
Importing obj files without usemtl
Summary: When there is no "usemtl" statement in the .obj file use material from .mtl if there is one. https://github.com/facebookresearch/pytorch3d/issues/1068 Reviewed By: bottler Differential Revision: D34141152 fbshipit-source-id: 7a5b5cc3f0bb287dc617f68de2cd085db8f7ad94
This commit is contained in:
committed by
Facebook GitHub Bot
parent
12f20d799e
commit
ef21a6f6aa
7
tests/data/missing_usemtl/README.md
Normal file
7
tests/data/missing_usemtl/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Acknowledgements
|
||||
|
||||
This is copied version of docs/tutorials/data/cow_mesh with removed line 6159 (usemtl material_1) to test behavior without usemtl material_1 declaration.
|
||||
|
||||
Thank you to Keenen Crane for allowing the cow mesh model to be used freely in the public domain.
|
||||
|
||||
###### Source: http://www.cs.cmu.edu/~kmcrane/Projects/ModelRepository/
|
||||
9
tests/data/missing_usemtl/cow.mtl
Executable file
9
tests/data/missing_usemtl/cow.mtl
Executable file
@@ -0,0 +1,9 @@
|
||||
newmtl material_1
|
||||
map_Kd cow_texture.png
|
||||
|
||||
# Test colors
|
||||
|
||||
Ka 1.000 1.000 1.000 # white
|
||||
Kd 1.000 1.000 1.000 # white
|
||||
Ks 0.000 0.000 0.000 # black
|
||||
Ns 10.0
|
||||
12014
tests/data/missing_usemtl/cow.obj
Executable file
12014
tests/data/missing_usemtl/cow.obj
Executable file
File diff suppressed because it is too large
Load Diff
BIN
tests/data/missing_usemtl/cow_texture.png
Executable file
BIN
tests/data/missing_usemtl/cow_texture.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
@@ -658,6 +658,18 @@ class TestMeshObjIO(TestCaseMixin, unittest.TestCase):
|
||||
self.assertTrue(aux.material_colors is None)
|
||||
self.assertTrue(aux.texture_images is None)
|
||||
|
||||
def test_load_no_usemtl(self):
|
||||
obj_filename = "missing_usemtl/cow.obj"
|
||||
# obj_filename has no "usemtl material_1" line
|
||||
filename = os.path.join(DATA_DIR, obj_filename)
|
||||
# TexturesUV type
|
||||
mesh = IO().load_mesh(filename)
|
||||
self.assertIsNotNone(mesh.textures)
|
||||
|
||||
verts, faces, aux = load_obj(filename)
|
||||
self.assertTrue("material_1" in aux.material_colors)
|
||||
self.assertTrue("material_1" in aux.texture_images)
|
||||
|
||||
def test_load_mtl_fail(self):
|
||||
# Faces have a material
|
||||
obj_file = "\n".join(
|
||||
|
||||
Reference in New Issue
Block a user