
    Mi                        S SK r S SKrS SKJrJr  S SKr S SKJr  SSKJr  SSKJrJr  SSKJr  SS	KJrJrJr  SS
KJr  SSKJr  SSKJrJr         S"S\S\\   S\S\S\S\\   S\S\S\4S jjr S#S jr!S r"S r#S r$S\S\S\4S jr%S$S jr&         S%S  jr'S!\ 0r(g! \	 a  r
SSKJr  \" \
5      r Sr
C
NSr
C
ff = f)&    N)defaultdictdeque)Image   )ExceptionWrapper)util)logtol)ResolverLike)DictLoadableOptional)to_float)SimpleMaterial)TextureVisualsunmerge_facesfile_objresolvergroup_materialskip_materialsmaintain_ordermetadatasplit_objectssplit_groupsreturnc           
        ^- U R                  5       n	[        R                  " U	5      n	SR                  U	R	                  5       R                  SS5      5      n	U	R                  SS5      n	0 n
U	R                  S5      nU(       df  US:  a`  XS-   U	R                  SU5       R	                  5       n [        X   US	9nUR                  5        VVs0 s H  u  pU[        S/0 UD6_M     n
nn[        U	S9u  nnnn[!        XU5      nU(       d  U(       d  U(       a  [#        UX&U5      n[%        U5      (       d  Ub  SU0nUb  UUS'   Ub  UUS'   U$ 0 n[%        U5      S:  Ga  UR'                  5       u  nnnn[(        R*                  " SU[(        R,                  S9SS  Vs/ s H&  nUR+                  SS5      S   R	                  5       PM(     nn[%        US   R                  SS5      R+                  5       5      m-[/        U-4S jU 5       5      nU(       af  [0        R2                  " SR5                  U5      R                  SS5      S[0        R6                  S9nUUS:  ==   S-  ss'   [9        UT-US   S9u  nnn O%[        R                  " S5        [;        U5      u  nnn / n!U(       a  Ub  U!R=                  U5        U(       a  Ub  U!R=                  U5        U(       a,  [%        U
5      S:  a  Ub  U!R=                  [?        U5      5        U!(       a  SR5                  U!5      n"O1Ub  Un"O+[A        S [C        USS5      [C        U SS5      S4 5       5      n"[        RD                  " U"U5      n"URG                  5       n#Ub  U b*  [%        U 5      [%        U5      :X  a  [I        UUU US 9u  n$n%n&n'OSn'[I        UUUS 9u  n$n%n&[J        RL                  (       aI  [0        RN                  " UU   UU%   U$   5      (       d   eU$RQ                  5       [%        UU%   5      :  d   e UU&   n(U#RS                  UU%   RG                  5       U$S".5        GO=Sn([J        RL                  (       a  URQ                  5       [%        U5      :  d   eUb4  [0        RT                  " U 5      URT                  :X  a  [I        UU US 9u  n$n%n'OU(       a#  [0        RV                  " [%        U5      [X        S#9n%O"[0        RZ                  " [%        U5      [X        S#9n%SU%U'   [0        RZ                  " [%        U5      [0        R6                  S#9n)[0        R\                  " U%R_                  5       5      U)U%'   U)U   n$Sn'U#RS                  U$UU%   RG                  5       S$.5        Ub	   UU%   U#S'   U'bl   UU'   n*U*RT                  U#S   RT                  :w  aD  [a        S&R                  [?        U*RT                  5      [?        U#S   RT                  5      5      5      eU*U#S'   Sn+UU
;   a  [c        U(U
U   S(9n+OEU(b%  [%        U(5      [%        U#S   5      :X  a
  [c        U(S)9n+OUb  [        R                  " S*U S+35        U+U#S,'   U#UU"'   [%        U5      S:  a  GM  URe                  5        Vs/ s H  oUS-.PM	     n,nUU,S..$ s  snnf ! [        [        4 a    [        R                  " S
U 35         GN[         a    [        R                  " S
U 3SS9   GNf = fs  snf ! [         a    [        R                  " S!5        Sn( GNf = f! [         a    [        R                  " S%SS9   GNf = f! [         a    [        R                  " S'SS9   GNnf = fs  snf )0aF  
Load a Wavefront OBJ file into kwargs for a trimesh.Scene
object.

Parameters
--------------
file_obj : file like object
  Contains OBJ data
resolver : trimesh.visual.resolvers.Resolver
  Allow assets such as referenced textures and
  material files to be loaded
group_material : bool
  Group faces that share the same material
  into the same mesh.
skip_materials
  Don't load any materials.
maintain_order
  Make the strongest attempt possible to not reorder faces
  or vertices which may result in visual artifacts and other
  odd behavior. The OBJ data structure is quite different than
  the "flat matching array" used by Trimesh and GLTF so this may
  not be completely possible.
split_objects
  Whenever the loader encounters an `o` directive in the OBJ
  file, split the loaded result into a new Trimesh object.
split_groups
    Whenever the loader encounters a `g` directive in the OBJ
    file, split the loaded result into a new Trimesh object.

Returns
-------------
kwargs : dict
  Keyword arguments which can be loaded by
  trimesh.exchange.load.load_kwargs into a trimesh.Scene
z
{}
z

z\
 mtllibr      )r   zunable to load materials from: Texc_info)textNverticesvertex_normalsvertex_colorsz^f)flags   / c              3   |   >#    U  H1  nT[        UR                  S S5      R                  5       5      :H  v   M3     g7f)r)   r*   N)lenreplacesplit).0fcolumnss     n/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/exchange/obj.py	<genexpr>load_obj.<locals>.<genexpr>   s/     YjC		#s(;(A(A(C$DDjs   9<sepdtype)arrayr1   sample_linez+faces have mixed data: using slow fallback!_c              3   0   #    U  H  nUc  M  Uv   M     g 7fN r/   is     r2   r3   r4      s"      A
  s   		file_namenamegeometry)maintain_facesz)index failed on UV coordinates, skipping!)r$   facesr7   )rD   r$   zfailed to load vertex_colorszincorrect normals {} != {}zfailed to load vertex_normals)uvmaterial)rF   zspecified material (z)  not loaded!visual)rB   frame_to)rB   graphr=   )3readr   decode_textformatstripr-   find	parse_mtlitemsr   OSError	TypeErrorr	   debugBaseException_parse_vertices_preprocess_faces	_group_byr,   poprer.   	MULTILINEallnp
fromstringjoinint64_parse_faces_vectorized_parse_faces_fallbackappendstrnextgetattrunique_namecopyr   r
   strictallclosemaxupdateshapeonesboolzerosarangesum
ValueErrorr   keys).r   r   r   r   r   r   r   r   kwargsr#   	materialsmtl_positionmtl_pathmaterial_kwargskvvnvtvcface_tuplespcrB   rG   current_objectcurrent_groupchunkr?   
face_lines
flat_arrayr8   rD   	faces_tex
faces_norm
name_partsrA   mesh	new_facesmask_vmask_vtmask_vnrF   inversenormalsrH   rJ   r1   s.                                                @r2   load_objr      s   ^ ==?DD!D ??4::<//=>D <<#D I99X&Lla/ q(499T<+HIOOQ
	S'(:XNO<K<Q<Q<ST<SDAN/Q//<SIT $.MAr2r $DFK
 ,^LY {!_>#%B >"$B	 H
k
Q
9D9J6.- XXdE>qrB
B GGD!Q%%'B 	 
 jm++C5;;=>YjYY
  MM$,,S#6CrxxE
 %!)! ,CW*Q-,(E9j IICD+@+L(E9j 
^7n-M5m,c)nq0X5Ic(m, 88J'D'!D   Hk48Hfd3 D h/ {{}  %#j/SZ*G6C9j73	67G -:9^.*	67 zz {{1U8QvYy-ABBBB }}QvY777 [ KKQvY^^%5	JK Bzzyy{SV+++~"((:"6%++"E-::n.*	67 "WWSV48FXXc!fD9F $u ((3q6:"$))FJJL"9#EN	 KK)69IJK >I(*6
_% JW+==D$4$:$::$4;;.D4D4J4J0K 
 *1%& y #rIh4GHF^B3tJ/?+@ @#r*F!II,XJnEFXe k
Q
j 6>]]_E_+_EE !511y U# 	DII7zBC 	SII7zBTR	S^
v ! 		EFV ! I		84HI ! J		9DIJ& Fsm   /Z$ Z&Z$ -[8[= 	\& A+] 	]2Z$ $)[5![54[5="\#"\#&]	]	]/.]/c           
         [         R                  " U 5      n Sn0 n[        R                  [        U 5      R	                  5       5      nSSSSS.nU GH  nUR	                  5       R                  5       n[        U5      S::  a  M3  US   R                  5       nUS	:X  a"  Ub  X#US
   '   S
SR                  USS 5      0nMn  US:X  a  UR                  5       R                  S5      S-   n	XiS R	                  5       n
 UR                  U
5      n[        R                  " [         R                  " U5      5      US'   [        R                  R!                  [        R                  R                  [#        USS5      U
5      5      US   R$                  S'   GMB  XR-                  5       ;   aF   USS  Vs/ s H  n[/        U5      PM     nn[        U5      S:X  a  US   nUb  XXX   '   XU'   GM  GM  Uc  GM  USS X('   GM     U(       a  X#US
   '   U$ ! [&         a    [(        R*                  " SSS9   GM  f = fs  snf ! [&         a    [(        R*                  " SSS9   GM  f = f)a  
Parse a loaded MTL file.

Parameters
-------------
mtl : str or bytes
  Data from an MTL file
resolver : trimesh.Resolver
  Fetch assets by name from file system, web, or other

Returns
------------
mtllibs : list of dict
  Each dict has keys: newmtl, map_Kd, Kd
Ndiffuseambientspecular
glossiness)kdkaksnsr(   r   newmtlrA   r*   map_kdr    imageparentr   	file_pathzfailed to load imageTr!   zfailed to convert color!)r   rL   rd   
splitlinesrN   r.   r,   lowerr_   indexgetr   openwrap_as_streamospathabspathrf   inforU   r	   rT   rt   float)mtlr   rG   rv   linesmappedliner.   keyr   r@   	file_dataxvalues                 r2   rP   rP   @  s:   " 

3
C HINN3s8>>+,E YjUF

""$u:?Ahnn(? #.6(6*+ qr 34HH_JJL&&x014EV**,IA$LL3	 %*JJt/B/B9/M$N!68ggooGGLL8R!@)L7!&&{3 KKM!E+0959aq95u:?!!HE',1V[)$)SM	 ( !!!"IHMk n &.(6"#3 ! A		04@A 6 ! E		4tDEs7   9BH&H9-H4#H9H10H14H99IIc                 4   U R                  SU45      n [        UR                  5       R                  5       5      n[	        X-  5      n[
        R                  " U5      U-  nU SS2U4   nSu  pxXS-  :X  a  SR                  S UR                  5        5       5      R                  S5      n	X:X  a  U SS2US-   4   nOYU	[	        US-  5      :X  a  U SS2US-   4   nO:[        R                  " S	U 35        O XS
-  :X  a  U SS2US-   4   nU SS2US-   4   nXgU4$ )a  
Parse loaded homogeneous (tri/quad) face data in a
vectorized manner.

Parameters
------------
array : (n,) int
  Indices in order
columns : int
  Number of columns in the file
sample_line : str
  A single line so we can assess the ordering

Returns
--------------
faces : (n, d) int
  Faces in space
faces_tex : (n, d) int or None
  Texture for each vertex in face
faces_norm : (n, d) int or None
  Normal index for each vertex in face
NNNr   r   c              3   B   #    U  H  oR                  S 5      v   M     g7f)r)   N)rN   r>   s     r2   r3   *_parse_faces_vectorized.<locals>.<genexpr>  s     B.A.As   r)   r(   zface lines are weird:    )reshaper,   rN   r.   intr]   rq   r_   countr	   rT   )
r8   r1   r9   group_countper_refr   rD   r   r   r   s
             r2   ra   ra     s/   0 MM2w-(E k'')//12K ''(GIIk"W,E!U(OE 'I/! Bk.?.?.ABBHHM q%!)|,Jc'A+&& al+III.{m<=	!O	# !UQY,'	1eai<(
Z''    c                    / / / p2nU  GH_  nUR                  5       R                  S5      S   R                  5       n[        U5      nUS:X  a  OUS:X  a  US   US   US   US   US   US   /nOUS:  aZ  / nUR                  n[	        [        U5      S-
  5       V	s/ s H'  n	U" US   5      U" XYS-      5      U" XYS-      5      /PM)       n	UnO%[
        R                  " S[        U5       S35        M  U Hm  n
U
R                  S	5      nUR                  [        US   5      5         UR                  [        US   5      5         UR                  [        US   5      5        Mo     GMb     [        R                  " U[        R                  S
9R                  S5      nXS:  ==   S-  ss'   Su  p[        U5      [        U5      :X  aA  [        R                  " U[        R                  S
9R                  S5      nXS:  ==   S-  ss'   [        U5      [        U5      :X  aA  [        R                  " U[        R                  S
9R                  S5      nXS:  ==   S-  ss'   XU4$ s  sn	f ! [         a     GN4f = f! [         a     GM  f = f)a  
Use a slow but more flexible looping method to process
face lines as a fallback option to faster vectorized methods.

Parameters
-------------
lines : (n,) str
  List of lines with face information

Returns
-------------
faces : (m, 3) int
  Clean numpy array of face triangles
r   r   r      r(   r   zface needs more values 3>z
 skipping!r)   rE   )r   r   r   )rN   r.   r,   rc   ranger	   rT   r   rU   r]   r8   r`   r   )r   r{   r}   r|   r   r.   	len_splitcollectcollect_appendr?   r0   rD   r   r   s                 r2   rb   rb     sm   " B2A  

""4(+113J	>!^1XuQxq58U1XuQxPE]G %^^N s5zA~. /A	 #58,"5Q<0"5Q<0
 / EII1#e*ZHI AGGCLEHHSq]#		#eAh-(		#eAh-( ? d HHQbhh'//8E	!)#I
2w#a&HHRrxx088A	a- A% 
2w#a&((2RXX.66w?!!W$$W. ! 
 ! s*   .I'(I,I=,
I:9I:=
JJc                 >   S Vs0 s H  oU R                  SU S35      _M     nn[        S UR                  5        5       5      (       d  gUR                  5        VVs0 s HA  u  pUS:  d  M  XR                  SU R	                  SU S35      S-   [        U5      -   5      _MC     nnn[        S UR                  5        5       5      n[        S	 UR                  5        5       5      nXU R                  S
S5      R                  SS5      nUR                  5        VVVs0 s HH  u  pUS:  d  M  XR                  SU S35      SS  Vs/ s H  oR                  SS5      S   PM     sn_MJ     n	nnnU	R                  5        VVs0 s H"  u  pU[        US   R                  5       5      _M$     n
nn[        S 5      nU	R                  5        GH/  u  p[        R                  " SR                  U5      S[        R                  S9n[        U5      X   4n[        U5      [        R                  " U5      :X  a  UR!                  U5      X'   M  / nU VVs/ s HS  n["        R%                  U5       Vs/ s H/  o?R'                  UR)                  5       R                  5       5      PM1     snPMU       nn[        S U 5       5      n[        R*                  " U Vs/ s H  nUSU PM
     sn[        R                  S9X'   GM2     US   nSnUb*  UR,                  S   S:  a  USS2SS24   USS2SS24   nnO!Ub  UR,                  S   S:  a  USS2SS24   nUS   nUb  USS2SS24   nUS   n[.        R0                  (       af  [        U5      U R3                  S5      :X  d   eUb   [        U5      U R3                  S5      :X  d   eUb   [        U5      U R3                  S5      :X  d   eUUUU4$ s  snf s  snnf s  snf s  snnnf s  snnf s  snf s  snnf s  snf )ab  
Parse raw OBJ text into vertices, vertex normals,
vertex colors, and vertex textures.

Parameters
-------------
text : str
  Full text of an OBJ file

Returns
-------------
v : (n, 3) float
  Vertices in space
vn : (m, 3) float or None
  Vertex normals
vt : (p, 2) float or None
  Vertex texture coordinates
vc : (n, 3) float or None
  Per-vertex color
)r{   r}   r|   r   r*   c              3   *   #    U  H	  oS :  v   M     g7fr   Nr=   )r/   r{   s     r2   r3   "_parse_vertices.<locals>.<genexpr>N  s     /!Avs   )NNNNr   r   c              3   4   #    U  H  oS :  d  M
  Uv   M     g7fr   r=   )r/   ss     r2   r3   r   Y  s     5?a1f?   		c              3   4   #    U  H  oS :  d  M
  Uv   M     g7fr   r=   )r/   es     r2   r3   r   Z  s     1Aq&aar   z+er   z-er(   Nc                      g r<   r=   r=   r   r2   <lambda>!_parse_vertices.<locals>.<lambda>i  s    r   r5   c              3   8   #    U  H  n[        U5      v   M     g 7fr<   )r,   )r/   Ls     r2   r3   r   z  s     .1As   rE   r{   r    r   r}   r|   
v 
vn 
vt )rO   anyvaluesrQ   rfindr,   minrk   r-   r.   r   r]   r^   r_   float64prodr   rd   r   rc   rN   r8   rm   r
   ri   r   )r#   rz   startsr{   endsstartendr   r?   dataper_rowresultr   r8   rm   r   r   r   r~   r}   r|   s                        r2   rV   rV   0  s   6 0AA/@!Rs!9%%/@FA /v}}///%
 LLN"DA6 	?99T4::1#Qi014s1v=>>" 	  56==?55E
11
1CsO##D#.66tSAE
 LLN"DA6 	Er!AY)?)CD)CAGGD!Q)CDD" 	  15

=q#adjjl##G= &FJJLchhuo3bjjIUWZ(u:'e,FI
 ESXYSXas~~a7HI7H!ll1779??,-7HISXY...EU!;U!FU)U!;2::NFI% !* 	sA	B}q!RaR%!AqsF)22	
1771:>a!eH 
B	~2A2Y	B zz 1vF++++>r7djj1111>r7djj1111b"b=e B E >$ JY "<sS   O2O7/8O7"P2PO=*P)P	P46P*PP
=PPuse_mtluse_obj	use_groupc                 ^   [        S 5      nU  HQ  u  pVpxU(       a  UOSU(       a  UOSU(       a  UOS4n	XTU	   S'   XdU	   S'   XtU	   S'   XI   S   R                  U5        MS     UR                  5        H  n	SR                  XI   S   5      XI   S'   M      [	        UR                  5       5      $ )a  
For chunks of faces split by material group
the chunks that share the same material.

Parameters
------------
face_tuples : (n,) list of (material, obj, chunk)
  The data containing faces
use_mtl
  Group tuples by `usemtl` commands
use_obj
  Group tuples by `o` commands
use_group
  Group tuples by `g` commands

Returns
------------
grouped : (m,) list of tuples containing:
          `(material name, objectname, group name, raw chunk)`
c                      SSS/ /$ )Nr   r=   r=   r   r2   r   _group_by.<locals>.<lambda>  s    2r2r"2r   Nr   r(   r   r   r   )r   rc   rt   r_   listr   )
r   r   r   r   groupedrG   objgroupr   r   s
             r2   rX   rX     s    . 23G'2#u  HTCED

 #QQQQu% (3 ||~))GLO4Q   !!r   c           
      v   / SQn[        U 5      nU H'  nU R                  USU5      nUS:  a  M  Xd:  d  M%  UnM)     U R                  SU R                  S5      S-   5      nUS:  a  XU nOXS n[        R                  (       a&  UR                  S5      U R                  S5      :X  d   e[        R                  " [        R                  " SU5       V	s/ s H  oR                  S5      PM     sn	[        S9n
S[        U5      /U
/nU(       a\  UR                  [        R                  " [        R                  " S	U5       V	s/ s H  oR                  S5      PM     sn	[        S95        U(       a\  UR                  [        R                  " [        R                  " S
U5       V	s/ s H  oR                  S5      PM     sn	[        S95        [        R                  " [        R                  " [        U5      5      5      nSnSnSn/ n[!        USS USS 5       GH  u  nnUUU R#                  5       S-   nUR%                  S5      (       a)  UR'                  SS5      u  nnUSS R#                  5       nO}UR%                  S5      (       a)  UR'                  SS5      u  nnUSS R#                  5       nO>UR%                  S5      (       a(  UR'                  SS5      u  nnUSS R#                  5       nUR%                  S5      (       d  SU;   d  M  UR                  XUU45        GM     U$ s  sn	f s  sn	f s  sn	f )af  
Pre-Process Face Text

Rather than looking at each line in a loop we're
going to split lines by directives which indicate
a new mesh, specifically 'usemtl', 'o', and 'g' keys
search for materials, objects, faces, or groups

Parameters
------------
text : str
  Raw file

Returns
------------
triple : (n, 3) tuple
  Tuples of (material, object, data-chunk)
)z
usemtl 
o 
f 
g z
s r   r   r   r   Nusemtl rE   r   r   r   r(   zo r   usemtlr    zg f z
f)r,   rO   r   r
   ri   r   r]   r8   rZ   finditerr   r   rc   uniqueconcatenatetupleziprN   
startswithr.   )r#   r   
use_groupsstartersf_startstsearchf_endf_chunkmidx_mtl
split_idxssplitscurrent_objcurrent_mtlr   r   r   r   r   s                       r2   rW   rW     s   ( =H$iG2q'*A: G  IIdDJJv.23Ezu% x.
zz}}V$

6(:::: hhBKK	7,KL,Kq
,KLTWXGc'l#W-J HH"++fg*FG*FQggaj*FGsS	
 HH"++fg*FG*FQggaj*FGsS	

 YYr~~eJ&789F KKMK&"+vabz2
sc"((*T1D!!!&T1!5K%ab///1Kh''!&T1!5K%ab///1Kd###(;;tQ#7 M5)!"-335M D!!Ue^-OP! 3" U M H
 Hs   L,L1%L6c
                    SSSSS.n
[         R                  " U S5      (       a  U /nOX[         R                  " U S5      (       a  U R                  5       nO+[         R                  " U S5      (       a  U /nO[        S	5      e[	        5       nS
S
S
S.n0 n[        5       nU GH\  nS/nU(       a  UR                  R                  S;   am  [        UR                  R                  5      (       aI  [        R                  " UR                  [        UR                  R                  SS2SS24   5      45      nOUR                  n[	        S[         R                  " USSUS9-   /5      nUc  SUR                  R                   ;   nU(       aG   [         R                  " UR"                  SSUS9nUR%                  S5        UR%                  SU-   5        U(       GaM  [-        UR                  S5      (       Ga1   UR                  R.                  n[-        US5      (       a  UR1                  5       n[3        U5      nUU;  aD  [         R4                  " UR6                  U5      nUR9                  U5        UR;                  US9UU'   UU   S   n[        [        R<                  " [?        UR                  SS5      5      5      S:X  aP  [         R                  " UR                  R@                  SS US9nUR%                  S!5        UR%                  S"U-   5        URC                  S#U 35        U
[E        U5         n[-        US%5      (       a<  UR%                  S&[         R                  " URF                  S-   US   -   SS'US(9-   5        US==   [        UR                  5      -  ss'   S)URH                  ;   a-  URC                  S*RK                  URH                  S)   5      5        UR%                  S+RM                  U5      5        GM_     0 n[        U5      S
:  a  / nURO                  5        H}  u  nnURQ                  5        Hc  u  nnURS                  5       RU                  S,5      (       a  UR%                  U5        M=  UU;  a  UUU'   MJ  [(        RV                  " S-U 35        Me     M     Uc  S.nU	b  S/U	 S03RY                  5       n OS1n U S2RM                  U5      -   UU'   URC                  S3U 35        U	b  URC                  S/U	 35        UR%                  S+5        S+RM                  U5      n!U(       aG  UbD  [        U5      S
:  a5  URQ                  5        V"V#s/ s H  u  n"n#UR[                  U"U#5      PM       n"n#U(       a  U!U4$ U!$ ! [&         a    [(        R*                  " SSS9   GNf = f! [&         a    [(        R*                  " S$SS9   GNf = fs  sn#n"f )4a  
Export a mesh as a Wavefront OBJ file.
TODO: scenes with textured meshes

Parameters
-----------
mesh : trimesh.Trimesh
  Mesh to be exported
include_normals : Optional[bool]
  Include vertex normals in export. If None
  will only be included if vertex normals are in cache.
include_color : bool
  Include vertex color in export
include_texture : bool
  Include `vt` texture in file text
return_texture : bool
  If True, return a dict with texture files
write_texture : bool
  If True and a writable resolver is passed
  write the referenced texture files with resolver
resolver : None or trimesh.resolvers.Resolver
  Resolver which can write referenced text objects
digits : int
  Number of digits to include for floating point
mtl_name : None or str
  If passed, the file name of the MTL file.
header : str or None
  Header string for top of file or None for no header.

Returns
-----------
export : str
  OBJ format output
texture : dict
  Contains files that need to be saved in the same
  directory as the exported mesh: {file name : bytes}
z{}z{}//{}z{}/{}z{}/{}/{}))r{   )r{   r|   )r{   r}   r{   r|   r}   TrimeshScene
PointCloudzmust be Trimesh or Scene!r   r  r{   )vertexfaceNr   zv r*   r   )	col_delim	row_delimdigitsr%   r   r|   zvn z failed to convert vertex normalsTr!   rF   	to_simple)rA   r(   r   r   r}   zvt r   z failed to convert UV coordinatesrD   r   r   )r  r  value_formatrA   z
o {}r   z.mtlznot writing zmaterial.mtlz# z

r   s   

zmtllib ).r   is_instance_nameddumprs   r   setrH   kindr,   r&   r]   column_stackr$   r   array_to_string_cachecacher%   rc   rU   r	   rT   hasattrrG   r  hashrg   rA   addto_objrm   rf   rF   
appendleftr   rD   r   rM   r_   r   rQ   r   endswithwarningencodewrite)$r   include_normalsinclude_colorinclude_texturereturn_texturewrite_texturer   r  mtl_nameheaderface_formatsmeshesobjectscountsrv   materials_namecurrent	face_typev_blobexport	convertedrG   hashedrA   tex_nameface_formatmtl_datamtl_libr   r:   r@   r   prependr#   rz   r{   s$                                       r2   
export_objr:  +  s]   h %	L dI..			g	.	.			l	3	3455 gGAQ'FIUNE	 ##'99GNN0011 __!!8GNN,H,HBQB,O#PQF
 %%F &&cVF
 ".'..2F2FFOM 00**!%!		   &ei/0
 ww~~t<<M">>228[11'113H h*++HMM>JD"&&t,(0T(BIf% %V,Q/ rxxd CDEJ $ 4 4))SGTZ!I $$T*MM%)"34!!GH:"67
 #5#347G$$MM&&MMA%s3!$!,	 	ss7++,, W%%%hoog.>.>v.FGHtyy()M R H
9~ !'')GD!(,

$	9??$--f55NN9-h.*3HY'KK,yk :; )5 * %H 6($'..0GG %w||G'<<WXJ/0Rx=) NN4 99WD -#i.12D*2..*:;*:$!Q1	*:; X~Kc ! M		<tLMF ! M		<tLMP 	<s,   AV2D0V'WV$#V$'W
	W
r   )NTFFNFFr<   )FF)	NTTFTN   Nz!https://github.com/mikedh/trimesh))r   rZ   collectionsr   r   numpyr]   PILr   rU   E
exceptionsr   r   r   	constantsr	   r
   	resolversr   typedr   r   r   visual.colorr   visual.materialr   visual.texturer   r   ro   r   rP   ra   rb   rV   rX   rW   r:  _obj_loadersr=   r   r2   <module>rH     sK   	 	 * 	      $ , , # , :
 (,  #b2b2|$b2 b2 	b2
 b2 tnb2 b2 b2 
b2J	Wt@(FP%fm`)"D )"4 )"D )"X\B .iX x Y     .QE s   B% %C+B>>C