Advertisement
sunnydavis

XnaLara Converter.ms

Jun 4th, 2012
1,576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 109.03 KB | None | 0 0
  1. -- XnaLara Converter.ms
  2. -- Maxscript for importing and exporting geometry between 3ds Max and XNALara.
  3. -- Addressed an issue under 3ds Max 2013 where skin weight bind to the wrong bones
  4. -- @original: http://pastebin.com/v89CDW1J
  5. -- @author mariokart64n
  6. -- @date June 4, 2013
  7. -- @see http://www.tombraiderforums.com/showthread.php?t=181251
  8. version=maxVersion();if version[1]>=8000 then
  9. (
  10. -- Check Version of 3DSMAX
  11. rollout appGUI "XNALara Converter" width:175 height:315
  12. (
  13. button btn1 "IMPORT" pos:[16,8] width:120 height:32
  14. groupBox grp1 "Import Options" pos:[8,111] width:160 height:86
  15. editText edt1 "Scale:" pos:[40,89] width:86 height:16 bold:true text:"1.0000"
  16. checkbox chk1 "Single mesh" pos:[24,129] width:128 height:17 checked:true
  17. checkbox chk2 "Hide Unused Bones" pos:[24,149] width:140 height:17 checked:true
  18. checkbox chk3 "Vertex Normals" pos:[24,169] width:128 height:17 enabled:false
  19. groupBox grp2 "Export Options" pos:[8,201] width:160 height:86
  20. checkbox chk4 "Selection Only" pos:[24,219] width:128 height:17
  21. checkbox chk5 "Reparent Bones" pos:[24,239] width:128 height:17
  22. checkbox chk6 "Optimized Output" pos:[24,259] width:128 height:17 checked:true
  23. button btn3 "About" pos:[123,291] width:42 height:18
  24. label lbl2 "v1.1b (08.02.11)" pos:[11,293] width:98 height:17
  25. button btn1b "+" pos:[140,12] width:24 height:24
  26. button btn2 "EXPORT" pos:[16,48] width:120 height:32
  27. button btn2b "+" pos:[140,52] width:24 height:24
  28. local fsource=""
  29. local ssource=""
  30. local boneWarning=""
  31. local rescale=1
  32. local boneLimit=58
  33. local metric_scale=39.3700787
  34. local imperial_scale=0.0254982
  35. local boneSize=0.03
  36. local guessBone=false
  37. local bsenable=true
  38. local matNames=true
  39. local impFixed=false
  40. local expFixed=false
  41. on edt1 entered txt do
  42. (
  43. if (txt as float)!=undefined then
  44. (
  45. if (txt as float)!=0 then(rescale=(txt as float))else(messagebox "Input Invalid\nNumber Must Be Larger Than 0")
  46. )
  47. else
  48. (
  49. if txt=="bones" then
  50. (
  51. rollout exoptions "Extra Options (Some May Not Work)"width:298 height:263
  52. (
  53. groupBox grp4_1 "Peanutbutter Jelly Time!" pos:[11,11] width:277 height:243
  54. editText edt4_1 "Bone Size" pos:[26,37] width:114 height:16 enabled:bsenable text:(boneSize as string) bold:true
  55. checkbox chk4_1 "Guess Size Instead" pos:[150,36] width:128 height:17 checked:guessBone
  56. checkbox chk4_2 "Rhand to LHand Coordinates" pos:[27,63] width:221 height:19 enabled:false checked:true
  57. checkbox chk4_3 "Flip Texture Coordinates" pos:[27,83] width:221 height:19 enabled:false checked:true
  58. checkbox chk4_4 "Disable Skin on Import" pos:[27,123] width:221 height:19
  59. checkbox chk4_5 "Disable Mesh on Import" pos:[27,143] width:221 height:19
  60. checkbox chk4_6 "Disable Bones on Import" pos:[27,163] width:221 height:19
  61. checkbox chk4_7 "Disable Mats on Import" pos:[27,183] width:221 height:19
  62. checkbox chk4_8 "Export With Material Names" pos:[27,103] width:221 height:19 enabled:true checked:true
  63. editText edt4_2 "in<->cm" pos:[36,210] width:103 height:16 text:(metric_scale as string) bold:true
  64. editText edt4_3 "cm<->in" pos:[153,210] width:103 height:16 text:(imperial_scale as string) bold:true
  65. editText edt4_4 "Bone Limit" pos:[36,230] width:103 height:16 text:(boneLimit as string) bold:true
  66. on edt4_2 entered txt4 do (if (txt4 as float)!=undefined do metric_scale=(txt4 as float))
  67. on edt4_3 entered txt4 do (if (txt4 as float)!=undefined do imperial_scale=(txt4 as float))
  68. on edt4_4 entered txt4 do (if (txt4 as float)!=undefined do boneLimit=(txt4 as float))
  69. on chk4_1 changed theState do
  70. (
  71. if theState==false do edt4_1.enabled=true; bsenable=true;guessBone=false
  72. if theState==true do(edt4_1.enabled=false; bsenable=false;guessBone=true; boneSize=0)
  73. )
  74. on edt4_1 entered txt4 do(if (txt4 as float)!=undefined do boneSize=(txt4 as float))
  75. )
  76. createDialog exoptions
  77. )
  78. else(messagebox "Input Invalid\nPlease Supply A Number")
  79. )
  80. )
  81. on chk4_8 changed theState do matNames=theState
  82. on btn1b pressed do
  83. (
  84. if fsource==undefined do fsource=""
  85. rollout impPath "Open from Fixed Path" width:303 height:69
  86. (
  87. editText edt1b_1 "Path: " pos:[9,8] width:282 height:16 text:fsource
  88. button btn1b_1 "Browse" pos:[225,29] width:63 height:21
  89. checkbox chk1b_1 "Use Fixed Path" pos:[48,27] width:126 height:20 checked:impFixed
  90. on chk1b_1 changed theState do impFixed=theState
  91. on edt1b_1 entered txt do fsource=txt
  92. on btn1b_1 pressed do
  93. (
  94. fsource = GetOpenFileName \
  95. caption:"Open XnaLara MESH Model File" \
  96. types: "Binary(*.mesh)|*.MESH|Text(*.ascii)|*.ASCII|"
  97. if fsource!=undefined do edt1b_1.text=fsource
  98. )
  99. )
  100. createDialog impPath
  101. )
  102. on btn2b pressed do
  103. (
  104. if ssource==undefined do ssource=""
  105. rollout expPath "Save to Fixed Path" width:303 height:69
  106. (
  107. editText edt2b_1 "Path: " pos:[9,8] width:282 height:16 text:ssource
  108. button btn2b_1 "Browse" pos:[225,29] width:63 height:21
  109. checkbox chk2b_1 "Use Fixed Path" pos:[48,27] width:126 height:20 checked:expFixed
  110. on chk2b_1 changed theState do expFixed=theState
  111. on edt2b_1 entered txt do ssource=txt
  112. on btn2b_1 pressed do
  113. (
  114. ssource = getSaveFileName \
  115. caption:"Save XnaLara ASCII Model File" \
  116. types: "Text(*.ascii)|*.ASCII|All files (*.*)|*.*|"
  117. if ssource!=undefined do edt2b_1.text=ssource
  118. )
  119. )
  120. createDialog expPath
  121. )
  122. on btn1 pressed do
  123. (
  124. if impFixed==false OR fsource==""do
  125. (
  126. fsource = GetOpenFileName \
  127. caption:"Open XnaLara MESH Model File" \
  128. types: "Binary(*.mesh)|*.MESH|Text(*.ascii)|*.ASCII|"
  129. )
  130. if fsource!=""AND fsource!=undefined then
  131. (
  132. if (doesFileExist fsource)==true then
  133. (
  134. fext= getFilenameType fsource
  135. fpath= getFilenamePath fsource
  136. fname= getFilenameFile fsource
  137. fsize= getFileSize fsource
  138. if fext==".mesh" do
  139. (
  140. f = fopen fsource "rb"
  141. st = timestamp() --get start time in milliseconds
  142. ts = timestamp()
  143. --===========================================================================
  144. undo off
  145. (
  146. fn ReadFixedString bstream fixedLen =
  147. (
  148. local str = ""
  149. for i = 1 to fixedLen do
  150. (
  151. str += bit.intAsChar (ReadByte bstream #unsigned)
  152. )
  153. str
  154. )
  155. --===========================================================================
  156. with redraw off
  157. (
  158. scaling=metric_scale*rescale -- converts inces to centimeters !! damn Imperial System, Metric FTW
  159. mshHde=chk2.checked
  160. mshSingle=chk1.checked
  161. normON=chk3.checked
  162. skinON=true
  163. meshON=true
  164. boneON=true
  165. matON=true
  166. struct vertex_data
  167. (
  168. position,normal,texture,texture2,texture3,channels,colour,boneids,weights
  169. )
  170. struct bone_data
  171. (
  172. bName,parent,child,posX,posY,posZ
  173. )
  174. BNArr = #()
  175. -- Bone Section
  176. -- ===========================================================================
  177. Print ("Section 01: Bones @ 0x"+((bit.intAsHex(ftell f))as string))
  178. boneCount=readlong f #unsigned
  179. boneBuffer = (bone_data bName:#() parent:#() child:#() posX:#() posY:#() posZ:#())
  180. for i = 1 to boneCount do
  181. (
  182. append boneBuffer.bName (ReadFixedString f (readbyte f #unsigned))
  183. append boneBuffer.parent (readshort f+1)
  184. append boneBuffer.child -1
  185. append boneBuffer.posX (readfloat f*scaling)
  186. append boneBuffer.posZ (readfloat f*scaling)
  187. append boneBuffer.posY (readfloat f*-scaling)
  188. )
  189. if boneON==true do
  190. (
  191. boneChildren = #()
  192. for i = 1 to boneCount do
  193. (
  194. local parentIndex=boneBuffer.parent[i]
  195. if parentIndex!=0 do
  196. (
  197. local bChildren = boneChildren[parentIndex]
  198. if bChildren==undefined do
  199. (
  200. bChildren=#()
  201. boneChildren[parentIndex]=bChildren
  202. )
  203. append bChildren i
  204. )
  205. )
  206. fn weightChild childIdx boneBuffer boneChildren func =
  207. (
  208. local cWeight = 0
  209. bName=skipToString (boneBuffer.bName[childIdx] as stringstream) "unused"
  210. if bName!=OK then
  211. (
  212. cWeight = cWeight+1
  213. )
  214. local bChildren = boneChildren[childIdx]
  215. if bChildren!=undefined do
  216. (
  217. for i=1 to bChildren.count do
  218. (
  219. cWeight = cWeight+(func bChildren[i] boneBuffer boneChildren func)
  220. )
  221. )
  222. return cWeight
  223. )
  224. for i = 1 to boneCount do
  225. (
  226. local bChildren = boneChildren[i]
  227. if bChildren!=undefined do
  228. (
  229. if bChildren.count==1 then
  230. (
  231. boneBuffer.child[i] = bChildren[1]
  232. )
  233. else
  234. (
  235. usedBoneCount=0
  236. usedBoneIndex=0
  237. for j=1 to bChildren.count do
  238. (
  239. childIndex=bChildren[j]
  240. bName=skipToString (boneBuffer.bName[childIndex] as stringstream) "unused"
  241. if bName!=OK do
  242. (
  243. usedBoneCount = usedBoneCount+1
  244. usedBoneIndex = childIndex
  245. )
  246. )
  247. if usedBoneCount==1 do
  248. (
  249. boneBuffer.child[i] = usedBoneIndex
  250. )
  251. if usedBoneCount==0 do
  252. (
  253. bestBoneIdx = 0
  254. bestBoneWeight = 0
  255. for j=1 to bChildren.count do
  256. (
  257. cWeight = weightChild bChildren[j] boneBuffer boneChildren weightChild
  258. if cWeight > bestBoneWeight do
  259. (
  260. bestBoneWeight = cWeight
  261. bestBoneIdx = bChildren[j]
  262. )
  263. )
  264. if bestBoneWeight > 0 do
  265. (
  266. boneBuffer.child[i] = bestBoneIdx
  267. )
  268. )
  269. )
  270. )
  271. )
  272. for i = 1 to boneCount do
  273. (
  274. startPos=[(boneBuffer.posX[i]),(boneBuffer.posY[i]),(boneBuffer.posZ[i])]
  275. endPos=startPos
  276. childIndex=boneBuffer.child[i]
  277. if childIndex>=1 then
  278. (
  279. endPos=[(boneBuffer.posX[childIndex]),(boneBuffer.posY[childIndex]),(boneBuffer.posZ[childIndex])]
  280. )
  281. else
  282. (
  283. if boneBuffer.parent[i]!=0 do
  284. (
  285. endPos=[(boneBuffer.posX[(boneBuffer.parent[i])]),(boneBuffer.posY[(boneBuffer.parent[i])]),(boneBuffer.posZ[(boneBuffer.parent[i])])]
  286. endPos=startPos+((startPos-endPos))
  287. )
  288. )
  289. bonSize=boneSize*scaling
  290. if bsenable==true or boneSize==0 or boneSize==undefined do
  291. (
  292. bonSize=(distance startPos endPos)*0.05
  293. )
  294. if bonSize==0 do bonSize=0.03
  295. newBone = bonesys.createbone startPos endPos [0,0,1]
  296. newBone.name = boneBuffer.bName[i]
  297. newBone.width = bonSize
  298. newBone.height = bonSize
  299. if boneBuffer.parent[i] !=0 do newBone.parent = BNArr[boneBuffer.parent[i]]
  300. append BNArr newBone
  301. if childIndex<=1 do newBone.length=0.06*scaling
  302. if mshHde==true do
  303. (
  304. bName=skipToString (boneBuffer.bName[i] as stringstream) "unused"
  305. if bName==OK do
  306. (
  307. hide newBone
  308. )
  309. )
  310. )
  311. )
  312. -- bone enable loop
  313. Print("Bone Collection: ("+(((timestamp())-ts)as string)+" Milli Seconds)");ts = timestamp()
  314. -- Mesh Section
  315. -- ===========================================================================
  316. Print ("Section 02: Meshes @ 0x"+((bit.intAsHex(ftell f))as string))
  317. meshCount=readlong f #unsigned
  318. mm = MultiMaterial()
  319. mm.numsubs=meshCount
  320. faceAdder=1
  321. -- meshCount=1
  322. texArray=#()
  323. faceArray=#()
  324. faceDimArray=#()
  325. boneArray=#()
  326. uvChnArray=#()
  327. vertBuffer = (vertex_data position:#() normal:#() channels:#() texture:#() texture2:#() texture3:#() colour:#() boneids:#() weights:#())
  328. for i = 1 to meshCount do
  329. (
  330. mat=mm.materialList[i]
  331. matSpec=30
  332. matBump1=1
  333. matBump2=1
  334. matType=undefined
  335. texOpacity=false
  336. texLight=false
  337. texBump=false
  338. texSpec=false
  339. texIllum=false
  340. texSpecMap=false
  341. texMask=false
  342. texDetail1=false
  343. texDetail2=false
  344. texReflect=false
  345. texStatic=false
  346. matSpec=30
  347. matBump1=4
  348. matBump2=4
  349. texArray=#()
  350. if mshSingle==false do
  351. (
  352. --reset arrays
  353. faceArray=#()
  354. boneArray=#()
  355. uvChnArray=#()
  356. vertBuffer = (vertex_data position:#() normal:#() channels:#() texture:#() texture2:#() texture3:#() colour:#() boneids:#() weights:#())
  357. )
  358. mshName=ReadFixedString f (readbyte f #unsigned)
  359. if (findString mshName "_")!=undefined do
  360. (
  361. genItmName=filterString mshName "_"
  362. matType=genItmName[1] as integer
  363. mshName=genItmName[2]
  364. if (genItmName.count)>=3 do
  365. (
  366. if (genItmName[3] as float)!=undefined then
  367. (
  368. matSpec=(genItmName[3] as float)*100
  369. matBump1=genItmName[4] as float
  370. matBump2=genItmName[5] as float
  371. )
  372. else
  373. (
  374. -- this can get fucked up if there are too many _ in the mesh name .. ohwell
  375. matSpec=10
  376. matBump1=1
  377. matBump2=1
  378. )
  379. -- append texProp [matSpec,matBump1,matBump1]
  380. for c = 6 to genItmName.count do
  381. (
  382. mshCamTar=genItmName[c]
  383. )
  384. )
  385. )
  386. -- Camera Is Ignored, who the fuck saves cam info on a char model.
  387. uvwCount=readlong f #unsigned
  388. texCount=readlong f #unsigned
  389. for x = 1 to texCount do
  390. (
  391. texName=ReadFixedString f (readbyte f #unsigned)
  392. uvLayer=(readlong f #unsigned)+1 -- which UV layer to use.
  393. if uvLayer>=2 do uvLayer+=1 --max compatiblity.. cannot use layer 2
  394. append uvChnArray uvLayer
  395. append texArray (fpath+(filenameFromPath texName))
  396. )
  397. if matON==true do
  398. (
  399. if matType==undefined then
  400. (
  401. -- Not GenericItem, Trying to Detect Material Type
  402. texOpacity=true
  403. texSpec=true
  404. for x = 1 to texArray.count do
  405. (
  406. if (skipToString (texArray[x] as stringstream) "_lightmap")==OK do(texLight=true)
  407. if (skipToString (texArray[x] as stringstream) "_bump")==OK do(texBump=true)
  408. if (skipToString (texArray[x] as stringstream) "_mask")==OK do(texMask=true)
  409. if (skipToString (texArray[x] as stringstream) "_bump1")==OK do(texDetail1=true)
  410. if (skipToString (texArray[x] as stringstream) "_bump2")==OK do(texDetail2=true)
  411. -- 7 Yes Yes Yes No No No 1 Diffuse
  412. -- 9 Yes Yes Yes No No No 2 Diffuse, Lightmap
  413. -- 6 Yes Yes Yes Yes No No 2 Diffuse, Bumpmap
  414. -- 8 Yes Yes Yes Yes No No 3 Diffuse, Lightmap, Bumpmap
  415. -- 20 Yes Yes Yes Yes Yes Yes 6 Diffuse, Lightmap, Bumpmap, Mask, Bump1, Bump2
  416. )
  417. if (skipToString (mshName as stringstream) "collar")==OK do
  418. (
  419. matSpec=10
  420. matBump1=12
  421. matBump2=12
  422. )
  423. if (skipToString (mshName as stringstream) "gear")==OK do
  424. (
  425. matSpec=10
  426. matBump1=12
  427. matBump2=12
  428. )
  429. if (skipToString (mshName as stringstream) "belt")==OK do
  430. (
  431. matSpec=10
  432. matBump1=10
  433. matBump2=20
  434. )
  435. if (skipToString (mshName as stringstream) "suit")==OK do
  436. (
  437. matSpec=30
  438. matBump1=24
  439. matBump2=48
  440. )
  441. )
  442. else
  443. (
  444. -- ================================================================
  445. -- Standard Materials (CANNOT DO TRANSPARANCY)
  446. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  447. if matType == 10 do
  448. (
  449. -- Diffuse Only, High Emssive. Good For Anime Models
  450. texIllum=true
  451. )
  452. if matType == 5 do
  453. (
  454. -- Diffuse Only. Good As A Quick Material
  455. )
  456. if matType == 3 do
  457. (
  458. -- Lightmap
  459. texLight=true
  460. )
  461. if matType == 4 do
  462. (
  463. -- NormalMap + Spec
  464. texSpec=true
  465. texBump=true
  466. )
  467. if matType == 2 do
  468. (
  469. -- NormalMap + Spec + LightMap
  470. texSpec=true
  471. texLight=true
  472. texBump=true
  473. )
  474. if matType == 24 do
  475. (
  476. -- NormalMap + SpecMap + LightMap
  477. texSpec=true
  478. texSpecMap=true
  479. texLight=true
  480. texBump=true
  481. )
  482. if matType == 26 do
  483. (
  484. -- NormalMap + EnvMap
  485. texSpec=true
  486. texReflect=true
  487. texLight=true
  488. texBump=true
  489. )
  490. if matType == 28 do
  491. (
  492. -- NormalMap + DetailMap + EnvMap
  493. texReflect=true
  494. texSpec=true
  495. texBump=true
  496. texMask=true
  497. texDetail1=true
  498. texDetail2=true
  499. )
  500. if matType == 1 do
  501. (
  502. -- NormalMap + DetailMap + Spec + LightMap
  503. texSpec=true
  504. texLight=true
  505. texBump=true
  506. texMask=true
  507. texDetail1=true
  508. texDetail2=true
  509. )
  510. if matType == 22 do
  511. (
  512. -- NormalMap + DetailMap + SpecMap + LightMap
  513. texSpec=true
  514. texSpecMap=true
  515. texLight=true
  516. texBump=true
  517. texMask=true
  518. texDetail1=true
  519. texDetail2=true
  520. )
  521. -- ================================================================
  522. -- Transparent Materials
  523. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  524. if matType == 21 do
  525. (
  526. -- Diffuse Only, High Emissive. Good For Anime Models
  527. texOpacity=true
  528. texIllum=true
  529. )
  530. if matType == 7 do
  531. (
  532. -- Diffuse Only. Good As A Quick Material
  533. texOpacity=true
  534. )
  535. if matType == 9 do
  536. (
  537. -- Lightmap
  538. texOpacity=true
  539. texLight=true
  540. )
  541. if matType == 6 do
  542. (
  543. -- NormalMap + Spec
  544. texOpacity=true
  545. texSpec=true
  546. texBump=true
  547. )
  548. if matType == 8 do
  549. (
  550. -- NormalMap + Spec + LightMap
  551. texOpacity=true
  552. texSpec=true
  553. texLight=true
  554. texBump=true
  555. )
  556. if matType == 25 do
  557. (
  558. -- NormalMap + SpecMap + LightMap
  559. texOpacity=true
  560. texSpec=true
  561. texSpecMap=true
  562. texLight=true
  563. texBump=true
  564. )
  565. if matType == 27 do
  566. (
  567. -- NormalMap + EnvMap
  568. texOpacity=true
  569. texSpec=true
  570. texReflect=true
  571. texBump=true
  572. )
  573. if matType == 29 do
  574. (
  575. -- NormalMap + DetailMap + EnvMap
  576. texOpacity=true
  577. texReflect=true
  578. texSpec=true
  579. texBump=true
  580. texMask=true
  581. texDetail1=true
  582. texDetail2=true
  583. )
  584. if matType == 20 do
  585. (
  586. -- NormalMap + DetailMap + Spec + LightMap
  587. texOpacity=true
  588. texSpec=true
  589. texLight=true
  590. texBump=true
  591. texMask=true
  592. texDetail1=true
  593. texDetail2=true
  594. )
  595. if matType == 23 do
  596. (
  597. -- NormalMap + DetailMap + SpecMap + LightMap
  598. texOpacity=true
  599. texSpec=true
  600. texSpecMap=true
  601. texLight=true
  602. texBump=true
  603. texMask=true
  604. texDetail1=true
  605. texDetail2=true
  606. )
  607. -- ================================================================
  608. -- Extra Materials (Redunant Materials Mirrored for Static Models?)
  609. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  610. if matType == 13 do
  611. (
  612. -- Diffuse Only, High Emissive (Good for SkyBoxes)
  613. texStatic=true
  614. texIllum=true
  615. )
  616. if matType == 14 do
  617. (
  618. -- NormalMap, High Emissive
  619. texStatic=true
  620. texIllum=true
  621. texSpec=true
  622. texBump=true
  623. )
  624. if matType == 16 do
  625. (
  626. -- Diffuse Only
  627. texStatic=true
  628. )
  629. if matType == 11 do
  630. (
  631. -- NormalMap
  632. texStatic=true
  633. texSpec=true
  634. texBump=true
  635. )
  636. if matType == 17 do
  637. (
  638. -- LightMap
  639. texStatic=true
  640. texLight=true
  641. )
  642. if matType == 18 do
  643. (
  644. -- Transparent, Diffuse Only
  645. texStatic=true
  646. texOpacity=true
  647. )
  648. if matType == 19 do
  649. (
  650. -- Transparent, LightMap
  651. texStatic=true
  652. texOpacity=true
  653. texLight=true
  654. )
  655. if matType == 12 do
  656. (
  657. -- Transparent, NormalMap
  658. texStatic=true
  659. texOpacity=true
  660. texSpec=true
  661. texBump=true
  662. )
  663. if matType == 15 do
  664. (
  665. -- Transparent, NormalMap + High Emissive (Good For SkyBoxes)
  666. texStatic=true
  667. texOpacity=true
  668. texIllum=true
  669. texSpec=true
  670. texBump=true
  671. )
  672. -- ================================================================
  673. )
  674. if texSpec==true then
  675. (
  676. if texOpacity==false then
  677. (
  678. mat.specularLevel = matSpec
  679. )
  680. else
  681. (
  682. if texSpecMap==false then
  683. (
  684. mat.specularLevelMapAmount = matSpec
  685. mat.specularLevelMap = Bitmaptexture fileName:texArray[1]
  686. -- mat.specularLevelMap.effectsChannel = uvChnArray[1]
  687. mat.specularLevelMap.coords.mapChannel = uvChnArray[1]
  688. -- mat.monoOutput = 1
  689. -- mat.alphaSource = 0
  690. -- mat.preMultAlpha = off
  691. )
  692. else
  693. (
  694. if texMask==false then
  695. (
  696. mat.specularLevelMap = Bitmaptexture fileName:texArray[4]
  697. -- mat.specularLevelMap.effectsChannel = uvChnArray[4]
  698. mat.specularLevelMap.coords.mapChannel = uvChnArray[4]
  699. )
  700. else
  701. (
  702. mat.specularLevelMap = Bitmaptexture fileName:texArray[7]
  703. -- mat.specularLevelMap.effectsChannel = uvChnArray[7]
  704. mat.specularLevelMap.coords.mapChannel = uvChnArray[7]
  705. )
  706. )
  707. )
  708. )
  709. else(mat.specularLevel = 0)
  710. if texIllum==true do
  711. (
  712. mat.selfIllumAmount = 100
  713. )
  714. mat.diffuseMap = Bitmaptexture fileName:texArray[1]
  715. -- mat.diffuseMap.effectsChannel = uvChnArray[1]
  716. mat.diffuseMap.coords.mapChannel = uvChnArray[1]
  717. mat.diffuseMap.monoOutput = 1
  718. mat.diffuseMap.alphaSource = 2
  719. mat.diffuseMap.preMultAlpha = on
  720. if texOpacity==true do
  721. (
  722. mat.opacityMap = Bitmaptexture fileName:texArray[1]
  723. -- mat.opacityMap.effectsChannel = uvChnArray[1]
  724. mat.opacityMap.coords.mapChannel = uvChnArray[1]
  725. mat.opacityMap.monoOutput = 1
  726. mat.opacityMap.alphaSource = 0
  727. mat.opacityMap.preMultAlpha = off
  728. )
  729. if texLight==true do
  730. (
  731. matMod=RGB_Multiply ()
  732. matMod.map1 = mat.diffuseMap
  733. -- matMod.map1.effectsChannel = texArray[1]
  734. matMod.map2 = Bitmaptexture fileName:texArray[2]
  735. -- matMod.map2.effectsChannel = texArray[2]
  736. matMod.map1.coords.mapChannel = uvChnArray[1]
  737. matMod.map2.coords.mapChannel = uvChnArray[2]
  738. matMod.map1Enabled = true
  739. matMod.map2Enabled = true
  740. matMod.alphaFrom = 0
  741. mat.diffuseMap = matMod
  742. )
  743. if texBump==true do
  744. (
  745. mat.bumpMapEnable = on
  746. mat.bumpMapAmount = 100
  747. matMod=Normal_Bump ()
  748. if texLight==false then
  749. (
  750. matMod.map1on = true
  751. matMod.normal_map = Bitmaptexture fileName:texArray[2]
  752. -- matMod.normal_map.effectsChannel = uvChnArray[2]
  753. matMod.normal_map.coords.mapChannel = uvChnArray[2]
  754. if texMask==true do
  755. (
  756. maskMod1 = Mask ()
  757. maskMod2 = Mask ()
  758. layerMod = CompositeTexturemap ()
  759. tintMod = RGB_Tint ()
  760. tintMod.red = color 255 255 255
  761. tintMod.green = color 0 0 0
  762. tintMod.blue = color 0 0 0
  763. tintMod.map1 = Bitmaptexture fileName:texArray[3]
  764. -- tintMod.map1.effectsChannel = uvChnArray[4]
  765. tintMod.map1.coords.mapChannel = uvChnArray[3]
  766. tintMod.map1Enabled = true
  767. maskMod1.mask = tintMod
  768. tintMod = RGB_Tint ()
  769. tintMod.red = color 0 0 0
  770. tintMod.green = color 255 255 255
  771. tintMod.blue = color 0 0 0
  772. tintMod.map1 = Bitmaptexture fileName:texArray[3]
  773. -- tintMod.map1.effectsChannel = uvChnArray[5]
  774. tintMod.map1.coords.mapChannel = uvChnArray[3]
  775. tintMod.map1Enabled = true
  776. maskMod2.mask = tintMod
  777. maskMod1.map = Bitmaptexture fileName:texArray[4]
  778. maskMod2.map = Bitmaptexture fileName:texArray[5]
  779. -- maskMod1.map.effectsChannel = uvChnArray[3]
  780. -- maskMod2.map.effectsChannel = uvChnArray[3]
  781. maskMod1.map.coords.mapChannel = uvChnArray[4]
  782. maskMod2.map.coords.mapChannel = uvChnArray[5]
  783. maskMod1.map.coords.u_tiling = matBump1
  784. maskMod1.map.coords.v_tiling = matBump1
  785. maskMod2.map.coords.u_tiling = matBump2
  786. maskMod2.map.coords.v_tiling = matBump2
  787. maskMod1.mapEnabled = true
  788. maskMod2.mapEnabled = true
  789. maskMod1.maskEnabled = true
  790. maskMod2.maskEnabled = true
  791. maskMod1.maskInverted = false
  792. maskMod2.maskInverted = false
  793. layerMod.mapList.count=2
  794. layerMod.mapEnabled[1] = on
  795. layerMod.mapEnabled[2] = on
  796. layerMod.mapList[1] = maskMod1
  797. layerMod.mapList[2] = maskMod2
  798. matMod.bump_map = layerMod
  799. matMod.map2on = true
  800. )
  801. )
  802. else
  803. (
  804. matMod.map1on = true
  805. matMod.normal_map = Bitmaptexture fileName:texArray[3]
  806. -- matMod.normal_map.effectsChannel = uvChnArray[3]
  807. matMod.normal_map.coords.mapChannel = uvChnArray[3]
  808. if texMask==true do
  809. (
  810. maskMod1 = Mask ()
  811. maskMod2 = Mask ()
  812. layerMod = CompositeTexturemap ()
  813. tintMod = RGB_Tint ()
  814. tintMod.red = color 255 255 255
  815. tintMod.green = color 0 0 0
  816. tintMod.blue = color 0 0 0
  817. tintMod.map1 = Bitmaptexture fileName:texArray[4]
  818. -- tintMod.map1.effectsChannel = uvChnArray[5]
  819. tintMod.map1.coords.mapChannel = uvChnArray[4]
  820. tintMod.map1Enabled = true
  821. maskMod1.mask = tintMod
  822. tintMod = RGB_Tint ()
  823. tintMod.red = color 0 0 0
  824. tintMod.green = color 255 255 255
  825. tintMod.blue = color 0 0 0
  826. tintMod.map1 = Bitmaptexture fileName:texArray[4]
  827. tintMod.map1.coords.mapChannel = uvChnArray[4]
  828. tintMod.map1Enabled = true
  829. maskMod2.mask = tintMod
  830. maskMod1.map = Bitmaptexture fileName:texArray[5]
  831. maskMod2.map = Bitmaptexture fileName:texArray[6]
  832. -- maskMod1.map.effectsChannel = uvChnArray[4]
  833. -- maskMod2.map.effectsChannel = uvChnArray[4]
  834. maskMod1.map.coords.mapChannel = uvChnArray[5]
  835. maskMod2.map.coords.mapChannel = uvChnArray[6]
  836. maskMod1.map.coords.u_tiling = matBump1
  837. maskMod1.map.coords.v_tiling = matBump1
  838. maskMod2.map.coords.u_tiling = matBump2
  839. maskMod2.map.coords.v_tiling = matBump2
  840. maskMod1.mapEnabled = true
  841. maskMod2.mapEnabled = true
  842. maskMod1.maskEnabled = true
  843. maskMod2.maskEnabled = true
  844. maskMod1.maskInverted = false
  845. maskMod2.maskInverted = false
  846. layerMod.mapList.count=2
  847. layerMod.mapEnabled[1] = on
  848. layerMod.mapEnabled[2] = on
  849. layerMod.mapList[1] = maskMod1
  850. layerMod.mapList[2] = maskMod2
  851. matMod.bump_map = layerMod
  852. matMod.map2on = true
  853. )
  854. )
  855. -- matMod.alphaSource = 2
  856. -- matMod.filtering = 2
  857. -- matMod.alphaSource = 2
  858. mat.bumpMap = matMod
  859. )
  860. if texReflect==true do
  861. (
  862. mat.reflectionMapEnable = on
  863. mat.reflectionMapAmount = 30
  864. if texMask==false then
  865. (
  866. mat.reflectionMap = Bitmaptexture fileName:texArray[3]
  867. -- matMod.map2.effectsChannel = texArray[3]
  868. matMod.map2.coords.mapChannel = uvChnArray[3]
  869. )
  870. else
  871. (
  872. mat.reflectionMap = Bitmaptexture fileName:texArray[6]
  873. -- matMod.map2.effectsChannel = texArray[6]
  874. matMod.map2.coords.mapChannel = uvChnArray[6]
  875. )
  876. )
  877. showTextureMap mat true
  878. )
  879. vertCount=readlong f #unsigned
  880. for x = 1 to vertCount do
  881. (
  882. vx=readfloat f*scaling
  883. vz=readfloat f*scaling
  884. vy=readfloat f*-scaling
  885. nx=readfloat f*scaling
  886. nz=readfloat f*scaling
  887. ny=readfloat f*-scaling
  888. cr=readbyte f #unsigned
  889. cg=readbyte f #unsigned
  890. cb=readbyte f #unsigned
  891. ca=readbyte f #unsigned/255
  892. for y = 1 to uvwCount do
  893. (
  894. if y==1 do append vertBuffer.texture [(readfloat f),(readfloat f*-1),0]
  895. if y==2 do append vertBuffer.texture2 [(readfloat f),(readfloat f*-1),0]
  896. if y==3 do append vertBuffer.texture3 [(readfloat f),(readfloat f*-1),0]
  897. )
  898. for y = 1 to uvwCount do
  899. (
  900. -- Skips Vertex Tangents, (3dsmax doesn't support tangents.)
  901. fseek f (4*4) #seek_cur
  902. )
  903. if boneCount!=0 do
  904. (
  905. b1 = readshort f #unsigned+1
  906. b2 = readshort f #unsigned+1
  907. b3 = readshort f #unsigned+1
  908. b4 = readshort f #unsigned+1
  909. w1 = readfloat f
  910. w2 = readfloat f
  911. w3 = readfloat f
  912. w4 = readfloat f
  913. if b1!=0 do
  914. (
  915. find=findItem boneArray b1
  916. if find==0 do( append boneArray b1)
  917. )
  918. if b2!=0 do
  919. (
  920. find=findItem boneArray b2
  921. if find==0 do( append boneArray b2)
  922. )
  923. if b3!=0 do
  924. (
  925. find=findItem boneArray b3
  926. if find==0 do( append boneArray b3)
  927. )
  928. if b4!=0 do
  929. (
  930. find=findItem boneArray b4
  931. if find==0 do( append boneArray b4)
  932. )
  933. append vertBuffer.boneids [b1,b2,b3,b4]
  934. append vertBuffer.weights [w1,w2,w3,w4]
  935. )
  936. append vertBuffer.position [vx,vy,vz]
  937. append vertBuffer.normal [nx,ny,nz]
  938. append vertBuffer.colour [cr,cg,cb,ca]
  939. )
  940. faceCount=readlong f #unsigned
  941. for x = 1 to faceCount do
  942. (
  943. fc = readlong f + faceAdder
  944. fb = readlong f + faceAdder
  945. fa = readlong f + faceAdder
  946. append faceArray[fa,fb,fc]
  947. )
  948. if meshON==true do
  949. (
  950. if mshSingle==false then
  951. (
  952. msh = mesh vertices:vertBuffer.position faces:faceArray
  953. msh.numTVerts = vertCount
  954. buildTVFaces msh
  955. msh.name = mshName
  956. msh.material=mat
  957. for j = 1 to vertCount do meshop.setVertColor msh 0 j (color vertBuffer.colour[j][1] vertBuffer.colour[j][2] vertBuffer.colour[j][3])
  958. for j = 1 to vertCount do meshop.setVertAlpha msh -2 j vertBuffer.colour[j][4]
  959. for j = 1 to vertCount do setTVert msh j vertBuffer.texture[j]
  960. -- for j = 1 to vertCount do setNormal msh j vertBuffer.normal[j] -- Normals Don't Stick, lost when modifers are added
  961. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  962. if uvwCount==2 do
  963. (
  964. meshop.setNumMaps msh 3 keep:true
  965. for j = 1 to vertCount do (meshOp.setMapVert msh 2 j vertBuffer.texture2[j])
  966. )
  967. if uvwCount==3 do
  968. (
  969. meshop.setNumMaps msh 4 keep:true
  970. for j = 1 to vertCount do (meshOp.setMapVert msh 3 j vertBuffer.texture3[j])
  971. )
  972. meshop.autoSmooth msh #{1..faceArray.count} 90.0
  973. max modify mode
  974. if skinON==true do
  975. (
  976. clearSelection()
  977. select msh
  978. skinMod = skin ()
  979. addModifier msh skinMod
  980. for i = 1 to boneArray.count do
  981. (
  982. if i != boneArray.count then
  983. (
  984. skinOps.addBone skinMod BNArr[(boneArray[i])] 0
  985. )
  986. else
  987. (
  988. skinOps.addBone skinMod BNArr[(boneArray[i])] 1
  989. )
  990. )
  991. -- In Max 2013 the bone IDs are scrambled, so we look them up
  992. -- by bone's name and stores them in a table.
  993. local boneIDMap = #()
  994. -- iterate all bones in the Max (could be more than in a mesh)
  995. local numSkinBones = skinOps.GetNumberBones skinMod
  996. for i = 1 to numSkinBones do
  997. (
  998. local boneName = skinOps.GetBoneName skinMod i 0
  999. -- compare with mesh bones by name
  1000. for j = 1 to boneArray.count do
  1001. (
  1002. if boneName == BNArr[(boneArray[j])].name then
  1003. (
  1004. boneIDMap[j] = i
  1005. j = boneArray.count + 1 -- break the loop (faster than 'exit')
  1006. )
  1007. )
  1008. )
  1009. modPanel.setCurrentObject skinMod
  1010. for i = 1 to vertCount do
  1011. (
  1012. bi = #()
  1013. wv = #()
  1014. for j = 1 to 4 do
  1015. (
  1016. boneid = vertBuffer.boneids[i][j]
  1017. weight = vertBuffer.weights[i][j]
  1018. if weight!=0 do
  1019. (
  1020. append bi boneIDMap[findItem boneArray boneid]
  1021. append wv weight
  1022. )
  1023. )
  1024. skinOps.ReplaceVertexWeights skinMod i bi wv
  1025. )
  1026. )
  1027. --enable skin loop
  1028. if normON==true do
  1029. (
  1030. clearSelection()
  1031. select msh
  1032. normMod = Edit_Normals()
  1033. addModifier msh normMod
  1034. normMod.displayLength = 1
  1035. -- subobjectLevel = 1
  1036. -- modPanel.setCurrentObject normMod
  1037. for n = 1 to (normMod.GetNumFaces node:msh) do
  1038. (
  1039. -- norm=normMod.GetNormal n node:msh
  1040. -- print norm
  1041. vertID=getFace msh n
  1042. normMod.displayLength = 0
  1043. subobjectLevel = 1
  1044. modPanel.setCurrentObject normMod
  1045. for c = 1 to 3 do
  1046. (
  1047. normID=normMod.GetNormalID n c node:msh
  1048. normMod.EditNormalsMod.SetSelection #{normID}
  1049. normMod.EditNormalsMod.SetNormal normID vertBuffer.normal[(vertID[c])] node:msh
  1050. normMod.SetNormal normID vertBuffer.normal[(vertID[c])] node:msh
  1051. normMod.EditNormalsMod.MakeExplicit ()
  1052. normMod.EditNormalsMod.SetSelection #{}
  1053. )
  1054. )
  1055. subobjectLevel = 0
  1056. -- update msh
  1057. modPanel.setCurrentObject normMod
  1058. )
  1059. -- enable normals loop
  1060. )
  1061. else
  1062. (
  1063. mat.name = mshName
  1064. faceAdder+=vertCount
  1065. append faceDimArray faceCount
  1066. )
  1067. )
  1068. --useless loop lol
  1069. )
  1070. -- ends mesh loop
  1071. if mshSingle==true do
  1072. (
  1073. vertCount=vertBuffer.position.count
  1074. msh = mesh vertices:vertBuffer.position faces:faceArray
  1075. msh.numTVerts = vertCount
  1076. buildTVFaces msh
  1077. msh.name = fname
  1078. msh.material=mm
  1079. faceAdder=0
  1080. for j = 1 to meshCount do (for x = 1 to faceDimArray[j] do(faceAdder+=1;setFaceMatID msh faceAdder j))
  1081. for j = 1 to vertCount do meshop.setVertColor msh 0 j (color vertBuffer.colour[j][1] vertBuffer.colour[j][2] vertBuffer.colour[j][3])
  1082. for j = 1 to vertCount do meshop.setVertAlpha msh -2 j vertBuffer.colour[j][4]
  1083. for j = 1 to vertCount do setTVert msh j vertBuffer.texture[j]
  1084. -- for j = 1 to vertCount do setNormal msh j vertBuffer.normal[j] -- Normals Don't Stick, lost when modifers are added
  1085. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  1086. if uvwCount==2 do
  1087. (
  1088. meshop.setNumMaps msh 3 keep:true
  1089. for j = 1 to vertCount do (meshOp.setMapVert msh 2 j vertBuffer.texture2[j])
  1090. )
  1091. if uvwCount==3 do
  1092. (
  1093. meshop.setNumMaps msh 4 keep:true
  1094. for j = 1 to vertCount do (meshOp.setMapVert msh 3 j vertBuffer.texture3[j])
  1095. )
  1096. meshop.autoSmooth msh #{1..faceArray.count} 90.0
  1097. max modify mode
  1098. if skinON==true do
  1099. (
  1100. clearSelection()
  1101. select msh
  1102. skinMod = skin ()
  1103. addModifier msh skinMod
  1104. for i = 1 to boneArray.count do
  1105. (
  1106. if i != boneArray.count then
  1107. (
  1108. skinOps.addBone skinMod BNArr[(boneArray[i])] 0
  1109. )
  1110. else
  1111. (
  1112. skinOps.addBone skinMod BNArr[(boneArray[i])] 1
  1113. )
  1114. )
  1115. -- In Max 2013 the bone IDs are scrambled, so we look them up
  1116. -- by bone's name and stores them in a table.
  1117. local boneIDMap = #()
  1118. -- iterate all bones in the Max (could be more than in a mesh)
  1119. local numSkinBones = skinOps.GetNumberBones skinMod
  1120. for i = 1 to numSkinBones do
  1121. (
  1122. local boneName = skinOps.GetBoneName skinMod i 0
  1123. -- compare with mesh bones by name
  1124. for j = 1 to boneArray.count do
  1125. (
  1126. if boneName == BNArr[(boneArray[j])].name then
  1127. (
  1128. boneIDMap[j] = i
  1129. j = boneArray.count + 1 -- break the loop (faster than 'exit')
  1130. )
  1131. )
  1132. )
  1133. modPanel.setCurrentObject skinMod
  1134. for i = 1 to vertCount do
  1135. (
  1136. bi = #()
  1137. wv = #()
  1138. for j = 1 to 4 do
  1139. (
  1140. boneid = vertBuffer.boneids[i][j]
  1141. weight = vertBuffer.weights[i][j]
  1142. if weight!=0 do
  1143. (
  1144. append bi boneIDMap[findItem boneArray boneid]
  1145. append wv weight
  1146. )
  1147. )
  1148. skinOps.ReplaceVertexWeights skinMod i bi wv
  1149. )
  1150. )
  1151. --enable skin loop
  1152. if normON==true do
  1153. (
  1154. clearSelection()
  1155. select msh
  1156. normMod = Edit_Normals()
  1157. addModifier msh normMod
  1158. normMod.displayLength = 1
  1159. -- subobjectLevel = 1
  1160. -- modPanel.setCurrentObject normMod
  1161. for n = 1 to (normMod.GetNumFaces node:msh) do
  1162. (
  1163. -- norm=normMod.GetNormal n node:msh
  1164. -- print norm
  1165. vertID=getFace msh n
  1166. normMod.displayLength = 0
  1167. subobjectLevel = 1
  1168. modPanel.setCurrentObject normMod
  1169. for c = 1 to 3 do
  1170. (
  1171. normID=normMod.GetNormalID n c node:msh
  1172. normMod.EditNormalsMod.SetSelection #{normID}
  1173. normMod.EditNormalsMod.SetNormal normID vertBuffer.normal[(vertID[c])] node:msh
  1174. normMod.SetNormal normID vertBuffer.normal[(vertID[c])] node:msh
  1175. normMod.EditNormalsMod.MakeExplicit ()
  1176. normMod.EditNormalsMod.SetSelection #{}
  1177. )
  1178. )
  1179. subobjectLevel = 0
  1180. -- update msh
  1181. modPanel.setCurrentObject normMod
  1182. )
  1183. -- enable normals loop
  1184. )
  1185. if fsize!=(ftell f) then
  1186. (
  1187. Print ("Done ! @ 0x"+((bit.intAsHex(ftell f))as string))
  1188. )
  1189. else(Print "END OF FILE REACHED")
  1190. gc()
  1191. fclose f
  1192. flushLog()
  1193. closeLog()
  1194. enableSceneRedraw()
  1195. )
  1196. )
  1197. )
  1198. -- Close mesh ext Loop
  1199. if fext==".ascii" do
  1200. (
  1201. f=MemStreamMgr.openFile fsource
  1202. fext= getFilenameType fsource
  1203. fpath= getFilenamePath fsource
  1204. fname= getFilenameFile fsource
  1205. st = timestamp() --get start time in milliseconds
  1206. ts = timestamp()
  1207. clearlistener()
  1208. openLog (fpath+fname+"_log.txt") mode:"w" outputOnly:true
  1209. print (localTime+"\n"+fname+fext)
  1210. --===========================================================================
  1211. undo off
  1212. (
  1213. --===========================================================================
  1214. with redraw off
  1215. (
  1216. struct bone_data
  1217. (
  1218. bName,parent,child,position
  1219. )
  1220. boneBuffer = (bone_data bName:#() parent:#() child:#() position:#())
  1221. boneCount=(readDelimitedString (f.readLine() as stringstream) " ") as integer
  1222. for i = 1 to boneCount do
  1223. (
  1224. boneName=f.readLine()
  1225. boneParent=f.readLine()
  1226. bonePosition=f.readLine()
  1227. -- bonePosition=bonePosition as stringstream
  1228. append boneBuffer.bName boneName
  1229. -- append boneBuffer.parent ((boneParent as integer)+1)
  1230. -- append boneBuffer.position [(readDelimitedString bonePosition " " as float), \
  1231. -- (readDelimitedString bonePosition " " as float),(readDelimitedString bonePosition "" as float)]
  1232. )
  1233. renderGroups=#()
  1234. renderSettings=#()
  1235. meshCount=(readDelimitedString (f.readLine() as stringstream) " ") as integer
  1236. Print ("\nBone Count: "+(boneCount as string)+"\nMesh Count: "+(meshCount as string)+"\n")
  1237. for i = 1 to meshCount do
  1238. (
  1239. meshName=f.readLine(); Print meshName
  1240. append renderGroups ((readDelimitedString (meshName as stringstream) "_") as integer)
  1241. append renderSettings ((readDelimitedString (meshName as stringstream) "_") as float)
  1242. append renderSettings ((readDelimitedString (meshName as stringstream) "_") as float)
  1243. uvwCount=(readDelimitedString (f.readLine() as stringstream) " ") as integer
  1244. texCount=(readDelimitedString (f.readLine() as stringstream) " ") as integer
  1245. print ((texCount as string)+" Textures, "+(uvwCount as string)+" UV Layers")
  1246. for x = 1 to texCount do
  1247. (
  1248. texName=f.readLine()
  1249. uvLayer=((readDelimitedString (f.readLine() as stringstream) " ") as integer)+1
  1250. print ((filenameFromPath texName)+" ["+(uvLayer as string)+"]")
  1251. )
  1252. print ""
  1253. vertCount=(readDelimitedString (f.readLine() as stringstream) " ") as integer
  1254. for x = 1 to vertCount do
  1255. (
  1256. meshPosition=f.readLine()
  1257. meshNormal=f.readLine()
  1258. meshColour=f.readLine()
  1259. for y = 1 to uvwCount do
  1260. (
  1261. meshUVW=f.readLine()
  1262. )
  1263. if boneCount!=0 do
  1264. (
  1265. boneIndices=f.readLine()
  1266. boneWeights=f.readLine()
  1267. -- b1 = (readDelimitedString boneIndices " " as integer)+1
  1268. -- b2 = (readDelimitedString boneIndices " " as integer)+1
  1269. -- b3 = (readDelimitedString boneIndices " " as integer)+1
  1270. -- b4 = (readDelimitedString boneIndices "" as integer)+1
  1271. -- w1 = (readDelimitedString boneWeights " " as float)
  1272. -- w2 = (readDelimitedString boneWeights " " as float)
  1273. -- w3 = (readDelimitedString boneWeights " " as float)
  1274. -- w4 = (readDelimitedString boneWeights "" as float)
  1275. -- if b1!=0 do
  1276. (
  1277. find=findItem boneArray b1
  1278. -- if find==0 do( append boneArray b1)
  1279. )
  1280. -- if b2!=0 do
  1281. (
  1282. find=findItem boneArray b2
  1283. -- if find==0 do( append boneArray b2)
  1284. )
  1285. -- if b3!=0 do
  1286. (
  1287. find=findItem boneArray b3
  1288. -- if find==0 do( append boneArray b3)
  1289. )
  1290. -- if b4!=0 do
  1291. (
  1292. find=findItem boneArray b4
  1293. -- if find==0 do( append boneArray b4)
  1294. )
  1295. -- append vertBuffer.boneids [b1,b2,b3,b4]
  1296. -- append vertBuffer.weights [w1,w2,w3,w4]
  1297. )
  1298. -- vx=(readDelimitedString meshPosition " " as float)
  1299. -- vz=(readDelimitedString meshPosition " " as float)
  1300. -- vy=(readDelimitedString meshPosition "" as float)
  1301. -- nx=(readDelimitedString meshNormal " " as float)
  1302. -- nz=(readDelimitedString meshNormal " " as float)
  1303. -- ny=(readDelimitedString meshNormal "" as float)
  1304. -- cr=(readDelimitedString meshPosition " " as integer)
  1305. -- cg=(readDelimitedString meshPosition " " as integer)
  1306. -- cb=(readDelimitedString meshPosition " " as integer)
  1307. -- ca=(readDelimitedString meshPosition "" as integer)/255
  1308. -- append vertBuffer.position [vx,vy,vz]
  1309. -- append vertBuffer.normal [nx,ny,nz]
  1310. -- append vertBuffer.colour [cr,cg,cb,ca]
  1311. )
  1312. faceCount=(readDelimitedString (f.readLine() as stringstream) " ") as integer
  1313. for x = 1 to faceCount do
  1314. (
  1315. faceIndices=f.readLine()
  1316. -- fc = (readDelimitedString faceIndices " " as integer)+1
  1317. -- fb = (readDelimitedString faceIndices " " as integer)+1
  1318. -- fa = (readDelimitedString faceIndices "" as integer)+1
  1319. -- append faceArray[fa,fb,fc]
  1320. )
  1321. -- INSERT MESH IMPORT OP HERE
  1322. )
  1323. -- Mesh Loop
  1324. print "Detected Render Groups"
  1325. print renderGroups
  1326. print ""
  1327. print ""
  1328. print "Skeleton\n"
  1329. print boneBuffer.bName
  1330. gc()
  1331. fclose f
  1332. flushLog()
  1333. closeLog()
  1334. MemStreamMgr.close f
  1335. enableSceneRedraw()
  1336. Print ("\nDone! ("+((((timestamp())-st)/60)as string)+" Seconds)") --print time to finish
  1337. )
  1338. )
  1339. )
  1340. -- Close ascii ext Loop
  1341. if fext!=".ascii" AND fext!=".mesh" do MessageBox "File Extension Error"
  1342. )
  1343. else(MessageBox "Error Opening File!")
  1344. )
  1345. else (Print "Aborted.")
  1346. )
  1347. -- Close Button for IMPORT
  1348. on btn2 pressed do
  1349. (
  1350. -- EXPORT
  1351. st = timestamp() --get start time in milliseconds
  1352. -- ssource= "C:\\Users\\ACER_PREDATOR\\Desktop\\test.obj"
  1353. -- ssource= "C:\\Program Files (x86)\\XNALara\\data\\Max_Export\\goldenaxe_bikini\\generic_item.mesh.ascii"
  1354. if expFixed==false OR ssource==""do
  1355. (
  1356. ssource = getSaveFileName \
  1357. caption:"Save XnaLara ASCII Model File" \
  1358. types: "Text File (*.ASCII)|*.ascii|All files (*.*)|*.*|"
  1359. )
  1360. -- ssource=((getFilenameFile ssource)+".mesh.ascii") -- checks the name
  1361. -- ssource = getSaveFileName \
  1362. -- caption:"WaveFront OBJ Exporter" \
  1363. -- types: "OBJ(*.obj)|*.OBJ|All files (*.*)|*.*|"
  1364. if ssource!=""AND ssource!=undefined then
  1365. (
  1366. out_file = createfile ssource
  1367. fpath=(getFilenamePath ssource)
  1368. if (doesFileExist ssource)==true then
  1369. (
  1370. -- mshScale=1
  1371. mshScale=imperial_scale/rescale -- converts centimeters to inches ? my unit system is in inches ? is detection needed?
  1372. mshFlipUV=false -- not setup/wont do anything
  1373. mshRightH=true -- not setup/wont do anything
  1374. mshBySelection=chk4.checked
  1375. mshOptimise=chk6.checked-- wtf its faster with this on?
  1376. mshAddRoot=chk5.checked -- reparents all bones to a single root bone
  1377. mshBoneLimit=false -- as for now, only warns you if you've gonve over the bone limit (59 bones MAX)
  1378. fn checkname str =
  1379. (
  1380. -- removes special characters from names
  1381. local str0=""
  1382. for i = 1 to str.count do
  1383. (
  1384. if str[i]!="_" and str[i]!="#" and str[i]!=" " and str[i]!="." and str[i]!="/" and str[i]!="_" and str[i]!="\"" and str[i]!="\\"
  1385. do str0+=str[i]
  1386. )
  1387. str0
  1388. )
  1389. fn renamedup aray idx =
  1390. (
  1391. -- renames duplicated names
  1392. local namCount=1
  1393. newname= aray[idx]+"("+(namCount as string)+")"
  1394. find=findItem aray newname
  1395. if find!=0 do
  1396. (
  1397. while(findItem aray newname)!=0 do
  1398. (
  1399. namCount+=1
  1400. newname=aray[idx]+"("+(namCount as string)+")"
  1401. )
  1402. )
  1403. newname
  1404. )
  1405. fn getMaterial msh matid =
  1406. (
  1407. -- tries to sort a material into a correct render group
  1408. local matArray=#()
  1409. matArray[14]=""
  1410. -- matArray[1]-> ESTIMATED RENDER GROUP
  1411. -- matArray[2] -> texDiffuse
  1412. -- matArray[3] -> texOpacity
  1413. -- matArray[4] -> texIllum
  1414. -- matArray[5] -> texSpecMap
  1415. -- matArray[6] -> texSpec
  1416. -- matArray[7] -> texLight
  1417. -- matArray[8] -> texBump
  1418. -- matArray[9] -> texDetail1
  1419. -- matArray[10] -> texDetail2
  1420. -- matArray[11]-> matBump1
  1421. -- matArray[12]-> matBump2
  1422. -- matArray[13]-> texMask
  1423. -- matArray[14]-> texReflect
  1424. -- $.material.originalMaterial.diffuseMap
  1425. local matslot=msh.material
  1426. if classOf matslot==standardmaterial do matslot=msh.material
  1427. if classOf matslot==Shell_Material do matslot=msh.material.originalMaterial
  1428. if classOf matslot==multimaterial do matslot=msh.material[matid]
  1429. if matslot!=undefined then
  1430. (
  1431. if classOf matslot.diffuseMap==Bitmaptexture do matArray[2]=filenameFromPath matslot.diffuseMap.filename
  1432. if classOf matslot.diffuseMap==RGB_Multiply do
  1433. (
  1434. matArray[2]=filenameFromPath matslot.diffuseMap.map1.filename
  1435. matArray[7]=filenameFromPath matslot.diffuseMap.map2.filename
  1436. )
  1437. if classOf matslot.ambientMap==Bitmaptexture do matArray[7]=filenameFromPath matslot.ambientMap.filename
  1438. if classOf matslot.opacityMap==Bitmaptexture or matslot.opacity!=100 do matArray[3]="true"
  1439. if classOf matslot.specularLevelMap==Bitmaptexture do matArray[5]=filenameFromPath matslot.specularLevelMap.filename
  1440. if matslot.selfIllumAmount!=0 do matArray[4]="true";matArray[6]=(matslot.specularLevel as string)
  1441. if classOf matslot.bumpMap==Bitmaptexture do matArray[8]=filenameFromPath matslot.bumpMap.filename
  1442. if classOf matslot.reflectionMap==Bitmaptexture do matArray[14]=filenameFromPath matslot.reflectionMap.filename
  1443. if classOf matslot.bumpMap==Normal_Bump do
  1444. (
  1445. if classOf matslot.bumpMap.normal_map==Bitmaptexture do matArray[8]=filenameFromPath matslot.bumpMap.normal_map.filename
  1446. if classOf matslot.bumpMap.bump_map==Bitmaptexture do
  1447. (
  1448. matArray[9]=filenameFromPath matslot.bumpMap.bump_map.filename
  1449. matArray[11]=(matslot.bumpMap.bump_map.coords.u_tiling) as string
  1450. matArray[10]="norm_null.tga";matArray[13]="mask_null.tga"
  1451. )
  1452. if classOf matslot.bumpMap.bump_map==CompositeTexturemap do
  1453. (
  1454. if classOf matslot.bumpMap.bump_map.mapList[2]==Mask \
  1455. AND classOf matslot.bumpMap.bump_map.mapList[3]==Mask do
  1456. (
  1457. if classOf matslot.bumpMap.bump_map.mapList[2].mask==Bitmaptexture \
  1458. OR classOf matslot.bumpMap.bump_map.mapList[2].mask==RGB_Tint then
  1459. (
  1460. if classOf matslot.bumpMap.bump_map.mapList[2].mask==Bitmaptexture do matArray[13]=matslot.bumpMap.bump_map.mapList[2].mask.filename
  1461. if classOf matslot.bumpMap.bump_map.mapList[2].mask==RGB_Tint do matArray[13]=matslot.bumpMap.bump_map.mapList[2].mask.map1.filename
  1462. if classOf matslot.bumpMap.bump_map.mapList[2].map==Bitmaptexture \
  1463. AND classOf matslot.bumpMap.bump_map.mapList[3].map==Bitmaptexture then
  1464. (
  1465. matArray[9]=matslot.bumpMap.bump_map.mapList[2].map.filename
  1466. matArray[10]=matslot.bumpMap.bump_map.mapList[3].map.filename
  1467. matArray[11]=(matslot.bumpMap.bump_map.mapList[2].map.u_tiling) as string
  1468. matArray[12]=(matslot.bumpMap.bump_map.mapList[3].map.u_tiling) as string
  1469. )
  1470. else(matArray[9]="norm_null.tga";matArray[10]="norm_null.tga";matArray[11]="1";matArray[12]="1")
  1471. )
  1472. )
  1473. )
  1474. )
  1475. )
  1476. else
  1477. (
  1478. messagebox "ERROR!!\nUnable To Read Material\n>>Only Standard and Multimaterials Are Supported<<"
  1479. if matslot!=undefined then (matArray[3]=matslot.diffuse as string;matArray[6]=matslot.specularLevel as string)else(matArray[3]="diff_null.tga")
  1480. )
  1481. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1482. -- RENDERING GROUP CHART, WRITTEN AND DESIGNED BY "XNAaraL" AS SPECIFIED FOR XNALARA VERSION 9.6
  1483. -- http://www.tombraiderforums.com/showpost.php?p=5254498&postcount=1735
  1484. -- Group | Shading | Alpha | Poseable | Specular higlight | Bump1 repeater | bump2 repeater | Textures | Texture types | Since | First model / mesh part | Downloadlink
  1485. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1486. -- 1 | Yes | No | Yes | Yes | Yes | Yes | 6 | Diffuse, Lightmap, Bumpmap, Mask, Bump1, Bump2 | 1.0 | LaraJungleShorts /tshirt | http://www.mediafire.com/?gc5cu5dtd2h 1_tshirt_0.1_24_48
  1487. -- 2 | Yes | No | Yes | Yes | No | No | 3 | Diffuse, Lightmap, Bumpmap | 1.0 | LaraJungleShorts /face | http://www.mediafire.com/?gc5cu5dtd2h 2_eyeducts_0.1_0_0_hand left_arm left wrist
  1488. -- 3 | Yes | No | Yes | No | No | No | 2 | Diffuse, Lightmap | 1.0 | LaraJungleShorts /backring | http://www.mediafire.com/?gc5cu5dtd2h 3_backring_0.1_0_0
  1489. -- 4 | Yes | No | Yes | Yes | No | No | 2 | Diffuse, Bumpmap | 1.0 | LaraJungleShorts /metal | http://www.mediafire.com/?gc5cu5dtd2h 4_metal_0.6_0_0
  1490. -- 5 | Yes | No | Yes | No | No | No | 1 | Diffuse | 1.0 | LaraJungleShorts /eyewhites | http://www.mediafire.com/?gc5cu5dtd2h 5_eyewhites_0.1_0_0_body upper_breast left_breast right
  1491. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1492. -- 6 | Yes | Yes | Yes | Yes | No | No | 2 | Diffuse, Bumpmap | 1.0 | LaraJungleShorts /hair2 | http://www.mediafire.com/?gc5cu5dtd2h 6_hair2_0.1_0_0
  1493. -- 7 | Yes | Yes | Yes | No | No | No | 1 | Diffuse | 1.0 | LaraJungleShorts /eyelashes | http://www.mediafire.com/?gc5cu5dtd2h 7_eyeshading_0.1_0_0_head_head jaw
  1494. -- 8 | Yes | Yes | Yes | Yes | No | No | 3 | Diffuse, Lightmap, Bumpmap | 1.8 | Natla / hair4 | http://www.mediafire.com/?4wmzyzxwj5y 8_hair4_0.1_0_0_wing right_wing right 7c
  1495. -- 9 | Yes | Yes | Yes | No | No | No | 2 | Diffuse, Lightmap | 1.8 | Natla / hair5 | http://www.mediafire.com/?4wmzyzxwj5y 9_hair5_0.1_0_0
  1496. -- 10 | No | No | Yes | No | No | No | 1 | Diffuse | 1.85 | Doppelganger /eyepupils | http://www.mediafire.com/?m0q9yctdris
  1497. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1498. -- 11 | Vertex | No | No | Yes | No | No | 2 | Diffuse, Bumpmap | 4.1 | CroftManorHall /Group1 | http://www.mediafire.com/?jlt33lalmjj
  1499. -- 12 | Vertex | Yes | No | Yes | No | No | 2 | Diffuse, Bumpmap | 4.1 | CroftManorHall /Group35 | http://www.mediafire.com/?jlt33lalmjj
  1500. -- 13 | No | No | No | No | No | No | 1 | Diffuse | 4.1 | CroftManorHall /Group91 | http://www.mediafire.com/?jlt33lalmjj
  1501. -- 14 | No | No | No | Yes | No | No | 2 | Diffuse, Bumpmap | 4.2 | CroftManorHallLQ /Group1 | http://www.mediafire.com/?zjeznnzcgaz
  1502. -- 15 | No | Yes | No | Yes | No | No | 2 | Diffuse, Bumpmap | 4.2 | CroftManorHallLQ /Group35 | http://www.mediafire.com/?zjeznnzcgaz
  1503. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1504. -- 16 | Yes | No | No | No | No | No | 1 | Diffuse | 4.7 | Yacht / part1 | http://www.mediafire.com/?mwakzzz1djy
  1505. -- 17 | Yes | No | No | No | No | No | 2 | Diffuse, Lightmap | 4.7 | Yacht / part5 | http://www.mediafire.com/?mwakzzz1djy
  1506. -- 18 | Yes | Yes | No | No | No | No | 1 | Diffuse | 4.7 | Yacht / part13 | http://www.mediafire.com/?mwakzzz1djy
  1507. -- 19 | Yes | Yes | No | No | No | No | 2 | Diffuse, Lightmap | 5.6 | ShipNatlaRoom /Mesh005 | http://www.mediafire.com/?ztjozjnninn
  1508. -- 20 | Yes | Yes | Yes | Yes | Yes | Yes | 6 | Diffuse, Lightmap, Bumpmap, Mask, Bump1, Bump2 | 7.8 | KnightThrall /Mesh001 | http://www.mediafire.com/?z4uwig2dzum
  1509. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1510. -- 21 | No | Yes | Yes | No | No | No | 1 | Diffuse | 9.1 | kerrigan /$AtlantiB$ |
  1511. -- 22 | Yes | No | Yes | Yes | Yes | Yes | 7 | Diffuse, Lightmap, Bumpmap, Mask, Bump1, Bump2, Specular | 9.3 | ICE-7E /suit | http://www.mediafire.com/?leipjbpmeyn2w2p
  1512. -- 23 | Yes | Yes | Yes | Yes | Yes | Yes | 7 | Diffuse, Lightmap, Bumpmap, Mask, Bump1, Bump2, Specular | 9.3 | ICE-7E /ice | http://www.mediafire.com/?leipjbpmeyn2w2p
  1513. -- 24 | Yes | No | Yes | Yes | No | No | 4 | Diffuse, Lightmap, Bumpmap, Specular | 9.42 |
  1514. -- 25 | Yes | Yes | Yes | Yes | No | No | 4 | Diffuse, Lightmap, Bumpmap, Specular | 9.42 |
  1515. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1516. -- 26 | YES/No | No | Yes | Yes intensity | No | No | 3 | Diffuse, Bumpmap, enviroment | 9.5 | MetallicExample /trousers1 | http://www.mediafire.com/?g8gah73w0mv45q7
  1517. -- 27 | YES/No | Yes | Yes | Yes intensity | No | No | 3 | Diffuse, Bumpmap, enviroment | 9.5.5 |
  1518. -- 28 | YES/No | No | Yes | Yes intensity | YES | YES | 6 | Diffuse, Bumpmap, Mask, Bump1, Bump2, enviroment | 9.6 |
  1519. -- 29 | YES/No | Yes | Yes | Yes intensity | YES | YES | 6 | Diffuse, Bumpmap, Mask, Bump1, Bump2, enviroment | 9.6 |
  1520. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1521. if matArray[3]!="diff_null.tga"do
  1522. (
  1523. if matArray[3]!="true"then
  1524. (
  1525. -- Opaque
  1526. if matArray[4]!="true"then
  1527. (
  1528. -- not illum
  1529. if matArray[13]==undefined then
  1530. (
  1531. -- no detail map / masks
  1532. -- 5 Diffuse Only.
  1533. if matArray[5]==undefined \ -- texSpecMap
  1534. and matArray[7]==undefined \ -- texLight
  1535. and matArray[8]==undefined \ -- texBump
  1536. and matArray[14]=="" do matArray[1]="5"
  1537. -- 3 Diffuse + Lightmap
  1538. if matArray[5]==undefined \ -- texSpecMap
  1539. and matArray[7]!=undefined \ -- texLight
  1540. and matArray[8]==undefined \ -- texBump
  1541. and matArray[14]=="" do matArray[1]="3"
  1542. -- 24 Diffuse + NormalMap + SpecMap + LightMap
  1543. if matArray[5]!=undefined \ -- texSpecMap
  1544. and matArray[7]!=undefined \ -- texLight
  1545. and matArray[8]!=undefined \ -- texBump
  1546. and matArray[14]=="" do matArray[1]="24"
  1547. -- 24 Diffuse + NormalMap + SpecMap + LightMap
  1548. if matArray[5]!=undefined \ -- texSpecMap
  1549. and matArray[7]==undefined \ -- texLight
  1550. and matArray[8]==undefined \ -- texBump
  1551. and matArray[14]=="" do
  1552. (
  1553. matArray[7]="dirt_null.tga"
  1554. matArray[8]="norm_null.tga"
  1555. matArray[1]="24"
  1556. )
  1557. -- 24 Diffuse + NormalMap + SpecMap + LightMap
  1558. if matArray[5]!=undefined \ -- texSpecMap
  1559. and matArray[7]==undefined \ -- texLight
  1560. and matArray[8]!=undefined \ -- texBump
  1561. and matArray[14]=="" do
  1562. (
  1563. matArray[7]="dirt_null.tga"
  1564. matArray[1]="24"
  1565. )
  1566. -- 26 Diffuse + NormalMap + EnvMap
  1567. if matArray[5]==undefined \ -- texSpecMap
  1568. and matArray[7]==undefined \ -- texLight
  1569. and matArray[8]!=undefined \ -- texBump
  1570. and matArray[14]!="" do matArray[1]="26"
  1571. -- 4 Diffuse + NormalMap + Spec
  1572. if matArray[5]==undefined \ -- texSpecMap
  1573. and matArray[7]==undefined \ -- texLight
  1574. and matArray[8]!=undefined \ -- texBump
  1575. and matArray[14]=="" do matArray[1]="4"
  1576. -- 2 Diffuse + NormalMap + Spec + LightMap
  1577. if matArray[5]==undefined \ -- texSpecMap
  1578. and matArray[7]!=undefined \ -- texLight
  1579. and matArray[8]!=undefined \ -- texBump
  1580. and matArray[14]=="" do matArray[1]="2"
  1581. )
  1582. else
  1583. (
  1584. -- detail maps / masks
  1585. -- 28 Diffuse + NormalMap + DetailMap + EnvMap
  1586. if matArray[5]==undefined \ -- texSpecMap
  1587. and matArray[7]==undefined \ -- texLight
  1588. and matArray[8]!=undefined \ -- texBump
  1589. and matArray[14]!="" do matArray[1]="28"
  1590. -- 1 Diffuse + NormalMap + DetailMap + Spec + LightMap
  1591. if matArray[5]==undefined \ -- texSpecMap
  1592. and matArray[7]!=undefined \ -- texLight
  1593. and matArray[8]!=undefined \ -- texBump
  1594. and matArray[14]!="" do matArray[1]="1"
  1595. -- 22 Diffuse + NormalMap + DetailMap + SpecMap + LightMap
  1596. if matArray[5]!=undefined \ -- texSpecMap
  1597. and matArray[7]!=undefined \ -- texLight
  1598. and matArray[8]!=undefined \ -- texBump
  1599. and matArray[14]=="" do matArray[1]="22"
  1600. )
  1601. )
  1602. else
  1603. (
  1604. -- 10 Diffuse Only, High Emssive.
  1605. if matArray[2]!=undefined \ -- texDiffuse
  1606. and matArray[5]==undefined \ -- texSpecMap
  1607. and matArray[7]==undefined \ -- texLight
  1608. and matArray[8]==undefined \ -- texBump
  1609. and matArray[9]==undefined \ -- texDetail1
  1610. and matArray[10]==undefined \ -- texDetail2
  1611. and matArray[11]==undefined \ -- matBump1
  1612. and matArray[12]==undefined \ -- matBump2
  1613. and matArray[13]==undefined \ -- texMask
  1614. and matArray[14]=="" do matArray[1]="10"
  1615. )
  1616. )
  1617. else
  1618. (
  1619. -- Opacity
  1620. if matArray[4]!="true"then
  1621. (
  1622. -- not illum
  1623. if matArray[13]==undefined then
  1624. (
  1625. -- no detail map / masks
  1626. -- 5 Diffuse Only.
  1627. if matArray[5]==undefined \ -- texSpecMap
  1628. and matArray[7]==undefined \ -- texLight
  1629. and matArray[8]==undefined \ -- texBump
  1630. and matArray[14]=="" do matArray[1]="7"
  1631. -- 3 Diffuse + Lightmap
  1632. if matArray[5]==undefined \ -- texSpecMap
  1633. and matArray[7]!=undefined \ -- texLight
  1634. and matArray[8]==undefined \ -- texBump
  1635. and matArray[14]=="" do matArray[1]="9"
  1636. -- 24 Diffuse + NormalMap + SpecMap + LightMap
  1637. if matArray[5]!=undefined \ -- texSpecMap
  1638. and matArray[7]!=undefined \ -- texLight
  1639. and matArray[8]!=undefined \ -- texBump
  1640. and matArray[14]=="" do matArray[1]="25"
  1641. -- 24 Diffuse + NormalMap + SpecMap + LightMap
  1642. if matArray[5]!=undefined \ -- texSpecMap
  1643. and matArray[7]==undefined \ -- texLight
  1644. and matArray[8]==undefined \ -- texBump
  1645. and matArray[14]=="" do
  1646. (
  1647. matArray[7]="dirt_null.tga"
  1648. matArray[8]="norm_null.tga"
  1649. matArray[1]="25"
  1650. )
  1651. -- 24 Diffuse + NormalMap + SpecMap + LightMap
  1652. if matArray[5]!=undefined \ -- texSpecMap
  1653. and matArray[7]==undefined \ -- texLight
  1654. and matArray[8]!=undefined \ -- texBump
  1655. and matArray[14]=="" do
  1656. (
  1657. matArray[7]="dirt_null.tga"
  1658. matArray[1]="25"
  1659. )
  1660. -- 26 Diffuse + NormalMap + EnvMap
  1661. if matArray[5]==undefined \ -- texSpecMap
  1662. and matArray[7]==undefined \ -- texLight
  1663. and matArray[8]!=undefined \ -- texBump
  1664. and matArray[14]!="" do matArray[1]="27"
  1665. -- 4 Diffuse + NormalMap + Spec
  1666. if matArray[5]==undefined \ -- texSpecMap
  1667. and matArray[7]==undefined \ -- texLight
  1668. and matArray[8]!=undefined \ -- texBump
  1669. and matArray[14]=="" do matArray[1]="6"
  1670. -- 2 Diffuse + NormalMap + Spec + LightMap
  1671. if matArray[5]==undefined \ -- texSpecMap
  1672. and matArray[7]!=undefined \ -- texLight
  1673. and matArray[8]!=undefined \ -- texBump
  1674. and matArray[14]=="" do matArray[1]="8"
  1675. )
  1676. else
  1677. (
  1678. -- detail maps / masks
  1679. -- 28 Diffuse + NormalMap + DetailMap + EnvMap
  1680. if matArray[5]==undefined \ -- texSpecMap
  1681. and matArray[7]==undefined \ -- texLight
  1682. and matArray[8]!=undefined \ -- texBump
  1683. and matArray[14]!="" do matArray[1]="29"
  1684. -- 1 Diffuse + NormalMap + DetailMap + Spec + LightMap
  1685. if matArray[5]==undefined \ -- texSpecMap
  1686. and matArray[7]!=undefined \ -- texLight
  1687. and matArray[8]!=undefined \ -- texBump
  1688. and matArray[14]!="" do matArray[1]="20"
  1689. -- 22 Diffuse + NormalMap + DetailMap + SpecMap + LightMap
  1690. if matArray[5]!=undefined \ -- texSpecMap
  1691. and matArray[7]!=undefined \ -- texLight
  1692. and matArray[8]!=undefined \ -- texBump
  1693. and matArray[14]=="" do matArray[1]="23"
  1694. )
  1695. )
  1696. else
  1697. (
  1698. -- 10 Diffuse Only, High Emssive.
  1699. if matArray[2]!=undefined \ -- texDiffuse
  1700. and matArray[5]==undefined \ -- texSpecMap
  1701. and matArray[7]==undefined \ -- texLight
  1702. and matArray[8]==undefined \ -- texBump
  1703. and matArray[9]==undefined \ -- texDetail1
  1704. and matArray[10]==undefined \ -- texDetail2
  1705. and matArray[11]==undefined \ -- matBump1
  1706. and matArray[12]==undefined \ -- matBump2
  1707. and matArray[13]==undefined \ -- texMask
  1708. and matArray[14]=="" do matArray[1]="21"
  1709. )
  1710. )
  1711. )
  1712. -- matArray[2] -> texDiffuse
  1713. -- matArray[3] -> texOpacity
  1714. -- matArray[4] -> texIllum
  1715. -- matArray[5] -> texSpecMap
  1716. -- matArray[6] -> texSpec
  1717. -- matArray[7] -> texLight
  1718. -- matArray[8] -> texBump
  1719. -- matArray[9] -> texDetail1
  1720. -- matArray[10] -> texDetail2
  1721. -- matArray[11]-> matBump1
  1722. -- matArray[12]-> matBump2
  1723. -- matArray[13]-> texMask
  1724. -- matArray[14]-> texReflect
  1725. -- matArray[15]-> ESTIMATED RENDER GROUP
  1726. if matArray[1]==undefined do
  1727. (
  1728. matArray[2]="diff_null.tga"
  1729. matArray[1]="5"
  1730. )
  1731. if matArray[2]==undefined do matArray[2]="diff_null.tga"
  1732. if matArray[6]==undefined do matArray[6]="100"
  1733. if (matArray[6] as float)<=0 do matArray[6]="10" -- texSpec
  1734. if matArray[3]==undefined do matArray[3]="" -- texOpacity
  1735. if matArray[4]==undefined do matArray[4]="" -- texIllum
  1736. if matArray[5]!=undefined do matArray[6]="100"
  1737. if matArray[5]==undefined do matArray[5]="" -- texSpecMap
  1738. if matArray[7]==undefined do matArray[7]="" -- texLight
  1739. if matArray[8]==undefined do matArray[8]="" -- texBump
  1740. if matArray[9]==undefined do matArray[9]="" -- texDetail1
  1741. if matArray[10]==undefined do matArray[10]="" -- texDetail2
  1742. if matArray[11]==undefined do matArray[11]="" -- matBump1
  1743. if matArray[12]==undefined do matArray[12]="" -- matBump2
  1744. if matArray[13]==undefined do matArray[13]="" -- texMask
  1745. if matArray[14]==undefined do matArray[14]="" -- texReflect
  1746. matArray
  1747. )
  1748. fn maketext s p =
  1749. (
  1750. -- makes a 8x8 tga any colour, usage: (maketext savefile pixelcolour)
  1751. if (doesFileExist s)==false do
  1752. (
  1753. createFile s
  1754. s = fopen s "ab"
  1755. a=19;b=1
  1756. nullTex=#
  1757. (
  1758. 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x20,0x00,0xFF,0xFF, \
  1759. 0xFF,0x8A,0xFF,0xFF,0xFF,0x44,0xFF,0xFF,0xFF,0x68,0xFF,0xFF,0xFF,0x89,0xFF,0xFF,0xFF,0x86,0xFF,0xFF, \
  1760. 0xFF,0xC5,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE5,0xFF,0xFF,0xFF,0xCC,0xFF,0xFF, \
  1761. 0xFF,0xDE,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFC,0xFF,0xFF,0xFF,0xF9,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF, \
  1762. 0xFF,0xFE,0xFF,0xFF,0xFF,0xEF,0xFF,0xFF,0xFF,0xE6,0xFF,0xFF,0xFF,0xED,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF, \
  1763. 0xFF,0xFE,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xF9,0xFF,0xFF, \
  1764. 0xFF,0xF6,0xFF,0xFF,0xFF,0xFA,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, \
  1765. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, \
  1766. 0xFF,0xFE,0xFF,0xFF,0xFF,0xBB,0xFF,0xFF,0xFF,0xA3,0xFF,0xFF,0xFF,0x8C,0xFF,0xFF,0xFF,0x93,0xFF,0xFF, \
  1767. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xAA,0xFF,0xFF, \
  1768. 0xFF,0x8E,0xFF,0xFF,0xFF,0x92,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, \
  1769. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, \
  1770. 0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, \
  1771. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF
  1772. )
  1773. -- A small 8x8 White TGA Texture
  1774. for i = 1 to (8*8) do
  1775. (
  1776. nullTex[a]=p.blue;b+=1
  1777. nullTex[(a+1)]=p.green;b+=1
  1778. nullTex[(a+2)]=p.red;b+=1
  1779. a+=4
  1780. )
  1781. -- replaces pixels
  1782. for x=1 to nullTex.count do writebyte s nullTex[x]
  1783. fclose s
  1784. )
  1785. )
  1786. undo off
  1787. (
  1788. with redraw off
  1789. (
  1790. classesArr = #(BoneGeometry,Biped_Object,Dummy,IK_Chain_Object,Point)
  1791. getBone=for o in objects where findItem classesArr (classof o) > 0 collect o
  1792. classesArr = #(Editable_Mesh,Editable_Poly,PolyMeshObject)
  1793. if mshBySelection==false then
  1794. (
  1795. getMesh=for o in objects where findItem classesArr (classof o) > 0 collect o
  1796. if getMesh.count==0 do messagebox "FAIL!!\nNothing Valid to Export"
  1797. )
  1798. else
  1799. (
  1800. getMesh=for o in selection where findItem classesArr (classof o) > 0 collect o
  1801. if getMesh.count==0 do messagebox "FAIL!!\nNothing In Selection Valid to Export"
  1802. )
  1803. if getMesh.count!=0 do
  1804. (
  1805. struct bone_data(name,position,parent,child)
  1806. boneBuffer = (bone_data name:#() position:#() parent:#() child:#())
  1807. staticMsh=#()
  1808. skin_bone_limit=#()
  1809. skin_bone_limit[getMesh.count]=false
  1810. faceCount=0
  1811. for i = 1 to getMesh.count do
  1812. (
  1813. skinPresent=false
  1814. PhyiqArray=""
  1815. faceCount+=getMesh[i].numfaces
  1816. for x = 1 to getMesh[i].modifiers.count do
  1817. (
  1818. skinMod=getMesh[i].modifiers[x]
  1819. if classOf skinMod==Skin do
  1820. (
  1821. skinPresent=true
  1822. if (skinOps.GetNumberBones skinMod)>=boneLimit do
  1823. (
  1824. skin_bone_limit[i]=true;boneWarning+=(getMesh[i].name+"\n")
  1825. )
  1826. )
  1827. if classOf skinMod==Physique do PhyiqArray+=(" - "+getMesh[i].name+"\n")
  1828. )
  1829. if skinPresent==false do append staticMsh getMesh[i]
  1830. if PhyiqArray!="" do MessageBox ("WARNING!! Physique Not Supported\n\nFollowing Objects Have Failed to Convert:\n"+PhyiqArray)
  1831. )
  1832. if (getBone.count+staticMsh.count)!=0 do
  1833. (
  1834. boneBuffer.name[(getBone.count+staticMsh.count)]=""
  1835. boneBuffer.position[(getBone.count+staticMsh.count)]=[0,0,0]
  1836. boneBuffer.parent[(getBone.count+staticMsh.count)]=0
  1837. boneBuffer.child[(getBone.count+staticMsh.count)]=0
  1838. for i = 1 to getBone.count do
  1839. (
  1840. obj=getBone[i]
  1841. p=findItem getBone obj.parent
  1842. c=findItem getBone obj.children[1]
  1843. -- if p==0 do p=-1
  1844. p-=1 -- convert to base 0
  1845. if c==undefined do c=0
  1846. boneBuffer.name[i]=obj.name
  1847. boneBuffer.position[i]=obj.transform[4]
  1848. boneBuffer.parent[i]=p
  1849. boneBuffer.child[i]=c
  1850. )
  1851. for i = (getBone.count+1) to (getBone.count+staticMsh.count) do
  1852. (
  1853. obj=staticMsh[(i-getBone.count)]
  1854. boneBuffer.name[i]=obj.name
  1855. boneBuffer.position[i]=obj.transform[4]
  1856. boneBuffer.parent[i]=-1
  1857. boneBuffer.child[i]=0
  1858. )
  1859. )
  1860. if mshAddRoot==true do
  1861. (
  1862. -- reorder crap
  1863. find=findItem boneBuffer.name "root ground"
  1864. if find==0 then
  1865. (
  1866. -- Need to add Ground Root
  1867. insertItem "root ground" boneBuffer.name 1
  1868. insertItem [0,0,0] boneBuffer.position 1
  1869. insertItem -2 boneBuffer.parent 1
  1870. insertItem 0 boneBuffer.child 1
  1871. for i = 1 to boneBuffer.name.count do
  1872. (
  1873. boneBuffer.parent[i]+=1
  1874. )
  1875. )
  1876. else
  1877. (
  1878. -- Reorder all bones to Ground Root (Not tested? dont know if this even works)
  1879. if find!=1 then
  1880. (
  1881. -- the Root needs to be moved back to top
  1882. -- NOT WRITTEN -> would mean unlinking the root? not safe?
  1883. )
  1884. else
  1885. (
  1886. -- reparent everything else to the top
  1887. for i = 1 to boneBuffer.name.count do
  1888. (
  1889. if boneBuffer.parent[i]==-1 AND i!=find do
  1890. (
  1891. boneBuffer.parent[i]=0
  1892. )
  1893. )
  1894. )
  1895. )
  1896. )
  1897. if getMesh.count!=0 do
  1898. (
  1899. struct mesh_data(faces,vertices)
  1900. struct mesh_data(name,matname,faces,vertices,matinfo)
  1901. struct vertex_data(position,normal,tangent,colour,texture1,texture2,texture3,boneids,weights)
  1902. struct material_data(diffmap,dirtmap,specmap,normmap,bumpmap1,bumpmap2,maskmap,envmap)
  1903. meshBuffer = (mesh_data faces:#() vertices:#())
  1904. matBuffer = (material_data diffmap:#() dirtmap:#() specmap:#() normmap:#() bumpmap1:#() bumpmap2:#() maskmap:#() envmap:#())
  1905. meshBuffer = (mesh_data name:#() matname:#() faces:#() vertices:#() matinfo:#())
  1906. vertBuffer = (vertex_data position:#() normal:#() tangent:#() colour:#() texture1:#() texture2:#() texture3:#() boneids:#() weights:#())
  1907. vertBuffer.position [(faceCount*3)] = [0,0,0]
  1908. vertBuffer.normal [(faceCount*3)] = [0,0,0]
  1909. vertBuffer.tangent [(faceCount*3)] = [0,0,0]
  1910. vertBuffer.colour [(faceCount*3)] = [0,0,0]
  1911. vertBuffer.texture1 [(faceCount*3)] = [0,0,0]
  1912. vertBuffer.texture2 [(faceCount*3)] = [0,0,0]
  1913. vertBuffer.texture3 [(faceCount*3)] = [0,0,0]
  1914. vertBuffer.boneids [(faceCount*3)] = [0,0,0,0]
  1915. vertBuffer.weights [(faceCount*3)] = [0,0,0,0]
  1916. faceBuffer=#()
  1917. faceBuffer[(faceCount*3)]=0
  1918. )
  1919. vertCount=0 -- Counts used to index through my arrays
  1920. faceCount=0
  1921. for m = 1 to getMesh.count do
  1922. (
  1923. --loop meshcount
  1924. tvCount=getNumTVerts getMesh[m]
  1925. select getMesh[m]
  1926. max modify mode
  1927. modMesh = Edit_Mesh () --mkes sure mesh is triMesh
  1928. uvwMesh = Unwrap_UVW () --makes sure mesh has UVs !! fuck causes bad uv's >_<
  1929. addModifier getMesh[m] modMesh
  1930. if tvCount==0 do addModifier getMesh[m] uvwMesh
  1931. mat=getMesh[m].material
  1932. tmesh = getMesh[m]
  1933. -- tmesh = snapshotAsMesh getMesh[m] -- no material access wtf
  1934. UVLayers=1 -- should return 2, the 2nd channel is reserved for vertex colours
  1935. UVIndex=0
  1936. if (numMapsUsed tmesh)>=3 do
  1937. (
  1938. ;UVLayers=0 -- do a double check for vaild UV Channels
  1939. for i = 1 to (numMapsUsed tmesh) do
  1940. (
  1941. -- loop through each uv channel
  1942. if meshop.getMapSupport tmesh i == true do UVLayers+=1
  1943. )
  1944. )
  1945. if uvLayers>=3 do messagebox ("ERROR!!\n"+tmesh.name+" uses more then 2 UV Layers\n Script was not setup for more then 2\n\n-Sorry will Add Support in the future")
  1946. vColors=getNumCPVVerts tmesh -- returns 0 if there are no colours stored
  1947. cvert=(color 255 255 255) --white
  1948. num_verts = tmesh.numverts
  1949. num_faces = tmesh.numfaces
  1950. weightBuffer=#();weightBuffer[tmesh.numverts]=0.0
  1951. boneIDBuffer=#();boneIDBuffer[tmesh.numverts]=0
  1952. skinPresent=false
  1953. skinMod=undefined
  1954. if tmesh.modifiers.count!=0 then
  1955. (
  1956. for i = 1 to tmesh.modifiers.count do
  1957. (
  1958. -- Get Skin Data
  1959. if classOf tmesh.modifiers[i]==Skin do
  1960. (
  1961. skinPresent=true
  1962. skinMod=tmesh.modifiers[i]
  1963. )
  1964. )
  1965. if skinPresent==true then
  1966. (
  1967. modPanel.setCurrentObject skinMod
  1968. skinOps.RemoveZeroWeights skinMod
  1969. for i = 1 to tmesh.numverts do
  1970. (
  1971. vertex_bone_count = skinOps.GetVertexWeightCount skinMod i -- #of weights per vert
  1972. if vertex_bone_count!=0 then
  1973. (
  1974. weightCollection=#();weightCollection[vertex_bone_count]=0.0
  1975. boneidCollection=#();boneidCollection[vertex_bone_count]=0
  1976. for x = 1 to vertex_bone_count do
  1977. (
  1978. bone_weight = skinops.getvertexweight skinMod i x
  1979. bone_index = findItem boneBuffer.name
  1980. (
  1981. skinOps.GetBoneName skinMod \
  1982. (skinOps.GetVertexWeightBoneID skinMod i x) 0
  1983. )
  1984. if bone_index==0 do bone_index=1
  1985. if x<=4 do
  1986. (
  1987. -- limits to four bones weights per vertex
  1988. weightCollection[x]=bone_weight
  1989. boneidCollection[x]=bone_index
  1990. )
  1991. )
  1992. )
  1993. else
  1994. (
  1995. --dead weight found, nothing fancy just append weight to bone1
  1996. weightCollection=#();weightCollection[1]=0.0
  1997. boneidCollection=#();boneidCollection[1]=0
  1998. bone_index = 1
  1999. weightCollection[1]=1.0
  2000. boneidCollection[1]=1
  2001. )
  2002. if vertex_bone_count<=4 then
  2003. (
  2004. for x = (vertex_bone_count+1) to 4 do
  2005. (
  2006. weightCollection[x]=0
  2007. boneidCollection[x]=0
  2008. )
  2009. )
  2010. else
  2011. (
  2012. w=weightCollection[1]+weightCollection[2]+weightCollection[3]+weightCollection[4]
  2013. d=1-w;weightCollection[1]=(weightCollection[1]+d)
  2014. )
  2015. b1=boneidCollection[1]-1 -- convert to base 0
  2016. b2=boneidCollection[2]-1
  2017. b3=boneidCollection[3]-1
  2018. b4=boneidCollection[4]-1
  2019. if b1<=0 do b1=0
  2020. if b2<=0 do b2=0
  2021. if b3<=0 do b3=0
  2022. if b4<=0 do b4=0
  2023. boneIDBuffer[i]=[b1,b2,b3,b4]
  2024. -- boneIDBuffer[i]=[(boneidCollection[1]),(boneidCollection[2]),(boneidCollection[3]),(boneidCollection[4])]
  2025. weightBuffer[i]=[(weightCollection[1]),(weightCollection[2]),(weightCollection[3]),(weightCollection[4])]
  2026. )
  2027. )
  2028. else
  2029. (
  2030. for x = 1 to tmesh.numverts do
  2031. (
  2032. -- static mesh, fix skin info
  2033. weightBuffer[x]=[1,0,0,0]
  2034. if tmesh.parent!=undefined
  2035. then boneid=findItem boneBuffer.name tmesh.parent.name -- weight to a possible parent
  2036. else boneid=findItem boneBuffer.name tmesh.name -- if no parent weight to scene root
  2037. boneid-=1 -- convert to base 0
  2038. if boneid<=0 do boneid=0 -- convert to base 0
  2039. boneIDBuffer[x]=[boneid,0,0,0]
  2040. )
  2041. )
  2042. )
  2043. else
  2044. (
  2045. for x = 1 to tmesh.numverts do
  2046. (
  2047. weightBuffer[x]=[1,0,0,0]
  2048. if tmesh.parent!=undefined
  2049. then boneid=findItem getBone tmesh.parent.name
  2050. else boneid=findItem getBone tmesh.name
  2051. boneid-=1 -- convert to base 0
  2052. if boneid<=0 do boneid=0 -- convert to base 0
  2053. boneIDBuffer[x]=[boneid,0,0,0]
  2054. )
  2055. )
  2056. modNorm = Edit_Normals ()
  2057. addModifier tmesh modNorm
  2058. vertCollection=#() -- arrays reset on each mesh / material ID
  2059. normCollection=#()
  2060. tvertCollection=#()
  2061. faceCollection=#()
  2062. boneCheck=#()
  2063. vertCollection[(num_faces*3)] = [0,0,0,0]
  2064. normCollection[(num_faces*3)] = [0,0,0]
  2065. tvertCollection[(num_faces*3)] = [0,0,0,0]
  2066. faceCollection[num_faces] = [0,0]
  2067. if classOf mat==Multimaterial then
  2068. (
  2069. -- If MultiMaterial, Sort Faces By IDs
  2070. for x = 1 to num_faces do
  2071. (
  2072. faceCollection[x]=[(getFaceMatId tmesh x),(tmesh.faces[x].index)]
  2073. )
  2074. fn sortFN v1 v2 =
  2075. (
  2076. local d=v1[1]-v2[1];
  2077. case of
  2078. (
  2079. (d < 0.): -1
  2080. (d > 0.): 1
  2081. default: 0
  2082. );
  2083. );
  2084. qsort faceCollection sortFN
  2085. )
  2086. else(for x = 1 to num_faces do (faceCollection[x]= [1,x]))
  2087. faceStart=faceCollection[1][1]
  2088. faceCounter=0
  2089. count=0 -- count for resetable arrays
  2090. boneLimitReached=false
  2091. for x = 1 to num_faces do
  2092. (
  2093. if boneLimitReached==true do
  2094. (
  2095. matcrap=getMaterial tmesh faceStart
  2096. append meshBuffer.matinfo [(matcrap[1] as integer),(matcrap[6] as float),(matcrap[11] as float),(matcrap[12] as float)]
  2097. append matBuffer.diffmap matcrap[2]
  2098. append matBuffer.dirtmap matcrap[7]
  2099. append matBuffer.specmap matcrap[5]
  2100. append matBuffer.normmap matcrap[8]
  2101. append matBuffer.bumpmap1 matcrap[9]
  2102. append matBuffer.bumpmap2 matcrap[10]
  2103. append matBuffer.maskmap matcrap[13]
  2104. append matBuffer.envmap matcrap[14]
  2105. if matNames==true then mshName=(checkname tmesh.name) else mshName=(checkname tmesh.name)
  2106. find=findItem meshBuffer.name mshName
  2107. if find!=0 do mshName=renamedup meshBuffer.name find
  2108. append meshBuffer.name mshName
  2109. append meshBuffer.matname mshName
  2110. vertCollection=#() -- reset arrays
  2111. normCollection=#()
  2112. tvertCollection=#()
  2113. boneCheck=#()
  2114. vertCollection[(num_faces*3)] = [0,0,0,0]
  2115. normCollection[(num_faces*3)] = [0,0,0]
  2116. tvertCollection[(num_faces*3)] = [0,0,0,0]
  2117. append meshBuffer.faces faceCounter -- save counts, and reset shit
  2118. append meshBuffer.vertices count
  2119. boneLimitReached=false
  2120. faceCounter=0
  2121. count=0
  2122. )
  2123. case of
  2124. (
  2125. (classOf mat==Multimaterial):
  2126. (
  2127. -- reading materials, also rests arrays on new matID
  2128. d=faceCollection[x][1]-faceStart -- Compares Current MatID vs the Last MatID
  2129. case of
  2130. (
  2131. (d != 0):
  2132. (
  2133. -- Means Unique ID, need to reset
  2134. matcrap=getMaterial tmesh faceStart
  2135. append meshBuffer.matinfo [(matcrap[1] as integer),(matcrap[6] as float),(matcrap[11] as float),(matcrap[12] as float)]
  2136. append matBuffer.diffmap matcrap[2]
  2137. append matBuffer.dirtmap matcrap[7]
  2138. append matBuffer.specmap matcrap[5]
  2139. append matBuffer.normmap matcrap[8]
  2140. append matBuffer.bumpmap1 matcrap[9]
  2141. append matBuffer.bumpmap2 matcrap[10]
  2142. append matBuffer.maskmap matcrap[13]
  2143. append matBuffer.envmap matcrap[14]
  2144. case of
  2145. (
  2146. (mat.material[(faceCollection[x][1])] != undefined):
  2147. (
  2148. if matNames==true then mshName=(checkname tmesh.material[faceStart].name) else mshName=(checkname tmesh.name)
  2149. find=findItem meshBuffer.name mshName
  2150. if find!=0 do mshName=renamedup meshBuffer.name find
  2151. append meshBuffer.name mshName
  2152. append meshBuffer.matname mshName
  2153. )
  2154. (mat.material[(faceCollection[x][1])] == undefined):
  2155. (
  2156. if matNames==true then mshName=("Mat_"+(x as string)+"_"+(faceCollection[x][1] as string)) else mshName=(checkname tmesh.name)
  2157. find=findItem meshBuffer.name mshName
  2158. if find!=0 do mshName=renamedup meshBuffer.name find
  2159. append meshBuffer.name mshName
  2160. append meshBuffer.matname mshName
  2161. )
  2162. )
  2163. -- suppose to ensure that the material name is correct, this is critical.. but not properly set yet. -FIX ME!!
  2164. vertCollection=#() -- reset arrays
  2165. normCollection=#()
  2166. tvertCollection=#()
  2167. boneCheck=#()
  2168. vertCollection[(num_faces*3)] = [0,0,0,0]
  2169. normCollection[(num_faces*3)] = [0,0,0]
  2170. tvertCollection[(num_faces*3)] = [0,0,0,0]
  2171. append meshBuffer.faces faceCounter -- save counts, and reset shit
  2172. append meshBuffer.vertices count
  2173. faceStart=faceCollection[x][1]
  2174. faceCounter=0
  2175. count=0
  2176. )
  2177. )
  2178. )
  2179. (classOf mat!=Multimaterial):
  2180. (
  2181. -- assume this is an invalid material, or some other special type of material
  2182. -- do something here? lol makeup fake mat info
  2183. -- FIX ME!!
  2184. )
  2185. )
  2186. findex=getFace tmesh faceCollection[x][2] -- gets face index of mesh
  2187. tindex=getTVFace tmesh faceCollection[x][2] -- gets face index of texture coordinates
  2188. if vColors!=0 do cindex=getVCFace tmesh faceCollection[x][2] -- gets face index of vertex colours
  2189. -- t2index=getTVFace tmesh faceCollection[x][2] -- gets face for second UV channel (Fixed Channel)
  2190. if mshOptimise==true then
  2191. (
  2192. for y = 1 to 3 do
  2193. (
  2194. vert=getVert tmesh findex[y]
  2195. tvert=getTVert tmesh tindex[y]
  2196. tvert2=getTVert tmesh tindex[y]
  2197. if vColors!=0 do cvert=getVertColor tmesh cindex[y]
  2198. norm=modNorm.GetNormal (modNorm.GetNormalID faceCollection[x][2] y)
  2199. vertCull=findItem vertCollection [vert.x,vert.y,vert.z,(findex[y])]
  2200. tvertCull=findItem tvertCollection [tvert.x,tvert.y,0,(tindex[y])]
  2201. normCull=findItem normCollection norm
  2202. if vertCull!=0 do (if normCollection[vertCull]!=norm do normCull=0)
  2203. if vertCull!=tvertCull OR vertCull==0 OR normCull==0 then
  2204. (
  2205. --not found
  2206. count+=1
  2207. faceCount+=1
  2208. vertCount+=1
  2209. vertCollection[count]=[vert.x,vert.y,vert.z,(findex[y])]
  2210. tvertCollection[count]=[tvert.x,tvert.y,0,(tindex[y])]
  2211. normCollection[count]=norm
  2212. vertBuffer.position[vertCount]=[vert.x,vert.y,vert.z,(findex[y])] -- Face ID is left, relates to the Skin Weight
  2213. vertBuffer.texture1[vertCount]=[tvert.x,tvert.y,0]
  2214. vertBuffer.colour[vertCount]=cvert
  2215. vertBuffer.normal[vertCount]=norm
  2216. vertBuffer.boneids[vertCount]=boneIDBuffer[(findex[y])]
  2217. vertBuffer.weights[vertCount]=weightBuffer[(findex[y])]
  2218. faceBuffer[faceCount]=count
  2219. if skin_bone_limit[m]==true do
  2220. (
  2221. -- if current object exceeds bone limit, start new mesh
  2222. boneids=boneIDBuffer[(findex[y])]
  2223. for b = 1 to 4 do(if (finditem boneCheck boneids[b])==0 do append boneCheck boneids[b])
  2224. if boneCheck.count>=boneLimit do(boneLimitReached=true)
  2225. )
  2226. -- note to self, need to copy any changes to this function to the unoptimized loop
  2227. )
  2228. else
  2229. (
  2230. faceCount+=1
  2231. faceBuffer[faceCount]=vertCull
  2232. )
  2233. )
  2234. )
  2235. else
  2236. (
  2237. for y = 1 to 3 do
  2238. (
  2239. vert=getVert tmesh findex[y]
  2240. tvert=getTVert tmesh tindex[y]
  2241. norm=modNorm.GetNormal (modNorm.GetNormalID faceCollection[x][2] y)
  2242. count+=1
  2243. faceCount+=1
  2244. vertCount+=1
  2245. vertBuffer.position[vertCount]=[vert.x,vert.y,vert.z,(findex[y])] -- Face ID is left, relates to the Skin Weight
  2246. vertBuffer.texture1[vertCount]=[tvert.x,tvert.y,0]
  2247. vertBuffer.normal[vertCount]=norm
  2248. vertBuffer.boneids[vertCount]=boneIDBuffer[(findex[y])]
  2249. vertBuffer.weights[vertCount]=weightBuffer[(findex[y])]
  2250. faceBuffer[faceCount]=count
  2251. )
  2252. )
  2253. faceCounter+=1
  2254. )
  2255. matcrap=getMaterial tmesh faceStart
  2256. append meshBuffer.matinfo [(matcrap[1] as integer),(matcrap[6] as float),(matcrap[11] as float),(matcrap[12] as float)]
  2257. append matBuffer.diffmap matcrap[2]
  2258. append matBuffer.dirtmap matcrap[7]
  2259. append matBuffer.specmap matcrap[5]
  2260. append matBuffer.normmap matcrap[8]
  2261. append matBuffer.bumpmap1 matcrap[9]
  2262. append matBuffer.bumpmap2 matcrap[10]
  2263. append matBuffer.maskmap matcrap[13]
  2264. append matBuffer.envmap matcrap[14]
  2265. append meshBuffer.vertices count --flush counts (this may be improper? replace with if statement if counts are borked)
  2266. append meshBuffer.faces faceCounter
  2267. if classOf mat==Multimaterial then
  2268. (
  2269. if matNames==true then mshName=(checkname tmesh.material[faceStart].name) else mshName=(checkname tmesh.name)
  2270. find=findItem meshBuffer.name mshName
  2271. if find!=0 do mshName=renamedup meshBuffer.name find
  2272. append meshBuffer.name mshName
  2273. append meshBuffer.matname mshName
  2274. )
  2275. else
  2276. (
  2277. if tmesh.material==undefined then
  2278. (
  2279. if matNames==true then mshName=(checkname tmesh.name) else mshName=tmesh.name
  2280. find=findItem meshBuffer.name mshName
  2281. if find!=0 do mshName=renamedup meshBuffer.name find
  2282. append meshBuffer.name mshName
  2283. append meshBuffer.matname mshName
  2284. )
  2285. else
  2286. (
  2287. if matNames==true then mshName=(checkname tmesh.material.name) else mshName=(checkname tmesh.name)
  2288. find=findItem meshBuffer.name mshName
  2289. if find!=0 do mshName=renamedup meshBuffer.name find
  2290. append meshBuffer.name mshName
  2291. append meshBuffer.matname mshName
  2292. )
  2293. )
  2294. deleteModifier tmesh modNorm
  2295. deleteModifier tmesh modMesh
  2296. if tvCount==0 do deleteModifier tmesh uvwMesh
  2297. )
  2298. print meshBuffer
  2299. if getMesh.count!=0 do
  2300. (
  2301. -- xnalara ASCII format
  2302. vertIndex=1
  2303. nextvert=0
  2304. faceIndex=1
  2305. nextface=0
  2306. faceCounter=0
  2307. format "% # bones\n" boneBuffer.name.count to:out_file
  2308. for f = 1 to boneBuffer.name.count do
  2309. (
  2310. format "%\n" boneBuffer.name[f] to:out_file
  2311. format "% # parent index\n" boneBuffer.parent[f] to:out_file
  2312. format "% % %\n" (boneBuffer.position[f][1]*mshScale) (boneBuffer.position[f][3]*mshScale) (boneBuffer.position[f][2]*-mshScale) to:out_file
  2313. )
  2314. format "% # meshes\n" meshBuffer.name.count to:out_file
  2315. for f = 1 to meshBuffer.name.count do
  2316. (
  2317. nextvert+=meshBuffer.vertices[f]
  2318. nextface+=meshBuffer.faces[f]
  2319. format "%_%_%_%_%\n" (meshBuffer.matinfo[f][1]as integer) meshBuffer.name[f] (meshBuffer.matinfo[f][2]/100) meshBuffer.matinfo[f][3] meshBuffer.matinfo[f][4] to:out_file -- THE NAME IS CRITICAL, CURENTLY NOT PROPERLY SETUP!!
  2320. format "% # uv layers\n" 1 to:out_file -- Multiple UV channels not setup yet
  2321. texCount=1
  2322. a=meshBuffer.matinfo[f][1] -- calculated render group
  2323. case of
  2324. (
  2325. (a == 1): texCount=6
  2326. (a == 2): texCount=3
  2327. (a == 3): texCount=2
  2328. (a == 4): texCount=2
  2329. (a == 5): texCount=1
  2330. (a == 6): texCount=2
  2331. (a == 7): texCount=1
  2332. (a == 8): texCount=3
  2333. (a == 9): texCount=2
  2334. (a == 10): texCount=1
  2335. (a == 11): texCount=2
  2336. (a == 12): texCount=2
  2337. (a == 13): texCount=1
  2338. (a == 14): texCount=2
  2339. (a == 15): texCount=2
  2340. (a == 16): texCount=1
  2341. (a == 17): texCount=2
  2342. (a == 18): texCount=1
  2343. (a == 19): texCount=2
  2344. (a == 20): texCount=6
  2345. (a == 21): texCount=1
  2346. (a == 22): texCount=7
  2347. (a == 23): texCount=7
  2348. (a == 24): texCount=4
  2349. (a == 25): texCount=4
  2350. (a == 26): texCount=3
  2351. (a == 27): texCount=3
  2352. (a == 28): texCount=6
  2353. (a == 29): texCount=6
  2354. default: texCount=1
  2355. )
  2356. format "% # textures\n" texCount to:out_file
  2357. case of
  2358. (
  2359. (texCount==1):
  2360. (
  2361. format "%\n% # uv layer index\n" matBuffer.diffmap[f] 0 to:out_file
  2362. )
  2363. (texCount==2):
  2364. (
  2365. format "%\n% # uv layer index\n" matBuffer.diffmap[f] 0 to:out_file
  2366. if matBuffer.dirtmap[f]!=""
  2367. then format "%\n"matBuffer.dirtmap[f] to:out_file
  2368. else format "%\n"matBuffer.normmap[f] to:out_file
  2369. format "% # uv layer index\n" 0 to:out_file -- layers not implemented yet
  2370. )
  2371. (texCount==3):
  2372. (
  2373. format "%\n% # uv layer index\n" matBuffer.diffmap[f] 0 to:out_file
  2374. if matBuffer.envmap[f]!=""
  2375. then format "%\n% # uv layer index\n"matBuffer.normmap[f] 0 matBuffer.envmap[f] to:out_file -- layers not implemented yet
  2376. else format "%\n% # uv layer index\n"matBuffer.dirtmap[f] matBuffer.normmap[f] to:out_file
  2377. )
  2378. (texCount==4):
  2379. (
  2380. format "%\n% # uv layer index\n" matBuffer.diffmap[f] 0 to:out_file
  2381. format "%\n% # uv layer index\n" matBuffer.dirtmap[f] 0 to:out_file
  2382. format "%\n% # uv layer index\n" matBuffer.normmap[f] 0 to:out_file
  2383. format "%\n% # uv layer index\n" matBuffer.specmap[f] 0 to:out_file
  2384. )
  2385. (texCount==6):
  2386. (
  2387. format "%\n% # uv layer index\n" matBuffer.diffmap[f] 0 to:out_file
  2388. if matBuffer.envmap[f]!=""
  2389. then format "%\n% # uv layer index\n%\n% # uv layer index\n%\n% # uv layer index\n%\n% # uv layer index\n%\n% # uv layer index\n"\
  2390. matBuffer.normmap[f] 0 matBuffer.maskmap[f] 0 matBuffer.bumpmap1[f] 0 matBuffer.bumpmap2[f] 0 matBuffer.envmap[f] 0 to:out_file -- layers not implemented yet
  2391. else format "%\n% # uv layer index\n%\n% # uv layer index\n%\n% # uv layer index\n%\n% # uv layer index\n%\n% # uv layer index\n"\
  2392. matBuffer.dirtmap[f] 0 matBuffer.normmap[f] 0 matBuffer.maskmap[f] 0 matBuffer.bumpmap1[f] 0 matBuffer.bumpmap2[f] 0 to:out_file -- layers not implemented yet
  2393. )
  2394. (texCount==7):
  2395. (
  2396. format "%\n% # uv layer index\n" matBuffer.diffmap[f] 0 to:out_file
  2397. format "%\n% # uv layer index\n" matBuffer.dirtmap[f] 0 to:out_file
  2398. format "%\n% # uv layer index\n" matBuffer.normmap[f] 0 to:out_file
  2399. format "%\n% # uv layer index\n" matBuffer.maskmap[f] 0 to:out_file
  2400. format "%\n% # uv layer index\n" matBuffer.bumpmap1[f] 0 to:out_file
  2401. format "%\n% # uv layer index\n" matBuffer.bumpmap2[f] 0 to:out_file
  2402. format "%\n% # uv layer index\n" matBuffer.specmap[f] 0 to:out_file
  2403. )
  2404. )
  2405. format "% # vertices\n" meshBuffer.vertices[f] to:out_file
  2406. for i = vertIndex to nextvert do
  2407. (
  2408. format "% % %\n" (vertBuffer.position[i][1]*mshScale) (vertBuffer.position[i][3]*mshScale) (vertBuffer.position[i][2]*-mshScale) to:out_file
  2409. norm=normalize [(vertBuffer.normal[i][1]*mshScale),(vertBuffer.normal[i][3]*mshScale),(vertBuffer.normal[i][2]*-mshScale)]
  2410. format "% % %\n" norm.x norm.y norm.z to:out_file
  2411. -- format "% % %\n" vertBuffer.normal[i][1] vertBuffer.normal[i][3] vertBuffer.normal[i][2] to:out_file
  2412. format "% % % %\n" (vertBuffer.colour[i].red as integer) (vertBuffer.colour[i].green as integer) (vertBuffer.colour[i].blue as integer) 0 to:out_file -- vertex colours not setup yet
  2413. for y = 1 to 1 do
  2414. (
  2415. -- needs UV layer count, net setup yet
  2416. if y==1 do format "% %\n" vertBuffer.texture1[i][1] (vertBuffer.texture1[i][2]*-1) to:out_file
  2417. if y==2 do format "% %\n" vertBuffer.texture2[i][1] (vertBuffer.texture2[i][2]*-1) to:out_file
  2418. if y==3 do format "% %\n" vertBuffer.texture3[i][1] (vertBuffer.texture3[i][2]*-1) to:out_file
  2419. )
  2420. -- -- Vertex Tangents would go here
  2421. format "% % % %\n" (vertBuffer.boneids[i][1]as integer) (vertBuffer.boneids[i][2]as integer) (vertBuffer.boneids[i][3]as integer) (vertBuffer.boneids[i][4]as integer) to:out_file
  2422. format "% % % %\n" vertBuffer.weights[i][1] vertBuffer.weights[i][2] \
  2423. vertBuffer.weights[i][3] vertBuffer.weights[i][4] to:out_file
  2424. )
  2425. format "% # faces\n" meshBuffer.faces[f] to:out_file
  2426. for i = faceIndex to nextface do
  2427. (
  2428. fa=faceBuffer[(faceCounter+1)]-1
  2429. fb=faceBuffer[(faceCounter+2)]-1
  2430. fc=faceBuffer[(faceCounter+3)]-1
  2431. format "% % %\n" fc fb fa to:out_file
  2432. faceCounter+=3
  2433. )
  2434. faceIndex+=meshBuffer.faces[f]
  2435. vertIndex+=meshBuffer.vertices[f]
  2436. )
  2437. -- mesh loop
  2438. for x = 1 to matBuffer.diffmap.count do
  2439. (
  2440. if matBuffer.diffmap[x]=="diff_null.tga" do maketext (fpath+"\\diff_null.tga") (color 115 115 115)
  2441. if matBuffer.dirtmap[x]=="dirt_null.tga" do maketext (fpath+"\\dirt_null.tga") (color 254 254 254)
  2442. if matBuffer.specmap[x]=="spec_null.tga" do maketext (fpath+"\\spec_null.tga") (color 50 50 50)
  2443. if matBuffer.normmap[x]=="norm_null.tga" do maketext (fpath+"\\norm_null.tga") (color 128 128 255)
  2444. if matBuffer.maskmap[x]=="mask_null.tga" do maketext (fpath+"\\mask_null.tga") (color 255 0 0)
  2445. if matBuffer.bumpmap1[x]=="bump1_null.tga" do maketext (fpath+"\\bump1_null.tga") (color 128 128 255)
  2446. if matBuffer.bumpmap2[x]=="bump2_null.tga" do maketext (fpath+"\\bump2_nul.tgal") (color 128 128 255)
  2447. )
  2448. )
  2449. -- vertIndex=1
  2450. -- nextvert=0
  2451. -- faceIndex=1
  2452. -- nextface=0
  2453. -- lastface=0
  2454. -- faceCounter=0
  2455. -- for f = 1 to meshBuffer.name.count do
  2456. (
  2457. --dumps output as a wavefront OBJ format
  2458. -- nextvert+=meshBuffer.vertices[f]
  2459. -- format "# % vertices\n" meshBuffer.vertices[f] to:out_file
  2460. -- for i = vertIndex to nextvert do
  2461. (
  2462. -- format "v % % %\n" (vertBuffer.position[i][1]*mshScale) (vertBuffer.position[i][3]*mshScale) (vertBuffer.position[i][2]*-mshScale) to:out_file
  2463. )
  2464. -- format "\n# % vertex normals\n" meshBuffer.vertices[f] to:out_file
  2465. -- for i = vertIndex to nextvert do
  2466. (
  2467. -- norm=normalize [(vertBuffer.normal[i][1]*mshScale),(vertBuffer.normal[i][3]*mshScale),(vertBuffer.normal[i][2]*-mshScale)]
  2468. -- format "vn % % %\n" norm.x norm.y norm.z to:out_file
  2469. -- -- format "vn % % %\n" (vertBuffer.normal[i][1]*mshScale) (vertBuffer.normal[i][3]*mshScale) (vertBuffer.normal[i][2]*-mshScale) to:out_file
  2470. --
  2471. )
  2472. -- format "\n# % texture coords\n" meshBuffer.vertices[f] to:out_file
  2473. -- for i = vertIndex to nextvert do
  2474. (
  2475. -- format "vt % % 0.0\n" vertBuffer.texture1[i][1] vertBuffer.texture1[i][2] to:out_file
  2476. )
  2477. -- vertIndex+=meshBuffer.vertices[f]
  2478. )
  2479. -- print ("My Face Array has "+(faceBuffer.count as string)+" Entries")
  2480. -- for f = 1 to meshBuffer.name.count do
  2481. (
  2482. -- format "\n# % faces\n" meshBuffer.faces[f] to:out_file
  2483. -- format "g %\n" meshBuffer.name[f] to:out_file
  2484. -- nextface+=meshBuffer.faces[f]
  2485. -- print ("Currently Reading Set "+(f as string)+" from index "+(faceIndex as string)+" to "+(nextface as string)+"\n")
  2486. -- for i = faceIndex to nextface do
  2487. (
  2488. -- fa=faceBuffer[(faceCounter+1)]+lastface
  2489. -- fb=faceBuffer[(faceCounter+2)]+lastface
  2490. -- fc=faceBuffer[(faceCounter+3)]+lastface
  2491. -- format "f %/%/% %/%/% %/%/%\n" fa fa fa fb fb fb fc fc fc to:out_file
  2492. -- faceCounter+=3
  2493. )
  2494. -- faceIndex+=meshBuffer.faces[f]
  2495. -- lastface+=meshBuffer.vertices[f]
  2496. --
  2497. )
  2498. close out_file
  2499. if doesFileExist (fpath+"\\MeshAsciiToBin.exe")==true do
  2500. (
  2501. DOSCommand ("MeshAsciiToBin.exe \""+ssource+"\"")
  2502. )
  2503. messagebox ("DONE!\nOperation Completed in: "+((((timestamp()-st)/1000)+10)as string)+" s")
  2504. if boneWarning!="" do messagebox ("Warning!\nThe Following Meshes Exceed The 59 Bone Limit\n\n"+boneWarning)
  2505. gc() -- this will erase and undo saves, helps? flush files
  2506. enableSceneRedraw()
  2507. )
  2508. )
  2509. )
  2510. -- undo renabled / redraw scene
  2511. )
  2512. else(MessageBox "Error Creating File!")
  2513. )
  2514. else (Print "Aborted.")
  2515. format "% ms\n" (timestamp()-st)
  2516. )
  2517. -- Close Button for EXPORT
  2518. on btn3 pressed do
  2519. (
  2520. rollout AboutBox "About..." width:300 height:200
  2521. (
  2522. label lbl3 "XNALara Converter (v1.1b) (August2011)" pos:[16,15] width:263 height:16
  2523. label lbl4 "__________________________________________________________________________" pos:[18,29] width:263 height:17
  2524. label lbl5 "- Mario_Kart64n (mario_kart64n@hotmail.com)" pos:[19,176] width:272 height:19
  2525. label lbl8 "__________________________________________________________________________" pos:[18,153] width:263 height:17
  2526. label lbl9 "Yay ^_^ second exporter I've written so far, and much an improvement\n\nScript is pretty much self-explainatory.. it imports XnaLara Stuff\nIf you have questions head over to the forums www.tombraiderforums.com\n" pos:[19,55] width:262 height:95
  2527. )
  2528. createDialog AboutBox
  2529. )
  2530. )
  2531. createDialog appGUI
  2532. gc() -- flushes cache, also resets undo. but command needed to help release files (not required to be on)
  2533. fclose f
  2534. fclose s
  2535. clearlistener()
  2536. )
  2537. else(MessageBox "ERROR!!\nYour 3DSMAX Is Not Compatible with this Script\n-Sorry")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement