Advertisement
Guest User

Untitled

a guest
Jan 10th, 2015
1,413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.97 KB | None | 0 0
  1. if (heapSize < 200000) then
  2. heapSize = 2000000 -- allow ~ 40 MB instead of just 7.5 MB. Prevents "Runtime Error: Out of scripter memory"
  3.  
  4. fname = getOpenFileName \
  5. caption:"Open .mod from Mesh folder" \
  6. types:"Monster Hunter 4 (*.mod)|*.mod" \
  7. historyCategory:"MH4ObjectPresets"
  8. f = fopen fname "rb"
  9.  
  10. clearlistener()
  11.  
  12. fn readHalfFloat fstream = (
  13. hf=readshort fstream #unsigned
  14. sign = bit.get hf 16
  15. exponent = (bit.shift (bit.and hf (bit.hexasint "7C00")) -10) as integer - 16
  16. fraction = bit.and hf (bit.hexasint "03FF")
  17. if sign==true then sign = 1 else sign = 0
  18. exponentF = exponent + 127
  19. outputAsFloat = bit.or (bit.or (bit.shift fraction 13) \
  20. (bit.shift exponentF 23)) (bit.shift sign 31)
  21. return bit.intasfloat outputasfloat*2
  22. )
  23.  
  24. fn readFixedString bstream fixedLen = (
  25. local str = ""
  26. for i = 1 to fixedLen do (
  27. str += bit.intAsChar (ReadByte bstream #unsigned))
  28. str
  29. )
  30.  
  31. fn hexAsSting hx = (
  32. num = (bit.intashex hx) as string
  33. str=""
  34. pos=num.count;for i = 1 to (num.count/2) do (
  35. str+=bit.intaschar (execute ("0x"+(num[(pos-1)]+num[(pos)])))
  36. pos-=2
  37. )
  38. str
  39. )
  40.  
  41. struct weight_data
  42. (
  43. boneids,weights
  44. )
  45. struct Mesh_Info_Struct
  46. (
  47. VertCount, VSize,VType, FacePos, FaceCount,VStart,MeshId
  48. )
  49. clearlistener()
  50.  
  51. fseek f 0x6 #seek_set
  52. BoneCount = ReadShort f
  53. meshcount = ReadShort f
  54. fseek f 0xc #seek_set
  55. VertexCount = ReadLong f
  56. fseek f 0x18 #seek_set
  57. VertSize = ReadLong f
  58. Long05 = ReadLong f
  59. Long06 = ReadLong f
  60. UsedBoneCount = ReadLong f
  61. BoneOff = ReadLong f
  62. Print ("Bone Offset @ 0x"+((bit.intAsHex(ftell f))as string))
  63. print (meshcount as string)
  64. matcount2 = ReadShort f
  65. fseek f 0x30 #seek_set
  66. MatOff = ReadLong f
  67. itemoff = ReadLong f
  68. print (itemoff as string)
  69. vertOffset = ReadLong f
  70. print (vertOffset as string)
  71. faceOffset = ReadLong f
  72. print (faceOffset as string)
  73. Print ("Item Offset @ 0x"+((bit.intAsHex(ftell f))as string))
  74.  
  75. fseek f BoneOff #seek_set
  76.  
  77. Print ("Bone Start @ 0x"+((bit.intAsHex(ftell f))as string))
  78.  
  79. BNArr = #()
  80. BoneParent = #()
  81. for a = 1 to BoneCount Do (
  82. boneid = readbyte f#unsigned
  83. append BoneParent (readbyte f#unsigned)
  84. childid = readbyte f#unsigned
  85. unkid = readbyte f#unsigned
  86. floata = ReadFloat f
  87. floatb = ReadFloat f
  88. bonex = ReadFloat f
  89. boney = ReadFloat f
  90. bonez = ReadFloat f
  91. )
  92.  
  93. Print ("Bone End @ 0x"+((bit.intAsHex(ftell f))as string))
  94.  
  95. for a = 1 to BoneCount do (
  96. getPos = ftell f + 64
  97. fseek f getPos #seek_set
  98. )
  99.  
  100. for a = 1 to BoneCount do (
  101.  
  102. c11 = ReadFloat f; c12 = ReadFloat f; c13 = ReadFloat f; c14 = ReadFloat f
  103. c21 = ReadFloat f; c22 = ReadFloat f; c23 = ReadFloat f; c24 = ReadFloat f
  104. c31 = ReadFloat f; c32 = ReadFloat f; c33 = ReadFloat f; c34 = ReadFloat f
  105. c41 = ReadFloat f; c42 = ReadFloat f; c43 = ReadFloat f; c44 = ReadFloat f
  106.  
  107. tfm = matrix3 [c11,c12,c13] [c21,c22,c23] [c31,c32,c33] ([c41,c42,c43]*100)
  108.  
  109. newBone = bonesys.createbone \
  110. tfm.row4 \
  111. (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  112. (normalize tfm.row3)
  113. newBone.name = (a as string)
  114. newBone.width = 0.01
  115. newBone.height = 0.01
  116. newBone.transform = inverse tfm
  117. newBone.setBoneEnable false 0
  118. newBone.wirecolor = white
  119. newbone.showlinks = true
  120. newBone.pos.controller = TCB_position ()
  121. newBone.rotation.controller = TCB_rotation ()
  122. if (BoneParent[a] != -1) then
  123. newBone.parent = BNArr[(BoneParent[a])+1]
  124. append BNArr newBone
  125. )
  126.  
  127. rootRT = dummy name:"Main_Root" boxsize:[.1,.1,.1]
  128. for b in BNArr where b.parent==undefined do b.parent = rootRT
  129. rootRT.transform = (matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0])
  130.  
  131. fseek f 0x100 #seek_cur
  132.  
  133. Print ("Bone Section End @ 0x"+((bit.intAsHex(ftell f))as string))
  134.  
  135. Pos=ftell f
  136.  
  137. BoneMapArray00=#()
  138. BoneMapArray01=#()
  139. BoneMapArray02=#()
  140. BoneMapArray03=#()
  141. BoneMapArray04=#()
  142. BoneMapArray05=#()
  143.  
  144. fseek f Pos #seek_set
  145. if UsedBoneCount==1 then
  146. (
  147. UBoneCount=1
  148. for i = 1 to UBoneCount do (
  149. BoneMapCount00=readlong f
  150. for i = 1 to BoneMapCount00 do (
  151. BMap00=(readbyte f#unsigned +1)
  152. append BoneMapArray00 BMap00
  153. )
  154. Stride00=(24-BoneMapCount00)
  155. fseek f Stride00 #seek_cur
  156. )
  157. )
  158. if UsedBoneCount==2 then
  159. (
  160. UBoneCount=1
  161. for i = 1 to UBoneCount do (
  162. BoneMapCount00=readlong f
  163. for i = 1 to BoneMapCount00 do (
  164. BMap00=(readbyte f#unsigned +1)
  165. append BoneMapArray00 BMap00
  166. )
  167. Stride00=(24-BoneMapCount00)
  168. fseek f Stride00 #seek_cur
  169. BoneMapCount01=readlong f
  170. for i = 1 to BoneMapCount01 do (
  171. BMap01=(readbyte f#unsigned +1)
  172. append BoneMapArray01 BMap01
  173. )
  174. Stride01=(24-BoneMapCount01)
  175. fseek f Stride01 #seek_cur
  176. )
  177. )
  178. if UsedBoneCount==3 then
  179. (
  180. UBoneCount=1
  181. for i = 1 to UBoneCount do (
  182. BoneMapCount00=readlong f
  183. for i = 1 to BoneMapCount00 do (
  184. BMap00=(readbyte f#unsigned +1)
  185. append BoneMapArray00 BMap00
  186. )
  187. Stride00=(24-BoneMapCount00)
  188. fseek f Stride00 #seek_cur
  189. BoneMapCount01=readlong f
  190. for i = 1 to BoneMapCount01 do (
  191. BMap01=(readbyte f#unsigned +1)
  192. append BoneMapArray01 BMap01
  193. )
  194. Stride01=(24-BoneMapCount01)
  195. fseek f Stride01 #seek_cur
  196. BoneMapCount02=readlong f
  197. for i = 1 to BoneMapCount02 do (
  198. BMap02=(readbyte f#unsigned +1)
  199. append BoneMapArray02 BMap02
  200. )
  201. Stride02=(24-BoneMapCount02)
  202. fseek f Stride02 #seek_cur
  203. )
  204. )
  205. if UsedBoneCount==4 then
  206. (
  207. UBoneCount=1
  208. for i = 1 to UBoneCount do (
  209. BoneMapCount00=readlong f
  210. for i = 1 to BoneMapCount00 do (
  211. BMap00=(readbyte f#unsigned +1)
  212. append BoneMapArray00 BMap00
  213. )
  214. Stride00=(24-BoneMapCount00)
  215. fseek f Stride00 #seek_cur
  216. BoneMapCount01=readlong f
  217. for i = 1 to BoneMapCount01 do (
  218. BMap01=(readbyte f#unsigned +1)
  219. append BoneMapArray01 BMap01
  220. )
  221. Stride01=(24-BoneMapCount01)
  222. fseek f Stride01 #seek_cur
  223. BoneMapCount02=readlong f
  224. for i = 1 to BoneMapCount02 do (
  225. BMap02=(readbyte f#unsigned +1)
  226. append BoneMapArray02 BMap02
  227. )
  228. Stride02=(24-BoneMapCount02)
  229. fseek f Stride02 #seek_cur
  230. BoneMapCount03=readlong f
  231. for i = 1 to BoneMapCount03 do (
  232. BMap03=(readbyte f#unsigned +1)
  233. append BoneMapArray03 BMap03
  234. )
  235. Stride03=(24-BoneMapCount03)
  236. fseek f Stride03 #seek_cur
  237. )
  238. )
  239. if UsedBoneCount==5 then
  240. (
  241. UBoneCount=1
  242. for i = 1 to UBoneCount do (
  243. BoneMapCount00=readlong f
  244. for i = 1 to BoneMapCount00 do (
  245. BMap00=(readbyte f#unsigned +1)
  246. append BoneMapArray00 BMap00
  247. )
  248. Stride00=(24-BoneMapCount00)
  249. fseek f Stride00 #seek_cur
  250. BoneMapCount01=readlong f
  251. for i = 1 to BoneMapCount01 do (
  252. BMap01=(readbyte f#unsigned +1)
  253. append BoneMapArray01 BMap01
  254. )
  255. Stride01=(24-BoneMapCount01)
  256. fseek f Stride01 #seek_cur
  257. BoneMapCount02=readlong f
  258. for i = 1 to BoneMapCount02 do (
  259. BMap02=(readbyte f#unsigned +1)
  260. append BoneMapArray02 BMap02
  261. )
  262. Stride02=(24-BoneMapCount02)
  263. fseek f Stride02 #seek_cur
  264. BoneMapCount03=readlong f
  265. for i = 1 to BoneMapCount03 do (
  266. BMap03=(readbyte f#unsigned +1)
  267. append BoneMapArray03 BMap03
  268. )
  269. Stride03=(24-BoneMapCount03)
  270. fseek f Stride03 #seek_cur
  271. BoneMapCount04=readlong f
  272. for i = 1 to BoneMapCount04 do (
  273. BMap04=(readbyte f#unsigned +1)
  274. append BoneMapArray04 BMap04
  275. )
  276. Stride04=(24-BoneMapCount04)
  277. fseek f Stride04 #seek_cur
  278. )
  279. )
  280. if UsedBoneCount==6 then
  281. (
  282. UBoneCount=1
  283. for i = 1 to UBoneCount do (
  284. BoneMapCount00=readlong f
  285. for i = 1 to BoneMapCount00 do (
  286. BMap00=(readbyte f#unsigned +1)
  287. append BoneMapArray00 BMap00
  288. )
  289. Stride00=(24-BoneMapCount00)
  290. fseek f Stride00 #seek_cur
  291. BoneMapCount01=readlong f
  292. for i = 1 to BoneMapCount01 do (
  293. BMap01=(readbyte f#unsigned +1)
  294. append BoneMapArray01 BMap01
  295. )
  296. Stride01=(24-BoneMapCount01)
  297. fseek f Stride01 #seek_cur
  298. BoneMapCount02=readlong f
  299. for i = 1 to BoneMapCount02 do (
  300. BMap02=(readbyte f#unsigned +1)
  301. append BoneMapArray02 BMap02
  302. )
  303. Stride02=(24-BoneMapCount02)
  304. fseek f Stride02 #seek_cur
  305. BoneMapCount03=readlong f
  306. for i = 1 to BoneMapCount03 do (
  307. BMap03=(readbyte f#unsigned +1)
  308. append BoneMapArray03 BMap03
  309. )
  310. Stride03=(24-BoneMapCount03)
  311. fseek f Stride03 #seek_cur
  312. BoneMapCount04=readlong f
  313. for i = 1 to BoneMapCount04 do (
  314. BMap04=(readbyte f#unsigned +1)
  315. append BoneMapArray04 BMap04
  316. )
  317. Stride04=(24-BoneMapCount04)
  318. fseek f Stride04 #seek_cur
  319. BoneMapCount05=readlong f
  320. for i = 1 to BoneMapCount05 do (
  321. BMap05=(readbyte f#unsigned +1)
  322. append BoneMapArray05 BMap05
  323. )
  324. Stride05=(24-BoneMapCount05)
  325. fseek f Stride05 #seek_cur
  326. )
  327. )
  328.  
  329. Print ("Bone Map End @ 0x"+((bit.intAsHex(ftell f))as string))
  330.  
  331. Mesh_Info=#()
  332.  
  333. fseek f itemoff #seek_set
  334.  
  335. Print ("Item Start @ 0x"+((bit.intAsHex(ftell f))as string))
  336.  
  337. for i = 1 to meshcount do (
  338. getPos = ftell f + 48
  339. unk1 = ReadShort f
  340. VertCount = ReadShort f
  341. unk2 = ReadLong f
  342. unk3 = ReadShort f
  343. VSize = readbyte f
  344. VType = readbyte f
  345. VStart=readlong f
  346. unk5 = ReadLong f
  347. unk6 = ReadLong f
  348. FacePos = ReadLong f
  349. FaceCount = Readlong f
  350. Null=ReadLong f
  351. NullB=readbyte f#unsigned
  352. MeshId=readbyte f#unsigned+1
  353. UBN=readbyte f#unsigned
  354. append Mesh_Info (Mesh_Info_Struct VertCount:VertCount VSize:VSize VType:VType FacePos:FacePos FaceCount:FaceCount VStart:VStart MeshId:MeshId)
  355. fseek f getPos #seek_set
  356. )
  357.  
  358. Print ("Item End@ 0x"+((bit.intAsHex(ftell f))as string))
  359.  
  360. print Mesh_Info
  361.  
  362. for i = 1 to meshcount do (
  363.  
  364. vertArray=#()
  365. faceArray=#()
  366. UV_array=#()
  367. Weight_array=#()
  368.  
  369. fseek f vertOffset #seek_set
  370.  
  371. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))
  372.  
  373. if (Mesh_Info[i].VSize)==24 do
  374. for x = 1 to Mesh_Info[i].VertCount do (
  375.  
  376. getPos = ftell f + 24
  377.  
  378. vx = Readfloat f
  379. vy = Readfloat f
  380. vz = Readfloat f
  381.  
  382. p1 = Readfloat f
  383.  
  384. tu= Readfloat f
  385. tv= Readfloat f*-1
  386.  
  387. fseek f getPos #seek_set
  388.  
  389. append vertArray ([vx,-vz,vy]*100)
  390. append UV_array [tu,tv,0]
  391. )
  392.  
  393. if (Mesh_Info[i].VSize)==28 do
  394. for x = 1 to Mesh_Info[i].VertCount do (
  395.  
  396. getPos = ftell f + 28
  397.  
  398. vx = Readfloat f
  399. vy = Readfloat f
  400. vz = Readfloat f
  401.  
  402. p1 = Readfloat f
  403.  
  404. tu= Readfloat f
  405. tv= Readfloat f*-1
  406.  
  407. bone1 = readbyte f #unsigned
  408. bone2 = readbyte f #unsigned
  409. weight1 = readbyte f #unsigned/255.0
  410. weight2 = readbyte f #unsigned/255.0
  411.  
  412. if weight1==1 then
  413. weight2 = 0
  414.  
  415. fseek f getPos #seek_set
  416.  
  417. w = (weight_data boneids:#() weights:#())
  418. maxweight = 0
  419. if(weight1 != 0) then
  420. maxweight = maxweight + weight1
  421. if(weight2 != 0) then
  422. maxweight = maxweight + weight2
  423.  
  424. if(maxweight != 0) then (
  425. if(weight1 != 0) then (
  426. w1 = weight1 as float
  427. append w.boneids (bone1 + 1)
  428. append w.weights (w1)
  429. )
  430. if(weight2 != 0) then (
  431. w2 = weight2 as float
  432. append w.boneids (bone2 + 1)
  433. append w.weights (w2)
  434. )
  435. )
  436. append Weight_array w
  437. append vertArray ([vx,-vz,vy]*100)
  438. append UV_array [tu,tv,0]
  439. )
  440.  
  441. if (Mesh_Info[i].VSize)==32 do
  442. for x = 1 to Mesh_Info[i].VertCount do (
  443.  
  444. getPos = ftell f + 32
  445.  
  446. vx = Readfloat f
  447. vy = Readfloat f
  448. vz = Readfloat f
  449.  
  450. p1 = Readfloat f
  451.  
  452. tu= Readfloat f
  453. tv= Readfloat f*-1
  454.  
  455. bone1 = readbyte f #unsigned
  456. bone2 = readbyte f #unsigned
  457. weight1 = readbyte f #unsigned/255.0
  458. weight2 = readbyte f #unsigned/255.0
  459.  
  460. p2 = Readfloat f
  461.  
  462. if weight1==1 then
  463. weight2 = 0
  464.  
  465. fseek f getPos #seek_set
  466.  
  467. w = (weight_data boneids:#() weights:#())
  468. maxweight = 0
  469. if(weight1 != 0) then
  470. maxweight = maxweight + weight1
  471. if(weight2 != 0) then
  472. maxweight = maxweight + weight2
  473.  
  474. if(maxweight != 0) then (
  475. if(weight1 != 0) then (
  476. w1 = weight1 as float
  477. append w.boneids (bone1 + 1)
  478. append w.weights (w1)
  479. )
  480. if(weight2 != 0) then (
  481. w2 = weight2 as float
  482. append w.boneids (bone2 + 1)
  483. append w.weights (w2)
  484. )
  485. )
  486. append Weight_array w
  487. append vertArray ([vx,-vz,vy]*100)
  488. append UV_array [tu,tv,0]
  489. )
  490.  
  491. if (Mesh_Info[i].VSize)==36 do
  492. for x = 1 to Mesh_Info[i].VertCount do (
  493.  
  494. vx = Readfloat f
  495. vy = Readfloat f
  496. vz = Readfloat f
  497.  
  498. unk1 = (ReadShort f/32767.00)
  499. unk2 = (ReadShort f/32767.00)
  500.  
  501. tu= Readfloat f
  502. tv= Readfloat f*-1
  503.  
  504. bone1 = readbyte f #unsigned
  505. bone2 = readbyte f #unsigned
  506. weight1 = readbyte f #unsigned/255.0
  507. weight2 = readbyte f #unsigned/255.0
  508.  
  509. p1=readlong f
  510.  
  511. bone3 = readbyte f #unsigned
  512. weight3 = readbyte f #unsigned/255.0
  513. bone4 = readbyte f #unsigned
  514. weight4 = readbyte f #unsigned/255.0
  515.  
  516. if weight1==1 then
  517. weight2 = 0
  518. weight3 = 0
  519. weight4 = 0
  520.  
  521. w = (weight_data boneids:#() weights:#())
  522. maxweight = 0
  523. if(weight1 != 0) then
  524. maxweight = maxweight + weight1
  525. if(weight2 != 0) then
  526. maxweight = maxweight + weight2
  527. if(weight3 != 0) then
  528. maxweight = maxweight + weight3
  529. if(weight4 != 0) then
  530. maxweight = maxweight + weight4
  531.  
  532. if(maxweight != 0) then (
  533. if(weight1 != 0) then (
  534. w1 = weight1 as float
  535. append w.boneids (bone1 + 1)
  536. append w.weights (w1)
  537. )
  538. if(weight2 != 0) then (
  539. w2 = weight2 as float
  540. append w.boneids (bone2 + 1)
  541. append w.weights (w2)
  542. )
  543. if(weight3 != 0) then (
  544. w3 = weight3 as float
  545. append w.boneids (bone3 + 1)
  546. append w.weights (w3)
  547. )
  548. if(weight4 != 0) then (
  549. w4 = weight4 as float
  550. append w.boneids (bone4 + 1)
  551. append w.weights (w4)
  552. )
  553. )
  554. append Weight_array w
  555. append vertArray ([vx,-vz,vy]*100)
  556. append UV_array [tu,tv,0]
  557. )
  558.  
  559. if (Mesh_Info[i].VSize)==44 do
  560. for x = 1 to Mesh_Info[i].VertCount do (
  561.  
  562. vx = Readfloat f
  563. vy = Readfloat f
  564. vz = Readfloat f
  565.  
  566. unk1 = (ReadShort f/32767.00)
  567. unk2 = (ReadShort f/32767.00)
  568.  
  569. tu= Readfloat f
  570. tv= Readfloat f*-1
  571.  
  572. bone1 = readbyte f #unsigned
  573. bone2 = readbyte f #unsigned
  574. weight1 = readbyte f #unsigned/255.0
  575. weight2 = readbyte f #unsigned/255.0
  576.  
  577. p1=readlong f
  578.  
  579. bone3 = readbyte f #unsigned
  580. weight3 = readbyte f #unsigned/255.0
  581. bone4 = readbyte f #unsigned
  582. weight4 = readbyte f #unsigned/255.0
  583.  
  584. p2=readlong f
  585. p3=readlong f
  586.  
  587. if weight1==1.00 then
  588. weight2 = 0
  589. weight3 = 0
  590. weight4 = 0
  591.  
  592. w = (weight_data boneids:#() weights:#())
  593. maxweight = 0
  594. if(weight1 != 0) then
  595. maxweight = maxweight + weight1
  596. if(weight2 != 0) then
  597. maxweight = maxweight + weight2
  598. if(weight3 != 0) then
  599. maxweight = maxweight + weight3
  600. if(weight4 != 0) then
  601. maxweight = maxweight + weight4
  602.  
  603. if(maxweight != 0) then (
  604. if(weight1 != 0) then (
  605. w1 = weight1 as float
  606. append w.boneids (bone1 + 1)
  607. append w.weights (w1)
  608. )
  609. if(weight2 != 0) then (
  610. w2 = weight2 as float
  611. append w.boneids (bone2 + 1)
  612. append w.weights (w2)
  613. )
  614. if(weight3 != 0) then (
  615. w3 = weight3 as float
  616. append w.boneids (bone3 + 1)
  617. append w.weights (w3)
  618. )
  619. if(weight4 != 0) then (
  620. w4 = weight4 as float
  621. append w.boneids (bone4 + 1)
  622. append w.weights (w4)
  623. )
  624. )
  625. append Weight_array w
  626. append vertArray ([vx,-vz,vy]*100)
  627. append UV_array [tu,tv,0]
  628. )
  629.  
  630. vertOffset+=(Mesh_Info[i].VertCount*Mesh_Info[i].VSize)
  631.  
  632. fseek f faceOffset #seek_set
  633. FaceBuffStart=ftell f
  634. faceStart=(FaceBuffStart+(Mesh_Info[i].FacePos*2))
  635.  
  636. fseek f (FaceBuffStart+(Mesh_Info[i].FacePos*2)) #seek_set
  637.  
  638. StartDirection = -1
  639. f1 = (ReadShort f+1)- Mesh_Info[i].VStart
  640. f2 = (ReadShort f+1)- Mesh_Info[i].VStart
  641. FaceDirection = StartDirection
  642. while (ftell f) < (faceStart + ((Mesh_Info[i].FaceCount)*2)) Do (
  643. f3 = (ReadShort f)
  644. if (f3==0xFFFF) then (
  645. f1 = (ReadShort f+1)- Mesh_Info[i].VStart
  646. f2 = (ReadShort f+1)- Mesh_Info[i].VStart
  647. FaceDirection = StartDirection
  648. ) else (
  649. f3 += (1- Mesh_Info[i].VStart)
  650. FaceDirection *= -1
  651. if (f1!=f2)AND(f2!=f3)AND(f3!=f1) then (
  652. if FaceDirection > 0 then append faceArray [(f1),(f2),(f3)]
  653. else append faceArray [(f1),(f3),(f2)]
  654. )
  655. f1 = f2
  656. f2 = f3
  657. )
  658. )
  659.  
  660. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  661.  
  662. try(
  663. msh = mesh vertices:vertArray faces:faceArray
  664. msh.numTVerts = UV_array.count
  665. buildTVFaces msh
  666. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  667. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  668. msh.wirecolor = (color 230 200 210)
  669.  
  670. max modify mode
  671. select msh
  672. skinMod = skin ()
  673. addModifier msh skinMod
  674. if Mesh_Info[i].MeshId==1 then
  675. (
  676. for i = 1 to BoneMapArray00.count do
  677. (
  678.  
  679. maxbone = BNArr[(BoneMapArray00[i])]
  680. if i != BoneMapArray00.count then
  681. skinOps.addBone skinMod maxbone 0
  682. else
  683. skinOps.addBone skinMod maxbone 1
  684. )
  685. )
  686. if Mesh_Info[i].MeshId==2 then
  687. (
  688. for i = 1 to BoneMapArray01.count do
  689. (
  690.  
  691. maxbone = BNArr[(BoneMapArray01[i])]
  692. if i != BoneMapArray01.count then
  693. skinOps.addBone skinMod maxbone 0
  694. else
  695. skinOps.addBone skinMod maxbone 1
  696. )
  697. )
  698. if Mesh_Info[i].MeshId==3 then
  699. (
  700. for i = 1 to BoneMapArray02.count do
  701. (
  702.  
  703. maxbone = BNArr[(BoneMapArray02[i])]
  704. if i != BoneMapArray02.count then
  705. skinOps.addBone skinMod maxbone 0
  706. else
  707. skinOps.addBone skinMod maxbone 1
  708. )
  709. )
  710. if Mesh_Info[i].MeshId==4 then
  711. (
  712. for i = 1 to BoneMapArray03.count do
  713. (
  714.  
  715. maxbone = BNArr[(BoneMapArray03[i])]
  716. if i != BoneMapArray03.count then
  717. skinOps.addBone skinMod maxbone 0
  718. else
  719. skinOps.addBone skinMod maxbone 1
  720. )
  721. )
  722. if Mesh_Info[i].MeshId==5 then
  723. (
  724. for i = 1 to BoneMapArray04.count do
  725. (
  726.  
  727. maxbone = BNArr[(BoneMapArray04[i])]
  728. if i != BoneMapArray04.count then
  729. skinOps.addBone skinMod maxbone 0
  730. else
  731. skinOps.addBone skinMod maxbone 1
  732. )
  733. )
  734. if Mesh_Info[i].MeshId==6 then
  735. (
  736. for i = 1 to BoneMapArray05.count do
  737. (
  738.  
  739. maxbone = BNArr[(BoneMapArray05[i])]
  740. if i != BoneMapArray05.count then
  741. skinOps.addBone skinMod maxbone 0
  742. else
  743. skinOps.addBone skinMod maxbone 1
  744. )
  745. )
  746. modPanel.setCurrentObject skinMod
  747. for i = 1 to (Mesh_Info[i].VertCount) do (
  748. w = Weight_array[i]
  749. bi = #()
  750. wv = #()
  751.  
  752. for j = 1 to w.boneids.count do
  753. (
  754. boneid = w.boneids[j]
  755. weight = w.weights[j]
  756. append bi boneid
  757. append wv weight
  758. )
  759.  
  760. skinOps.ReplaceVertexWeights skinMod i bi wv
  761.  
  762. )
  763. )catch(format "Error!!\n")
  764. format "Mesh %\n\tMesh Start: %\n\tFace Start: %\n\tVertex Type: %\n\n" i ("0x"+((bit.intAsHex(vertOffset))as string)) ("0x"+((bit.intAsHex(faceStart))as string)) ((((Mesh_Info[i].VType))as string))
  765. )
  766.  
  767. fclose f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement