@@ -684,8 +684,8 @@ def save_obj(
684
684
decimal_places : Optional [int ] = None ,
685
685
path_manager : Optional [PathManager ] = None ,
686
686
* ,
687
- verts_normals : Optional [torch .Tensor ] = None ,
688
- faces_normals : Optional [torch .Tensor ] = None ,
687
+ normals : Optional [torch .Tensor ] = None ,
688
+ faces_normals_idx : Optional [torch .Tensor ] = None ,
689
689
verts_uvs : Optional [torch .Tensor ] = None ,
690
690
faces_uvs : Optional [torch .Tensor ] = None ,
691
691
texture_map : Optional [torch .Tensor ] = None ,
@@ -700,9 +700,9 @@ def save_obj(
700
700
decimal_places: Number of decimal places for saving.
701
701
path_manager: Optional PathManager for interpreting f if
702
702
it is a str.
703
- verts_normals : FloatTensor of shape (V, 3) giving the normal per vertex.
704
- faces_normals : LongTensor of shape (F, 3) giving the index into verts_normals
705
- for each vertex in the face.
703
+ normals : FloatTensor of shape (V, 3) giving the normal per vertex.
704
+ faces_normals_idx : LongTensor of shape (F, 3) giving the index into
705
+ normals for each vertex in the face.
706
706
verts_uvs: FloatTensor of shape (V, 2) giving the uv coordinate per vertex.
707
707
faces_uvs: LongTensor of shape (F, 3) giving the index into verts_uvs for
708
708
each vertex in the face.
@@ -718,12 +718,13 @@ def save_obj(
718
718
message = "'faces' should either be empty or of shape (num_faces, 3)."
719
719
raise ValueError (message )
720
720
721
- if faces_normals is not None and (faces_normals .dim () != 2 or faces_normals .size (1 ) != 3 ):
722
- message = "'faces_normals' should either be empty or of shape (num_faces, 3)."
721
+ if faces_normals_idx is not None and \
722
+ (faces_normals_idx .dim () != 2 or faces_normals_idx .size (1 ) != 3 ):
723
+ message = "'faces_normals_idx' should either be empty or of shape (num_faces, 3)."
723
724
raise ValueError (message )
724
725
725
- if verts_normals is not None and (verts_normals .dim () != 2 or verts_normals .size (1 ) != 3 ):
726
- message = "'verts_normals ' should either be empty or of shape (num_verts, 3)."
726
+ if normals is not None and (normals .dim () != 2 or normals .size (1 ) != 3 ):
727
+ message = "'normals ' should either be empty or of shape (num_verts, 3)."
727
728
raise ValueError (message )
728
729
729
730
if faces_uvs is not None and (faces_uvs .dim () != 2 or faces_uvs .size (1 ) != 3 ):
@@ -741,7 +742,7 @@ def save_obj(
741
742
if path_manager is None :
742
743
path_manager = PathManager ()
743
744
744
- save_normals = all ([n is not None for n in [verts_normals , faces_normals ]])
745
+ save_normals = all ([n is not None for n in [normals , faces_normals_idx ]])
745
746
save_texture = all ([t is not None for t in [faces_uvs , verts_uvs , texture_map ]])
746
747
output_path = Path (f )
747
748
@@ -756,8 +757,8 @@ def save_obj(
756
757
verts ,
757
758
faces ,
758
759
decimal_places ,
759
- verts_normals = verts_normals ,
760
- faces_normals = faces_normals ,
760
+ normals = normals ,
761
+ faces_normals_idx = faces_normals_idx ,
761
762
verts_uvs = verts_uvs ,
762
763
faces_uvs = faces_uvs ,
763
764
save_texture = save_texture ,
@@ -794,8 +795,8 @@ def _save(
794
795
faces ,
795
796
decimal_places : Optional [int ] = None ,
796
797
* ,
797
- verts_normals : Optional [torch .Tensor ] = None ,
798
- faces_normals : Optional [torch .Tensor ] = None ,
798
+ normals : Optional [torch .Tensor ] = None ,
799
+ faces_normals_idx : Optional [torch .Tensor ] = None ,
799
800
verts_uvs : Optional [torch .Tensor ] = None ,
800
801
faces_uvs : Optional [torch .Tensor ] = None ,
801
802
save_texture : bool = False ,
@@ -830,22 +831,22 @@ def _save(
830
831
lines += "v %s\n " % " " .join (vert )
831
832
832
833
if save_normals :
833
- if faces_normals is not None and (faces_normals .dim () != 2 or faces_normals .size (1 ) != 3 ):
834
- message = "'faces_normals ' should either be empty or of shape (num_faces, 3)."
834
+ if faces_normals_idx is not None and (faces_normals_idx .dim () != 2 or faces_normals_idx .size (1 ) != 3 ):
835
+ message = "'faces_normals_idx ' should either be empty or of shape (num_faces, 3)."
835
836
raise ValueError (message )
836
837
837
- if verts_normals is not None and (verts_normals .dim () != 2 or verts_normals .size (1 ) != 3 ):
838
- message = "'verts_normals ' should either be empty or of shape (num_verts, 3)."
838
+ if normals is not None and (normals .dim () != 2 or normals .size (1 ) != 3 ):
839
+ message = "'normals ' should either be empty or of shape (num_verts, 3)."
839
840
raise ValueError (message )
840
841
841
842
# pyre-fixme[16] # undefined attribute cpu
842
- verts_normals , faces_normals = verts_normals .cpu (), faces_normals .cpu ()
843
+ normals , faces_normals_idx = normals .cpu (), faces_normals_idx .cpu ()
843
844
844
845
# Save verts normals after verts
845
- if len (verts_normals ):
846
- V , D = verts_normals .shape
846
+ if len (normals ):
847
+ V , D = normals .shape
847
848
for i in range (V ):
848
- normal = [float_str % verts_normals [i , j ] for j in range (D )]
849
+ normal = [float_str % normals [i , j ] for j in range (D )]
849
850
lines += "vn %s\n " % " " .join (normal )
850
851
851
852
if save_texture :
@@ -879,14 +880,14 @@ def _save(
879
880
"%d/%d/%d" % (
880
881
faces [i , j ] + 1 ,
881
882
faces_uvs [i , j ] + 1 ,
882
- faces_normals [i , j ] + 1 ,
883
+ faces_normals_idx [i , j ] + 1 ,
883
884
)
884
885
for j in range (P )
885
886
]
886
887
elif save_normals :
887
888
# Format faces as {verts_idx}//{verts_normals_idx}
888
889
face = [
889
- "%d//%d" % (faces [i , j ] + 1 , faces_normals [i , j ] + 1 ) for j in range (P )
890
+ "%d//%d" % (faces [i , j ] + 1 , faces_normals_idx [i , j ] + 1 ) for j in range (P )
890
891
]
891
892
elif save_texture :
892
893
# Format faces as {verts_idx}/{verts_uvs_idx}
0 commit comments