Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.69 KB | None | 0 0
  1. /*
  2. Ninja Ripper 1.1.2 3D Max Importer
  3. Importer version 1.3 beta7
  4.  
  5. changes:
  6.  
  7. 2013.01.09 (1.3 beta7):
  8. - added uv Scale function
  9. - improved model Scale function
  10. */
  11.  
  12. try (destroydialog nr_rollout) catch()
  13.  
  14. -- allow ~ 40 MB instead of just 7.5 MB. Prevents "Runtime Error: Out of scripter memory"
  15. if (heapSize < 200000) then
  16. heapSize = 2000000
  17.  
  18. -- force useing one CPU core
  19. if SysInfo.CPUCount == 1 then
  20. TargetAffinity = 1
  21. else (
  22. TargetAffinity = 0
  23. for CoreID = 2 to SysInfo.CPUCount do
  24. TargetAffinity = (Bit.Set TargetAffinity CoreID true)
  25. )
  26. SysInfo.ProcessAffinity = TargetAffinity
  27.  
  28.  
  29. ---Constants
  30. global RipSignature = 0xDEADC0DE
  31. global RipFileVersion = 4
  32.  
  33.  
  34. ---Global vars
  35. global g_ImportType = 1 --- Group/Single/List (0,1,2)
  36. global g_InputSrc = "" --- Source Dir/File
  37. global g_VertexFormatRecog = 0 --- Auto/Manual (0,1)
  38. global g_Tex0_FileLev = 0
  39.  
  40. global g_PosX_Idx = 0
  41. global g_PosY_Idx = 0
  42. global g_PosZ_Idx = 0
  43. global g_NormX_Idx = 0
  44. global g_NormY_Idx = 0
  45. global g_NormZ_Idx = 0
  46. global g_Tc0_U_Idx = 0
  47. global g_Tc0_V_Idx = 0
  48.  
  49. --Globals additional
  50. global g_ninjaScale = 100
  51. global g_ninjarotX = 90
  52. global g_ninjarotY = 0
  53. global g_ninjarotZ = 0
  54. global g_flipUV = 1
  55. --global g_scaleUV = 1
  56. global uvscaler = 1
  57. global mdlscaler = 100
  58.  
  59. global g_enabler = true
  60.  
  61. -- fn NinjaRotationMatrix =
  62. -- (
  63. -- local angles = eulerAngles 0 -0 -90
  64. -- --local angles = eulerAngles g_ninjarotZ -g_ninjarotY -g_ninjarotX
  65. -- return angles as matrix3
  66. -- )
  67.  
  68. fn isNumSeqNR str = ((trimLeft str ".0123456789").count == 0)
  69.  
  70. fn ReadStr bstream =
  71. (
  72. local str = ""
  73. while true do
  74. (
  75. str0 = ReadByte bstream #unsigned
  76. if str0 == 0 then exit
  77. str+= bit.intAsChar str0
  78. )
  79. str
  80. )
  81.  
  82.  
  83. fn StringClear OrigStr =
  84. (
  85. local Str = ""
  86.  
  87. for j = 1 to OrigStr.count do (
  88. if OrigStr[ j ] != " " then(
  89. Str = Str + OrigStr[ j ]
  90. )
  91. )
  92. Str
  93. )
  94.  
  95.  
  96. fn CreateMeshName Num =
  97. (
  98. local Str = "Mesh_"
  99. local StrNum = ""
  100. r0 = Num as Integer
  101. StrNum = formattedPrint r0 format:"#04u"
  102.  
  103. Str = Str + StrNum as String
  104. Str = Str + ".rip"
  105.  
  106. Str
  107. )
  108.  
  109. fn GetMaterialByName mName =
  110. (
  111. local Material curmat
  112. print("Search material:" + mName)
  113.  
  114. for mat in sceneMaterials do
  115. (
  116. if (mat.name == mName as String ) do
  117. (
  118. curmat = mat
  119. )
  120. )
  121. curmat
  122. )
  123.  
  124. ----------------------------
  125. fn ImportRip RipFilePath =
  126. (
  127. f = fopen RipFilePath "rb"
  128.  
  129. local Signature = readlong f #unsigned
  130. local Version = readlong f #unsigned
  131. local dwFacesCnt = readlong f #unsigned
  132. local dwVertexesCnt = readlong f #unsigned
  133. local VertexSize = readlong f #unsigned
  134. local TextureFilesCnt= readlong f #unsigned
  135. local ShaderFilesCnt= readlong f #unsigned
  136. local VertexAttributesCnt= readlong f #unsigned
  137.  
  138.  
  139. print ( "*****ImportRip() File: " + RipFilePath as String )
  140. print ( "dwFacesCnt=" + dwFacesCnt as String )
  141. print ( "dwVertexesCnt=" + dwVertexesCnt as String )
  142. print ( "VertexAttributesCnt=" + VertexAttributesCnt as String )
  143.  
  144.  
  145. VertexAttribTypesArray= #() ---Contain all types
  146. TextureFiles = #()
  147. ShaderFiles = #()
  148.  
  149. Face_array = #()
  150. Normal_array = #()
  151. Vert_array = #()
  152. UV_array = #()
  153.  
  154.  
  155. local TempPosIdx = 0 ---Get only first index attribute flag
  156. local TempNormalIdx = 0
  157. local TempTexCoordIdx = 0
  158.  
  159. ---Read vertex attributes
  160. for i = 1 to VertexAttributesCnt do (
  161. Semantic = ReadStr f
  162. SemanticIndex = readlong f #unsigned
  163. Offset = readlong f #unsigned
  164. Size = readlong f #unsigned
  165. TypeMapElements = readlong f #unsigned
  166. for j = 1 to TypeMapElements do (
  167. TypeElement = readlong f #unsigned
  168. append VertexAttribTypesArray TypeElement
  169. )
  170. print "------------"
  171. print( "Semantic="+ Semantic )
  172. print( "SemanticIndex=" + SemanticIndex as String )
  173. print( "Offset=" + Offset as String )
  174. print( "Size=" + Size as String )
  175. print( "TypeMapElements=" + TypeMapElements as String )
  176.  
  177. ---Recognize semantic if "AUTO" set
  178. if g_VertexFormatRecog == 0 do ( ---AUTO recognition
  179. if Semantic == "POSITION" do ( --- Get as "XYZ_"
  180. if TempPosIdx == 0 do (
  181. g_PosX_Idx = Offset / 4
  182. g_PosY_Idx = g_PosX_Idx + 1
  183. g_PosZ_Idx = g_PosX_Idx + 2
  184.  
  185. TempPosIdx = TempPosIdx + 1
  186. )
  187. )
  188.  
  189. if Semantic == "NORMAL" do (
  190. if TempNormalIdx == 0 do (
  191. g_NormX_Idx = Offset / 4
  192. g_NormY_Idx = g_NormX_Idx + 1
  193. g_NormZ_Idx = g_NormX_Idx + 2
  194.  
  195. TempNormalIdx = TempNormalIdx + 1
  196. )
  197. )
  198.  
  199. if Semantic == "TEXCOORD" do (
  200. if TempTexCoordIdx == 0 do(
  201. g_Tc0_U_Idx = Offset / 4
  202. g_Tc0_V_Idx = g_Tc0_U_Idx + 1
  203.  
  204. TempTexCoordIdx = TempTexCoordIdx + 1
  205. )
  206. )
  207. )
  208.  
  209.  
  210. )
  211. print "-----------------------------"
  212.  
  213. ---Read texture files list to array ( if present )
  214. for i = 1 to TextureFilesCnt do (
  215. TexFile = ReadStr f
  216. append TextureFiles ( TexFile as String )
  217. )
  218.  
  219.  
  220. ---Read shader files list to array ( if present )
  221. for i = 1 to ShaderFilesCnt do (
  222. ShaderFile = ReadStr f
  223. append ShaderFiles ( ShaderFile as String )
  224. )
  225.  
  226.  
  227. print ( "Texture Files:" )
  228. for i = 1 to TextureFiles.count do (
  229. print ( TextureFiles[ i ] as String )
  230. )
  231. print ( "------------" )
  232.  
  233.  
  234. ---Read indexes
  235. for x = 1 to dwFacesCnt do(
  236. i0 = readlong f #unsigned
  237. i1 = readlong f #unsigned
  238. i2 = readlong f #unsigned
  239. append Face_array[i0+1,i1+1,i2+1]
  240.  
  241. --- print( "idx0: " + i0 as String + " idx1: " + i1 as String + " idx2: " + i2 as String )
  242. )
  243.  
  244.  
  245. print( "PosX idx: " + g_PosX_Idx as String )
  246. print( "PosY idx: " + g_PosY_Idx as String )
  247. print( "PosZ idx: " + g_PosZ_Idx as String )
  248. print( "NormX idx: " + g_NormX_Idx as String )
  249. print( "NormY idx: " + g_NormY_Idx as String )
  250. print( "NormZ idx: " + g_NormZ_Idx as String )
  251. print( "Tu0 idx: " + g_Tc0_U_Idx as String )
  252. print( "Tv0 idx: " + g_Tc0_V_Idx as String )
  253.  
  254.  
  255. ---Read vertexes
  256. for k = 1 to dwVertexesCnt do(
  257.  
  258. ---print ( "VertexIdx : " + (k-1) as String )
  259.  
  260. vx = 0.0
  261. vy = 0.0
  262. vz = 0.0
  263. vw = 0.0
  264. nx = 0.0
  265. ny = 0.0
  266. nz = 0.0
  267. nw = 0.0
  268. tu = 0.0
  269. tv = 0.0
  270.  
  271. for j = 0 to VertexAttribTypesArray.count - 1 do(
  272.  
  273. --- print ( "VertAttr Idx: " + j as String )
  274. ElementType = VertexAttribTypesArray[ j + 1 ]
  275. if ElementType == 0 then ( --- EFLOAT
  276. z = readfloat f
  277. )
  278. else if ElementType == 1 then ( ---EUINT
  279. z = readlong f #unsigned
  280. )
  281. else if ElementType == 2 then ( ---ESINT
  282. z = readlong f #signed
  283. )
  284. else (
  285. z = readlong f #unsigned
  286. )
  287.  
  288. if j == g_PosX_Idx do vx = z
  289. if j == g_PosY_Idx do vy = z
  290. if j == g_PosZ_Idx do vz = z
  291.  
  292. if j == g_NormX_Idx do nx = z
  293. if j == g_NormY_Idx do ny = z
  294. if j == g_NormZ_Idx do nz = z
  295.  
  296. if j == g_Tc0_U_Idx do tu = z
  297. if j == g_Tc0_V_Idx do tv = z
  298.  
  299.  
  300. vx = vx as Float
  301. vy = vy as Float
  302. vz = vz as Float
  303.  
  304. nx = nx as Float
  305. ny = ny as Float
  306. nz = nz as Float
  307.  
  308. tu = tu as Float
  309. tv = 1-tv as Float
  310. )
  311. append Vert_array[(vx * mdlscaler),(vy * mdlscaler),(vz * mdlscaler)]
  312. append Normal_array [nx,ny,nz]
  313. append UV_array[tu * uvscaler,tv * g_flipUV * uvscaler,0]
  314. --append UV_array[tu * g_scaleUV,tv * g_flipUV * g_scaleUV,0]uvscaler
  315. --append UV_array[tu * 0.00001,tv * g_flipUV * 0.00001,0]
  316.  
  317. --print( "vx: " + vx as String + " vy: " + vy as String + " vz: " + vz as String )
  318. --print( "tu: " + tu as String + " tv: " + tv as String )
  319. )
  320.  
  321. TexFile = TextureFiles [ 1 + g_Tex0_FileLev ]
  322. if TexFile == undefined do ( TexFile = "setka.png" )
  323.  
  324. TexFileName = getFilenamePath RipFilePath
  325. TexFileName = TexFileName + TexFile
  326. print ( "TEXTURE FILE: " + TexFileName )
  327.  
  328.  
  329. thenewmaterial = GetMaterialByName(TexFile)
  330. if thenewmaterial == undefined do
  331. (
  332. ---Material
  333. -- thenewmaterial = multimaterial numsubs:1
  334. -- thenewsubmaterial = standardmaterial name:TexFile
  335. -- thenewsubmaterial.diffusemap = bitmaptexture name:TexFile
  336. -- thenewsubmaterial.diffusemap.filename = TexFileName
  337. -- thenewmaterial.materiallist[1] = thenewsubmaterial
  338. -- showtexturemap thenewsubmaterial thenewsubmaterial.diffusemap true
  339.  
  340. thenewmaterial = standardmaterial name:TexFile
  341. thenewmaterial.diffusemap = bitmaptexture name:TexFile
  342. thenewmaterial.diffusemap.filename = TexFileName
  343. -- thenewmaterial.bumpmap = bitmaptexture name:TexFile
  344. -- thenewmaterial.bumpmap.filename = TexFileName
  345. showtexturemap thenewmaterial thenewmaterial.diffusemap true
  346.  
  347. )
  348.  
  349.  
  350. msh = mesh vertices:Vert_array faces:Face_array
  351. setNumTVerts msh UV_array.count
  352.  
  353. for i = 1 to UV_array.count do (setTVert msh i UV_array[i])
  354. buildTVFaces msh false
  355. for i = 1 to Face_array.count do (setTVFace msh i Face_array[i])
  356. --for i = 1 to Normal_array.count do (setNormal msh j Normal_array[j])
  357.  
  358. --Aplly mesh rotation
  359. currentMatrix = msh.transform
  360. preRotate currentMatrix (eulertoquat (eulerAngles g_ninjarotX g_ninjarotY g_ninjarotZ))
  361. msh.transform = currentMatrix
  362. resetxform msh
  363. maxOps.CollapseNode msh off
  364.  
  365. msh.name = getFilenameFile RipFilePath
  366. msh.material = thenewmaterial
  367.  
  368. fclose f
  369. --Redraw screen
  370. completeredraw()
  371. gw.updateScreen()
  372. )
  373.  
  374.  
  375. rollout nr_rollout "Ninja Ripper Importer v1.3 beta7.1" width:300 height:430
  376. (
  377. -- Source select
  378. groupBox grp1 "Source Select" pos:[5,5] width:289 height:113
  379. radioButtons RadioImport "" pos:[58,27] width:201 height:16 labels:#("Group", "Single", "List File") default:2 columns:3
  380.  
  381. label lblInputFile "Input .rip File:" pos:[12,58] width:68 height:17 visible:true
  382. label lblInputDir "Input Dir:" pos:[12,58] width:68 height:17 visible:false
  383. label lblInputLst "Input .lst File:" pos:[12,58] width:68 height:17 visible:false
  384. editText InputSrc "" pos:[84,55] width:169 height:20
  385. button SelectSrc "..." pos:[260,56] width:26 height:19 toolTip:""
  386.  
  387. label lbl10 "RIP File Nums" pos:[13,85] width:69 height:18 enabled:false
  388. editText RipList "" pos:[84,82] width:202 height:20 enabled:false
  389.  
  390. -- Vertex Format
  391. groupBox grp2 "Vertex Layout" pos:[5,125] width:175 height:168 columns:2
  392.  
  393. --imgTag theImgTag "Bitmap" pos:[5,150] width:168 height:20 bitmap:(bitmap 80 50 color:gray) align:#right
  394.  
  395. radioButtons RadioVertexFormat "" pos:[38,144] width:48 height:32 enabled:true labels:#("Auto", "Manual") default:1 columns:2
  396.  
  397. label lbl4 "Position" pos:[24,170] width:41 height:14 enabled:false
  398. spinner pos_x "x" pos:[21,195] width:38 height:20 type:#integer enabled:false
  399. spinner pos_y "y" pos:[21,225] width:38 height:20 type:#integer enabled:false
  400. spinner pos_z "z" pos:[21,256] width:38 height:20 type:#integer enabled:false
  401.  
  402. label lbl7 "Normal" pos:[78,170] width:37 height:14 enabled:false
  403. spinner norm_x "x" pos:[73,195] width:38 height:20 type:#integer enabled:false
  404. spinner norm_y "y" pos:[73,225] width:38 height:20 type:#integer enabled:false
  405. spinner norm_z "z" pos:[73,256] width:38 height:20 type:#integer enabled:false
  406.  
  407. label lbl5 "UV Coord" pos:[124,170] width:48 height:14 enabled:false
  408. spinner tc0_u "u" pos:[125,195] width:38 height:16 range:[0,500,0] type:#integer enabled:false
  409. spinner tc0_v "v" pos:[125,225] width:38 height:16 range:[0,500,0] type:#integer enabled:false
  410. --editText tc0_u "u" pos:[176,195] width:42 height:20
  411. --editText tc0_v "v" pos:[176,225] width:42 height:20
  412. --button plusUVone "+1" pos:[233,204] width:40 height:30 enabled:false
  413.  
  414. --Transform
  415. groupBox grp4 "Transformations" pos:[185,125] width:109 height:168
  416.  
  417. label lblscale "Scale" pos:[192,149] width:77 height:15 enabled:true
  418. edittext etscale "" pos:[221,149] width:65 height:16 enabled:true
  419.  
  420. label lblrotateX "Rotate X" pos:[192,180] width:77 height:15 enabled:true
  421. spinner spnrotateX "" pos:[241,180] width:45 height:16 range:[0,360,g_ninjarotX] type:#float scale:90 type:#integer enabled:true
  422.  
  423. label lblrotateY "Rotate Y" pos:[192,206] width:77 height:15 enabled:true
  424. spinner spnrotateY "" pos:[241,206] width:45 height:16 range:[0,360,g_ninjarotY] type:#float scale:90 type:#integer enabled:true
  425.  
  426. label lblrotateZ "Rotate Z" pos:[192,232] width:77 height:15 enabled:true
  427. spinner spnrotateZ "" pos:[241,232] width:45 height:16 range:[0,360,g_ninjarotZ] type:#float scale:90 type:#integer enabled:true
  428.  
  429. label uvscale "UV x" pos:[192,260] width:77 height:15 enabled:true
  430. edittext etuvscale "" pos:[221,260] width:65 height:16 enabled:true
  431.  
  432. label lbl6 "Tex.Num" pos:[15,309] width:70 height:15
  433. spinner spnTex0Lev "" pos:[65,309] width:45 height:16 range:[0,7,0] type:#integer
  434.  
  435. label lblflipuv "Flip UV Vertical" pos:[15,331] width:70 height:15
  436. checkbox checkerUV pos:[97,331] checked:false
  437.  
  438. -- Import button
  439. button BtnImport "IMPORT" pos:[185,301] width:109 height:52
  440.  
  441. --on spnscale changed val do g_ninjaScale = val
  442. on spnrotateX changed val do g_ninjarotX = val
  443. on spnrotateY changed val do g_ninjarotY = val
  444. on spnrotateZ changed val do g_ninjarotZ = val
  445. on g_enabler changed val do g_enabler = val
  446.  
  447. --on nr_rollout open do etuvscale.text = "1"
  448. on etuvscale changed txt do
  449. (
  450. if not isNumSeqNR txt do
  451. (
  452. messagebox "You can write only numbers!"
  453. etuvscale.text = "1"
  454. )
  455. )
  456.  
  457. on etscale changed txt do
  458. (
  459. if not isNumSeqNR txt do
  460. (
  461. messagebox "You can write only numbers!"
  462. etscale.text = "1"
  463. )
  464. )
  465.  
  466. on etuvscale entered txt do
  467. uvscaler = etuvscale.text as float
  468.  
  469. on etscale entered txt do
  470. mdlscaler = etscale.text as float
  471.  
  472. on nr_rollout open do (
  473.  
  474. ---Init values
  475. pos_x.value = 0
  476. pos_y.value = 1
  477. pos_z.value = 2
  478.  
  479. norm_x.value = 3
  480. norm_y.value = 4
  481. norm_z.value = 5
  482.  
  483. tc0_u.value = 6
  484. tc0_v.value = 7
  485.  
  486. etuvscale.text = "1"
  487. etscale.text = "100"
  488. )
  489.  
  490. -- on checkerUV changed UVstate do g_flipUV = -1
  491.  
  492. on checkerUV changed UVstate do (
  493. if checkerUV.checked == false do (
  494. g_flipUV = 1
  495. )
  496.  
  497. if checkerUV.checked == true then (
  498. g_flipUV = -1
  499. )
  500. )
  501.  
  502. on RadioVertexFormat changed state do
  503. (
  504. lbl4.enabled = not lbl4.enabled
  505. pos_x.enabled = not pos_x.enabled
  506. pos_y.enabled = not pos_y.enabled
  507. pos_z.enabled = not pos_z.enabled
  508.  
  509. lbl5.enabled = not lbl5.enabled
  510. tc0_u.enabled = not tc0_u.enabled
  511. tc0_v.enabled = not tc0_v.enabled
  512. )
  513.  
  514. on RadioImport changed state do
  515. (
  516. if RadioImport.state == 1 then (
  517. lbl10.enabled = true
  518. RipList.enabled = true
  519. lblInputFile.visible = false
  520. lblInputDir.visible = true
  521. lblInputLst.visible = false
  522. )
  523. else if RadioImport.state == 2 then (
  524. lbl10.enabled = false
  525. RipList.enabled = false
  526. lblInputFile.visible = true
  527. lblInputDir.visible = false
  528. lblInputLst.visible = false
  529. )
  530. else if RadioImport.state == 3 then (
  531. lbl10.enabled = false
  532. RipList.enabled = false
  533. lblInputFile.visible = false
  534. lblInputDir.visible = false
  535. lblInputLst.visible = true
  536. )
  537. )
  538.  
  539. on SelectSrc pressed do (
  540. if RadioImport.state == 1 then ( ---Group
  541. g_InputSrc = getSavePath caption:"Choose directory with .rip files" initialDir:"$scripts"
  542. if g_InputSrc != undefined do (
  543. g_InputSrc = g_InputSrc + "\\"
  544. g_ImportType = 0
  545. InputSrc.text = g_InputSrc
  546. print ( "Dir selected: " + g_InputSrc )
  547. )
  548. )
  549. else if RadioImport.state == 2 then ( ---Single
  550. g_InputSrc = getOpenFileName \
  551. caption:"Ninja Ripper File Select" \
  552. types:"Ninja Ripper File(*.rip)|*.rip" \
  553. historyCategory:"Ninja Ripper"
  554. if g_InputSrc != undefined do (
  555. g_ImportType = 1
  556. InputSrc.text = g_InputSrc
  557. print ( "Single File selected: " + g_InputSrc )
  558. )
  559. )
  560. else if RadioImport.state == 3 then ( ---List file
  561. g_InputSrc = getOpenFileName \
  562. caption:"Ninja Ripper List File Select" \
  563. types:"Ninja Ripper List File(*.lst)|*.lst" \
  564. historyCategory:"Ninja Ripper"
  565. if g_InputSrc != undefined do(
  566. g_ImportType = 2
  567. InputSrc.text = g_InputSrc
  568. print ( "List File selected: " + g_InputSrc )
  569. )
  570. )
  571. )
  572.  
  573. --Import button
  574. on BtnImport pressed do (
  575.  
  576. if RadioVertexFormat.state == 1 then ( ---Auto
  577. print "***Auto***"
  578. g_VertexFormatRecog = 0
  579. ---Set default values
  580. g_PosX_Idx = 0
  581. g_PosY_Idx = 1
  582. g_PosZ_Idx = 2
  583.  
  584. g_ninjarotX = spnrotateX.value
  585. g_ninjarotY = spnrotateY.value
  586. g_ninjarotZ = spnrotateZ.value
  587. )
  588.  
  589. else ( ---Manual
  590. print "***Manual***"
  591. g_VertexFormatRecog = 1
  592.  
  593. ---Position
  594. g_PosX_Idx = ( pos_x.value as Integer )
  595. g_PosY_Idx = ( pos_y.value as Integer )
  596. g_PosZ_Idx = ( pos_z.value as Integer )
  597.  
  598. ---Normals
  599. g_NormX_Idx = ( norm_x.value as Integer )
  600. g_NormY_Idx = ( norm_y.value as Integer )
  601. g_NormZ_Idx = ( norm_z.value as Integer )
  602.  
  603. ---Tex coords
  604. g_Tc0_U_Idx = ( tc0_u.value as Integer )
  605. g_Tc0_V_Idx = ( tc0_v.value as Integer )
  606.  
  607. g_ninjarotX = spnrotateX.value
  608. g_ninjarotY = spnrotateY.value
  609. g_ninjarotZ = spnrotateZ.value
  610. )
  611.  
  612. g_Tex0_FileLev = spnTex0Lev.value as Integer
  613.  
  614.  
  615. ---Import part
  616. if g_ImportType == 1 then ( ---Single file import
  617. if g_InputSrc.count > 0 then ( ImportRip g_InputSrc )
  618. else ( print "Select RIP file" )
  619. )
  620. else if g_ImportType == 0 then ( ---Group import
  621.  
  622. if InputSrc.text.count > 0 then (
  623. if RipList.text.count > 0 then (
  624. RipDir = getFilenamePath InputSrc.text
  625. ---print ( "RipDir: " + RipDir as String )
  626.  
  627. tokens = filterString RipList.text ","
  628. FilteredTokens = #()
  629.  
  630. ---Remove token whitespaces
  631. for i = 1 to tokens.count do (
  632. ---print ( "Tokens: " + tokens[i] as String )
  633. local Str = StringClear tokens[i]
  634. append FilteredTokens ( Str as String )
  635. )
  636.  
  637. ---Import loop. Split tokens with "-"
  638. for i = 1 to FilteredTokens.count do (
  639. print ( "Filtered Tokens: " + FilteredTokens[i] as String )
  640. RangeTokens = filterString FilteredTokens[ i ] "-"
  641. if RangeTokens.count == 1 then ( --Single element
  642. RipDir1 = RipDir
  643. ss = CreateMeshName RangeTokens[ 1 ]
  644. RipDir1 = RipDir1 + ss;
  645. print ( "Single Import:" + RipDir1 as String )
  646. ImportRip RipDir1
  647. )
  648. else( ---Range element
  649. r0 = RangeTokens[1] as Integer
  650. r1 = RangeTokens[2] as Integer
  651. if r0 < r1 then (
  652. for j = r0 to r1 do(
  653. RipDir1 = RipDir
  654. ss = CreateMeshName j
  655. RipDir1 = RipDir1 + ss;
  656. print ( "Group Import:" + RipDir1 as String )
  657. ImportRip RipDir1
  658. )
  659. )
  660. else (
  661. print( "Incorrect range: " + r0 as String + " to " + r1 as String )
  662. )
  663. )
  664. )
  665.  
  666. )
  667. else(
  668. print "Type file list"
  669. )
  670. )
  671. else (
  672. print "Select dir"
  673. )
  674. )
  675. else(
  676. print "Import from list file not realized"
  677. )
  678. )
  679. )
  680.  
  681. createDialog nr_rollout 300 362 50 60
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement