Advertisement
expired6978

BSD Export

Jun 19th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. global BSDExport
  2. (
  3. if BSDExport != undefined do ( closerolloutfloater BSDExport )
  4. BSDExport = newrolloutfloater "BSD Export" 250 150
  5.  
  6. global exportRollout
  7.  
  8. fn writeBSDsFromMorphers exportPath objectNode =
  9. (
  10. try
  11. (
  12. for i=objectNode.modifiers.count to 1 by -1 do
  13. (
  14. local m = objectNode.modifiers[i]
  15. if isKindOf m Morpher then
  16. (
  17. for c=1 to 100 do
  18. (
  19. if WM3_MC_HasData m c then
  20. (
  21. local storeCount = 0
  22.  
  23. local morphName = WM3_MC_GetName m c
  24. WM3_MC_SetValue m c 100.0
  25. snapshot objectNode name:morphName
  26. WM3_MC_SetValue m c 0.0
  27. local newMesh = GetNodeByName morphName
  28. local numVerts = meshop.getnumverts objectNode
  29.  
  30. local filePath = exportPath + morphName + ".bsd"
  31. local f=fopen filePath "wb"
  32. WriteLong f storeCount #unsigned
  33.  
  34. for v=1 to numVerts do
  35. (
  36. local sVert = meshop.getVert objectNode v
  37. local tVert = meshop.getVert newMesh v
  38. local mx = (tVert.x - sVert.x)
  39. local my = (tVert.y - sVert.y)
  40. local mz = (tVert.z - sVert.z)
  41.  
  42. if abs(mx) > 0.0001 or abs(my) > 0.0001 or abs(mz) > 0.0001 then
  43. (
  44. local iOffset = v - 1
  45. WriteLong f iOffset #unsigned
  46. WriteFloat f mx
  47. WriteFloat f my
  48. WriteFloat f mz
  49. storeCount += 1
  50. )
  51. )
  52.  
  53. fseek f 0 #seek_set
  54. WriteLong f storeCount #unsigned
  55.  
  56. delete newMesh
  57. fclose f
  58. )
  59. )
  60. )
  61. )
  62. )
  63. catch
  64. (
  65. throw
  66. )
  67. )
  68.  
  69. rollout exportRollout "Export"
  70. (
  71. editText exportFilePath "Export File Path" labelOnTop:true
  72. button openFileButton "Browse..."
  73. button exportButton "Export"
  74.  
  75. on openFileButton pressed do
  76. (
  77. local exportPath = getSavePath caption:"Select Folder" initialDir:exportFilePath.text
  78. if exportPath != undefined do
  79. (
  80. exportFilePath.text = exportPath + "\\"
  81. )
  82. )
  83.  
  84. on exportButton pressed do
  85. (
  86. local workingDirectory = pathConfig.getCurrentProjectFolder() + "\\"
  87. if exportFilePath.text != "" then
  88. workingDirectory = exportFilePath.text
  89.  
  90. writeBSDsFromMorphers workingDirectory $
  91.  
  92. MessageBox("Export finished.")
  93. )
  94. )
  95.  
  96. addRollout exportRollout BSDExport rolledup:false
  97. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement