Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2856 connectés 

  FORUM HardWare.fr
  Graphisme
  Divers

  Maxscript : getFaceMatID

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Maxscript : getFaceMatID

n°604705
Nico5779
Posté le 28-01-2005 à 11:33:33  profilanswer
 

Bonjour,  
je suis en train de faire un maxscript, pour exporter une scene selon un format proche du .obj.
Et je n'arrive pas a récuperer le material appliqué a une face, j'essaie avec la fonction getFaceMatId , et ca me renvoi un nombre dont je ne c que faire.
Ce nombre est aléatoire pour tout les faces d'un objet ou je n'assigne pas de material, mais semble correspondre a qqch lorsque je commence a assigner des textures.
Par exemple, si j'assigne une meme texture a toutes les face d'un cube, ben j'obtiens 6 fois le meme nombre.
Mais seulement je c pas du tout a quoi ca correspond, j'esperais que se soit l'id dans le tableau meditmaterial, mais apperement non, ca matche pas.
qqn aurait une idée?
Voici l'etat actuel du script:

Code :
  1. i = 1
  2. for op in meditmaterials do
  3. (
  4. format "%\n" op.name
  5. format "%\n" op.diffuse.r
  6. if op.diffuseMap != undefined then
  7. format "%\n" op.diffuseMap.filename
  8. i += 1
  9. )
  10. i = 1
  11. while true do
  12. (
  13. if isValidNode selection[i] then
  14. (
  15.  tmesh = snapshotAsMesh selection[i]
  16.  format "o#%$\n" selection[i].name
  17.  format "p#p#%/%/%$\n" selection[i].position.x selection[i].position.z -selection[i].position.y
  18.  num_verts = tmesh.numverts
  19.  num_tverts = tmesh.numTverts
  20.  num_nverts = tmesh.numverts
  21.  num_faces = tmesh.numfaces
  22.  ground = getUserProp selection[i] "ground"
  23.  breakable = getUserProp selection[i] "breakable"
  24.  if ground == undefined then ground = 0
  25.  if breakable == undefined then breakable = 0
  26.  format "p#g#%$\n" ground
  27.  format "p#b#%$\n" breakable
  28.  for v = 1 to num_verts do
  29.  (
  30.   vert = getVert tmesh v
  31.   format "v#%/%/%$\n" vert.x vert.z -vert.y
  32.  )
  33.  for t = 1 to num_tverts do
  34.  (
  35.   vert = getTVert tmesh t
  36.   format "t#%/%/%$\n" vert.x vert.y vert.z
  37.  )
  38.  for n = 1 to num_nverts do
  39.  (
  40.   vert = getNormal tmesh n
  41.   format "n#%/%/%$\n" vert.x vert.z vert.y
  42.  )
  43.  pwold = -1
  44.  midold = -1
  45.  for f = 1 to num_faces do
  46.  (
  47.   pw = getFaceSmoothGroup tmesh f
  48.   if(pw != pwold) then
  49.   (
  50.    format "s#%$\n" pw
  51.    pwold = pw
  52.   )
  53.   face = getFace tmesh f
  54.   matid = getFaceMatId tmesh f
  55.    jj = meditmaterials[matid]
  56.    format "m#%\n" matid
  57.    midold = mid
  58.   face2 = getTVFace tmesh f
  59.   face3 = getFaceNormal tmesh f
  60.   x = face.x as integer
  61.   y = face.y as integer
  62.   z = face.z as integer
  63.   x2 = face2.x as integer
  64.   y2 = face2.y as integer
  65.   z2 = face2.z as integer
  66.   format "f#%/%/%&%/%/%&%/%/%$\n" x x2 x y y2 y z z2 z
  67.  )
  68.  format "\n"
  69. )else
  70. (
  71.  format "-->fin<--\n"
  72.  exit
  73. )
  74. i = i + 1
  75. )


 
 
Merci d'avance  :jap:


Message édité par Nico5779 le 28-01-2005 à 11:37:41
mood
Publicité
Posté le 28-01-2005 à 11:33:33  profilanswer
 

n°604727
Nico5779
Posté le 28-01-2005 à 12:23:32  profilanswer
 

ok c bon g trouvé
voici la version modifié qui fait +/- ce que je veux:

Code :
  1. i = 1
  2. for op in meditmaterials do
  3. (
  4. format "%\n" op.name
  5. format "%\n" op.diffuse.r
  6. if op.diffuseMap != undefined then
  7. format "%\n" op.diffuseMap.filename
  8. i += 1
  9. )
  10. i = 1
  11. while true do
  12. (
  13. if isValidNode selection[i] then
  14. (
  15.  tmesh = snapshotAsMesh selection[i] as TriMesh
  16.  format "o#%$\n" selection[i].name
  17.  format "p#p#%/%/%$\n" selection[i].position.x selection[i].position.z -selection[i].position.y
  18.  num_verts = tmesh.numverts
  19.  num_tverts = tmesh.numTverts
  20.  num_nverts = tmesh.numverts
  21.  num_faces = tmesh.numfaces
  22.  ground = getUserProp selection[i] "ground"
  23.  breakable = getUserProp selection[i] "breakable"
  24.  if ground == undefined then ground = 0
  25.  if breakable == undefined then breakable = 0
  26.  format "p#g#%$\n" ground
  27.  format "p#b#%$\n" breakable
  28.  for v = 1 to num_verts do
  29.  (
  30.   vert = getVert tmesh v
  31.   format "v#%/%/%$\n" vert.x vert.z -vert.y
  32.  )
  33.  for t = 1 to num_tverts do
  34.  (
  35.   vert = getTVert tmesh t
  36.   format "t#%/%/%$\n" vert.x vert.y vert.z
  37.  )
  38.  for n = 1 to num_nverts do
  39.  (
  40.   vert = getNormal tmesh n
  41.   format "n#%/%/%$\n" vert.x vert.z vert.y
  42.  )
  43.  pwold = -1
  44.  midold = -1
  45.  for f = 1 to num_faces do
  46.  (
  47.   pw = getFaceSmoothGroup tmesh f
  48.   if(pw != pwold) then
  49.   (
  50.    format "s#%$\n" pw
  51.    pwold = pw
  52.   )
  53.   face = getFace tmesh f
  54.   tt = classof selection[i].material
  55.   if(tt == Standardmaterial) then
  56.   (
  57.    matname = selection[i].material
  58.   )else
  59.   (
  60.    matid = getFaceMatId tmesh f
  61.    matname = selection[i].material[matid]
  62.   )
  63.   if(midold != matname) then
  64.   (
  65.    format "m#%\n" matname
  66.    midold = matname
  67.   )
  68.   face2 = getTVFace tmesh f
  69.   face3 = getFaceNormal tmesh f
  70.   x = face.x as integer
  71.   y = face.y as integer
  72.   z = face.z as integer
  73.   x2 = face2.x as integer
  74.   y2 = face2.y as integer
  75.   z2 = face2.z as integer
  76.   format "f#%/%/%&%/%/%&%/%/%$\n" x x2 x y y2 y z z2 z
  77.  )
  78.  format "\n"
  79. )else
  80. (
  81.  format "-->fin<--\n"
  82.  exit
  83. )
  84. i = i + 1
  85. )


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Graphisme
  Divers

  Maxscript : getFaceMatID

 

Sujets relatifs
[Maxscript] recup les info rgb d'une face[maxscript] question de newbie sur 1boucle /caméras et /cibles
Maxscript un petit renseignement ...▲ topic Maxscript ▲
3DSmax : mon premier maxscript3DSMAX : maxscript??? export vrml, selection...
Plus de sujets relatifs à : Maxscript : getFaceMatID


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR