home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 16944 / Warframe_Online_UPD.7z / Warframe_Online_UPD.ms
Encoding:
Text File  |  2019-10-16  |  35.7 KB  |  1,472 lines

  1. if (heapSize < 20000000) then
  2.     heapSize = 200000000
  3. gname = getOpenFileName \
  4. caption:"Open .fbx from Bones folder" \
  5. types:"Warframe_Bones (*.fbx)|*.fbx" \
  6. historyCategory:"WarframeBNEObjectPresets"
  7. g = fopen gname "rb"
  8. fname = getOpenFileName \
  9. caption:"Open .fbx from Mesh folder" \
  10. types:"Warframe (*.fbx)|*.fbx" \
  11. historyCategory:"WarframeMSHObjectPresets"
  12. f = fopen fname "rb"
  13.  
  14. clearlistener()
  15.  
  16. fn readHalfFloat fstream = (
  17.     hf=readshort fstream #unsigned
  18.     sign = bit.get hf 16
  19.     exponent = (bit.shift (bit.and hf (bit.hexasint "7C00")) -10) as integer - 16
  20.     fraction = bit.and hf (bit.hexasint "03FF")
  21.     if sign==true then sign = 1 else sign = 0
  22.     exponentF = exponent + 127
  23.     outputAsFloat = bit.or (bit.or (bit.shift fraction 13) \
  24.     (bit.shift exponentF 23)) (bit.shift sign 31)
  25.     return bit.intasfloat outputasfloat*2
  26.     )
  27.  
  28. fn ReadFixedString bstream fixedLen =
  29. (
  30.     local str = ""
  31.     for i = 1 to fixedLen do
  32.     (
  33.         str += bit.intAsChar (ReadByte bstream #unsigned)
  34.     )
  35.     str
  36. )    
  37.  
  38. struct weight_data
  39. (
  40.    boneids,weights
  41. )
  42. struct mesh_info_struct
  43. (
  44. meshname,FacePos,FaceCount
  45. )
  46. struct Bone_Info_Struct
  47. (
  48.     Bone1,Bone2,Bone3,Bone4
  49. )
  50. struct Weight_Info_Struct
  51. (
  52.     Weight1,Weight2,Weight3,Weight4
  53. )
  54. struct BoneMap_Struct
  55. (
  56. BoneMapId
  57. )
  58.  
  59. BoneCount=#()    
  60. BoneCount1=#()    
  61. VertexCount=#()    
  62. TotalFaces=#()    
  63. NumMorph=#()    
  64.  
  65. clearlistener()
  66.  
  67. fseek g 0x10 #seek_set
  68. SkelCount = readlong g 
  69. modelPathS = readlong g
  70. modelPath = ReadFixedString g modelPathS
  71. matNameS = readlong g
  72. matName = ReadFixedString g matNameS
  73. Print ("Strings End @ 0x"+((bit.intAsHex(ftell g))as string))
  74. if matNameS!=0 then readbyte g    
  75. StaticOrRigged=readlong g
  76. print ("StaticOrRigged:"+StaticOrRigged as string)    
  77. if StaticOrRigged==71 then (
  78. fseek g 0x68 #seek_cur
  79. UsedBones = readlong g    
  80. append VertexCount (readshort g)    
  81. Unk=readshort g    
  82. append TotalFaces (readlong g)        
  83. append NumMorph (readlong g)    
  84. fseek g 0xC6 #seek_cur
  85. )
  86. if StaticOrRigged==82 then (
  87. fseek g 0x6C #seek_cur
  88. UsedBones = readlong g        
  89. Print ("Pos @ 0x"+((bit.intAsHex(ftell g))as string))    
  90. append VertexCount (readshort g)    
  91. Unk=readshort g    
  92. append TotalFaces (readlong g)        
  93. append NumMorph (readlong g)    
  94. fseek g 0xC6 #seek_cur
  95. )
  96. ---------------------------------------------------------------------------------------------------------
  97. if StaticOrRigged==237 or StaticOrRigged==477 then (
  98. fseek g 0x6A #seek_cur    
  99. append BoneCount (readlong g)
  100. BoneNamesArray = #()    
  101. for x = 1 to BoneCount[1] do (
  102. BoneNameSize = readlong g    
  103. BoneName = ReadFixedString g BoneNameSize    
  104. append BoneNamesArray BoneName
  105. )
  106. append TotalFaces (readlong g)    
  107. UsedBones = readlong g
  108. append VertexCount (readlong g)    
  109. append NumMorph (readlong g)    
  110. fseek g 0x4 #seek_cur
  111. parse = readlong g
  112. if parse!=2 then fseek g 0x3D #seek_cur
  113. if parse==2 then fseek g 0x5D #seek_cur    
  114. append BoneCount1 (readlong g)
  115. BoneNamesArray1 = #()
  116. boneparent_array = #()
  117. for y = 1 to BoneCount1[1] do (
  118. BoneNameSize1 = readlong g    
  119. BoneName1 = ReadFixedString g BoneNameSize1
  120. append BoneNamesArray1 BoneName1
  121. boneparent=readshort g
  122. boneId=readshort g
  123. append boneparent_array boneparent
  124. )    
  125. fseek g 0xA2 #seek_cur
  126. )
  127.  
  128. if StaticOrRigged==248 then (
  129. fseek g 0x7A #seek_cur    
  130. append BoneCount (readlong g)
  131. BoneNamesArray = #()    
  132. for x = 1 to BoneCount[1] do (
  133. BoneNameSize = readlong g    
  134. BoneName = ReadFixedString g BoneNameSize    
  135. append BoneNamesArray BoneName
  136. )
  137. append TotalFaces (readlong g)    
  138. UsedBones = readlong g
  139. append VertexCount (readlong g)    
  140. append NumMorph (readlong g)    
  141. fseek g 0x4 #seek_cur
  142. parse = readlong g
  143. if parse!=2 then fseek g 0x3D #seek_cur
  144. if parse==2 then fseek g 0x5D #seek_cur    
  145. append BoneCount1 (readlong g)
  146. BoneNamesArray1 = #()
  147. boneparent_array = #()
  148. for y = 1 to BoneCount1[1] do (
  149. BoneNameSize1 = readlong g    
  150. BoneName1 = ReadFixedString g BoneNameSize1
  151. append BoneNamesArray1 BoneName1
  152. boneparent=readshort g
  153. boneId=readshort g
  154. append boneparent_array boneparent
  155. )    
  156. fseek g 0xA2 #seek_cur
  157. )
  158.  
  159. if StaticOrRigged==252 then (
  160. fseek g 0x7E #seek_cur    
  161. append BoneCount (readlong g)
  162. BoneNamesArray = #()    
  163. for x = 1 to BoneCount[1] do (
  164. BoneNameSize = readlong g    
  165. BoneName = ReadFixedString g BoneNameSize    
  166. append BoneNamesArray BoneName
  167. )
  168. Print ("!!!! @ 0x"+((bit.intAsHex(ftell g))as string))
  169. append TotalFaces (readlong g)    
  170. UsedBones = readlong g
  171. append VertexCount (readlong g)    
  172. append NumMorph (readlong g)    
  173. fseek g 0x4 #seek_cur
  174. parse = readlong g
  175. if parse!=2 then fseek g 0x3D #seek_cur
  176. if parse==2 then fseek g 0x5D #seek_cur    
  177. append BoneCount1 (readlong g)
  178. BoneNamesArray1 = #()
  179. boneparent_array = #()
  180. for y = 1 to BoneCount1[1] do (
  181. BoneNameSize1 = readlong g    
  182. BoneName1 = ReadFixedString g BoneNameSize1
  183. append BoneNamesArray1 BoneName1
  184. boneparent=readshort g
  185. boneId=readshort g
  186. append boneparent_array boneparent
  187. )    
  188. fseek g 0xA2 #seek_cur
  189. )
  190.  
  191. Print ("End @ 0x"+((bit.intAsHex(ftell g))as string))
  192.  
  193. Print ("Mesh Info Start @ 0x"+((bit.intAsHex(ftell g))as string))
  194.  
  195. MeshInfoArray= #()
  196. MeshCount=readlong g    
  197. for a = 1 to MeshCount do (
  198. fseek g 0x20 #seek_cur    
  199. NameSize=readlong g
  200. meshname = ReadFixedString g NameSize
  201. FacePos=readlong g
  202. Lod_1=readlong g
  203. Lod_2=readlong g    
  204. Lod_3=readlong g
  205. Lod_4=readlong g    
  206. FaceCount=readlong g    
  207. Lod_1_Count=readlong g    
  208. Lod_2_Count=readlong g
  209. Lod_3_Count=readlong g    
  210. Lod_4_Count=readlong g    
  211. fseek g 0x34 #seek_cur
  212. append MeshInfoArray (mesh_info_struct meshname:meshname FacePos:FacePos FaceCount:FaceCount)        
  213. )
  214.  
  215. print MeshInfoArray
  216.  
  217. Print ("Mesh Info End @ 0x"+((bit.intAsHex(ftell g))as string))
  218.  
  219. UsedBoneCount =#()
  220. if NumMorph[1]!=0 then 
  221. for x = 1 to 1 do (    
  222. MorphCount =readlong g    
  223. for x = 1 to MorphCount do (
  224. MorphNameSize = readlong g
  225. MorphName = ReadFixedString g MorphNameSize        
  226. null = readlong g    
  227. )
  228.  
  229. print ("MorphCount:"+ NumMorph[1] as string)
  230.  
  231. Print ("Morph End @ 0x"+((bit.intAsHex(ftell g))as string))
  232.  
  233. Print ("Map Start @ 0x"+((bit.intAsHex(ftell g))as string))
  234.  
  235. MeshParts=readlong g    
  236. BoneMapStart = (ftell g)
  237. for a = 1 to MeshParts do (
  238. append UsedBoneCount (readlong g)    
  239. for x = 1 to UsedBoneCount[a] do (
  240. UsedBoneId=readlong g    
  241. )    
  242. )
  243. )
  244.  
  245. wordCount=readlong g
  246. for i=1 to wordCount do (
  247. readshort g
  248. )    
  249. readlong g
  250.  
  251. Print ("Map Start @ 0x"+((bit.intAsHex(ftell g))as string))
  252.     
  253. MeshParts=readlong g    
  254. BoneMapStart = (ftell g)
  255. for a = 1 to MeshParts do (
  256. append UsedBoneCount (readlong g)    
  257. for x = 1 to UsedBoneCount[a] do (
  258. UsedBoneId=readlong g    
  259. )    
  260. )
  261.  
  262. VCount =#()    
  263.  
  264. Print ("Map End @ 0x"+((bit.intAsHex(ftell g))as string))
  265.  
  266. if NumMorph[1]!=0 then 
  267. for i = 1 to 1 do (    
  268. Mcount = readlong g    
  269. fseek g 0x18 #seek_cur
  270. for x = 1 to MeshParts do (
  271. LongCount00=readlong g    
  272. for i=1 to (LongCount00)    do (
  273. readlong g    
  274. )    
  275. LongCount01=readlong g    
  276. for i=1 to (LongCount01)    do (
  277. readlong g    
  278. )    
  279. longCount = readlong g
  280. Print ("VCount Start @ 0x"+((bit.intAsHex(ftell g))as string))        
  281. append VCount (readlong g)    
  282. for i=1 to (LongCount-1)    do (
  283. readlong g    
  284. )    
  285. Count=readlong g    
  286. for x = 1 to Count do (    
  287. NameSize = readlong g    
  288. fseek g NameSize #seek_cur
  289. )
  290. Print ("VCount End @ 0x"+((bit.intAsHex(ftell g))as string))    
  291. MorphStrCount=readlong g    
  292. for i=1 to (MorphStrCount)    do (
  293. readfloat g    
  294. )        
  295. LongCount02=readlong g    
  296. for i=1 to (LongCount02)    do (
  297. readlong g    
  298. )        
  299. )
  300. )
  301.  
  302. if NumMorph[1]==0 then fseek g 0x0 #seek_cur
  303.  
  304. print ("MVertex Count: "+(VCount as string))
  305. print ("Vertex Count: "+(VertexCount as string))    
  306.  
  307. -------------------------------------------------------------------------------------------------
  308.  
  309. fseek f 0x0 #seek_set    
  310. StrCheck=ReadFixedString f 8
  311. print     StrCheck
  312. if StaticOrRigged==237 or StaticOrRigged==248 or StaticOrRigged==477 then
  313. if StrCheck=="NXSMESH" then (
  314. print "Type 71+Rigged"        
  315. fseek f 0x0 #seek_set        
  316. for i = 1 to MeshCount do (        
  317.         
  318. vertArray=#()
  319. faceArray =#()    
  320. vertArray2=#()
  321. faceArray2 =#()
  322. UVarray=#()
  323.     
  324. fseek f 0xC #seek_cur    
  325. FaceType=readlong f    
  326. UnkHash=readlong f    
  327. ColVertCount=readlong f
  328. ColFaceCount=readlong f
  329.     
  330. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  331.     
  332. for x =1 to ColVertCount do (    
  333.     
  334. vx = readFloat f    
  335. vy = readFloat f    
  336. vz = readFloat f    
  337.  
  338. append vertArray2 ([-vx,-vz,vy]*100)        
  339. )
  340.     
  341. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  342.     
  343. if FaceType==6 then (
  344. for x = 1 to ColFaceCount do (
  345. fa=readbyte f #unsigned + 1
  346. fb=readbyte f #unsigned + 1
  347. fc=readbyte f #unsigned + 1
  348. append faceArray2 [fc,fb,fa]     
  349. )
  350.  
  351. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  352.     
  353. FaceOrderCount=(readlong f+1)
  354.  
  355. if ColFaceCount==FaceOrderCount then     
  356. for i=1 to (FaceOrderCount) do (
  357. readbyte f    
  358. )    
  359.  
  360. if ColFaceCount!=FaceOrderCount then     
  361. for i=1 to ColFaceCount do (
  362. readshort f
  363. )    
  364.  
  365. Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))        
  366. )        
  367.     
  368. if FaceType==10 then (    
  369. for x = 1 to ColFaceCount do (
  370. fa=readshort f #unsigned + 1
  371. fb=readshort f #unsigned + 1
  372. fc=readshort f #unsigned + 1
  373. append faceArray2 [fc,fb,fa]     
  374. )    
  375. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  376.     
  377. FaceOrderCount=(readlong f+1)
  378.  
  379. for i=1 to ColFaceCount do (
  380. readshort f    
  381. )    
  382.  
  383. Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))        
  384. )    
  385.  
  386. msh2 = mesh vertices:vertArray2 faces:faceArray2
  387. msh2.name=(("Collison Mesh_")+i as string)
  388.  
  389. fseek f 0x5B #seek_cur
  390.  
  391. BNECount=readlong f
  392. pad2=readbyte f
  393. for i=1 to BNECount do (
  394. getPos = ftell f + 128
  395. fseek f getPos #seek_set        
  396. )    
  397.  
  398. Print ("BNE End @ 0x"+((bit.intAsHex(ftell f))as string))    
  399.     
  400. fseek f 0x1C #seek_cur    
  401.  
  402. FaceOrderCount2=(readlong f)
  403.  
  404. for i=1 to FaceOrderCount2 do (
  405. readbyte f    
  406. )    
  407. Print ("NXE End @ 0x"+((bit.intAsHex(ftell f))as string))    
  408. )
  409.  
  410. BNArr = #()
  411. fseek f 0x2 #seek_cur
  412. for a = 1 to BoneCount[1] do (
  413. getPos = ftell f + 64
  414. fseek f getPos #seek_set    
  415. )    
  416.  
  417. BNArr1 = #()
  418. for a = 1 to BoneCount1[1] do ( --second bones section
  419. getPos = ftell f + 64        
  420. fseek f getPos #seek_set    
  421. )    
  422.     
  423.  
  424. for x =1 to BoneCount1[1] do (
  425. check = readshort f    
  426. )    
  427.  
  428. for x =1 to BoneCount1[1] do (
  429. check1 = readshort f    
  430. )    
  431.  
  432. fseek f 0x8 #seek_cur
  433.  
  434. if NumMorph[1]==0 then
  435. for i = 1 to MeshCount do (    
  436.     
  437. vertArray=#()
  438. faceArray =#()
  439. UVarray=#()
  440. W1_array=#() 
  441. B1_array=#()
  442. Weight_array=#()
  443. UsedBoneCountArray =#()
  444.     
  445. fseek g BoneMapStart #seek_set    
  446.  
  447. num = readlong g    
  448. for x = 1 to num do (
  449. BoneMapId=(readlong g+1)    
  450. append UsedBoneCountArray (BoneMap_Struct BoneMapId:BoneMapId)        
  451. )    
  452.  
  453. BoneMapStart+=(num*4)+4
  454. -- print UsedBoneCountArray    
  455.  
  456. vertOffset = (ftell f)
  457.  
  458. print vertOffset
  459.  
  460. NumVert=VertexCount[1]    
  461.  
  462. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  463.     
  464. for x =1 to NumVert do (    
  465.     
  466. vx = readHalfFloat f    
  467. vy = readHalfFloat f    
  468. vz = readHalfFloat f    
  469. fseek f 0xA #seek_cur
  470. tu = readHalfFloat f    
  471. tv = readHalfFloat f*-1
  472. tu00 = readHalfFloat f    
  473. tv00 = readHalfFloat f*-1    
  474. bone1 = readbyte f #unsigned
  475. bone2 = readbyte f #unsigned
  476. bone3 = readbyte f #unsigned
  477. bone4 = readbyte f #unsigned    
  478. weight1 = readbyte f #unsigned
  479. weight2 = readbyte f #unsigned
  480. weight3 = readbyte f #unsigned
  481. weight4 =readbyte f #unsigned    
  482.  
  483. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)    
  484. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  485. append vertArray ([-vx,-vz,vy]*100)    
  486. append UVarray [tu,tv,0]        
  487. )
  488.  
  489. num_compare=UsedBoneCount[i]
  490.  
  491. for b = 1 to W1_array.count Do (
  492. w = (weight_data boneids:#() weights:#())
  493. maxweight = 0
  494.    
  495. if(W1_array[b].Weight1 != 0) then
  496.    maxweight = maxweight + W1_array[b].Weight1
  497. if(B1_array[b].Bone1 > num_compare ) then (W1_array[b].Weight1)=0    
  498. if((B1_array[b].Bone1+1) > num_compare ) then (B1_array[b].Bone1)=0    
  499. if(W1_array[b].Weight2 != 0) then
  500.    maxweight = maxweight + W1_array[b].Weight2
  501. if(B1_array[b].Bone2 > num_compare) then (W1_array[b].Weight2)=0    
  502. if((B1_array[b].Bone2+1) > num_compare) then (B1_array[b].Bone2)=0
  503. if(W1_array[b].Weight3 != 0) then
  504.    maxweight = maxweight + W1_array[b].Weight3
  505. if(B1_array[b].Bone3 > num_compare) then (W1_array[b].Weight3)=0    
  506. if((B1_array[b].Bone3+1) > num_compare ) then (B1_array[b].Bone3)=0
  507. if(W1_array[b].Weight4 != 0) then
  508.    maxweight = maxweight + W1_array[b].Weight4
  509. if(B1_array[b].Bone4 > num_compare) then (W1_array[b].Weight4)=0        
  510. if((B1_array[b].Bone4+1) > num_compare ) then (B1_array[b].Bone4)=0
  511.  
  512. if(maxweight != 0) then
  513.    (
  514.       if(W1_array[b].Weight1 != 0) then
  515.       (
  516.          w1 = W1_array[b].Weight1 as float
  517.          append w.boneids (B1_array[b].Bone1 + 1)
  518.          append w.weights (w1/255)
  519.       )
  520.       if(W1_array[b].Weight2 != 0) then
  521.       (
  522.          w2 = W1_array[b].Weight2 as float
  523.          append w.boneids (B1_array[b].Bone2 + 1)
  524.          append w.weights (w2/255)
  525.       )
  526.       if(W1_array[b].Weight3 != 0) then
  527.       (
  528.          w3 = W1_array[b].Weight3 as float
  529.          append w.boneids (B1_array[b].Bone3 + 1)
  530.          append w.weights (w3/255)
  531.       )
  532.       if(W1_array[b].Weight4 != 0) then
  533.       (
  534.          w4 = W1_array[b].Weight4 as float
  535.          append w.boneids (B1_array[b].Bone4 + 1)
  536.          append w.weights (w4/255)
  537.       )      
  538.    )
  539. append Weight_array w
  540. )
  541.  
  542. FaceStart = (ftell f)    
  543. faceOffset = (MeshInfoArray[i].FacePos)*2
  544.     
  545. print num_compare
  546. print NumVert    
  547. print faceOffset
  548. print FaceStart
  549.     
  550. fseek f (FaceStart+faceOffset)  #seek_set    
  551.     
  552. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  553.     
  554. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  555. fa=readshort f + 1
  556. fb=readshort f + 1
  557. fc=readshort f + 1
  558. append faceArray [fc,fb,fa]     
  559. )    
  560.  
  561. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  562.     
  563. fseek f vertOffset  #seek_set    
  564.  
  565. try(        
  566. msh = mesh vertices:vertArray faces:faceArray
  567. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  568. msh.numTVerts = UVarray.count
  569. buildTVFaces msh
  570. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  571. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  572.  
  573.  
  574. -- max modify mode
  575. -- select msh
  576. -- skinMod = skin ()
  577. -- addModifier msh skinMod
  578. -- for i = 1 to UsedBoneCount[i] do
  579. -- (
  580. --     maxbone = getnodebyname BoneNamesArray[(UsedBoneCountArray[i].BoneMapId)]
  581. --     if i != UsedBoneCount[i] then 
  582. --         skinOps.addBone skinMod maxbone 0
  583. --     else
  584. --         skinOps.addBone skinMod maxbone 1
  585. -- )
  586. -- modPanel.setCurrentObject skinMod
  587. -- for i = 1 to NumVert do (
  588. --    w = Weight_array[i]
  589. --    bi = #() --bone index array
  590. --    wv = #() --weight value array
  591. --    
  592. --    for j = 1 to w.boneids.count do
  593. --    (
  594. --       boneid = w.boneids[j]
  595. --       weight = w.weights[j]
  596. --       append bi boneid
  597. --       append wv weight
  598. --    )   
  599. --    
  600. --    skinOps.ReplaceVertexWeights skinMod i bi wv
  601. -- )
  602. )catch(format "failed!!\n")
  603. )
  604. )
  605.  
  606. -----------------------------------------------------------------------------------------
  607.  
  608. if StaticOrRigged==237 or StaticOrRigged==248 or StaticOrRigged==252 or StaticOrRigged==477 then
  609. if StrCheck!="NXSMESH" then (
  610. BNArr = #()
  611. fseek f 0x2 #seek_set
  612. for a = 1 to BoneCount[1] do (
  613. getPos = ftell f + 64
  614. fseek f getPos #seek_set    
  615. )    
  616.  
  617. BNArr1 = #()
  618. for a = 1 to BoneCount1[1] do ( --second bones section
  619. getPos = ftell f + 64        
  620. fseek f getPos #seek_set    
  621. )    
  622.     
  623.  
  624. for x =1 to BoneCount1[1] do (
  625. check = readshort f    
  626. )    
  627.  
  628. for x =1 to BoneCount1[1] do (
  629. check1 = readshort f    
  630. )    
  631.  
  632. fseek f 0x8 #seek_cur
  633.  
  634. if NumMorph[1]==0 then
  635. for i = 1 to MeshCount do (    
  636.     
  637. vertArray=#()
  638. faceArray =#()
  639. UVarray=#()
  640. W1_array=#() 
  641. B1_array=#()
  642. Weight_array=#()
  643. UsedBoneCountArray =#()
  644.     
  645. fseek g BoneMapStart #seek_set    
  646.  
  647. num = readlong g    
  648. for x = 1 to num do (
  649. BoneMapId=(readlong g+1)    
  650. append UsedBoneCountArray (BoneMap_Struct BoneMapId:BoneMapId)        
  651. )    
  652.  
  653. BoneMapStart+=(num*4)+4
  654. -- print UsedBoneCountArray    
  655.  
  656. vertOffset = (ftell f)
  657.  
  658. print vertOffset
  659.  
  660. NumVert=VertexCount[1]    
  661.  
  662. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  663.     
  664. for x =1 to NumVert do (    
  665.     
  666. vx = readHalfFloat f    
  667. vy = readHalfFloat f    
  668. vz = readHalfFloat f    
  669. fseek f 0xA #seek_cur
  670. tu = readHalfFloat f    
  671. tv = readHalfFloat f*-1
  672. tu00 = readHalfFloat f    
  673. tv00 = readHalfFloat f*-1    
  674. bone1 = readbyte f #unsigned
  675. bone2 = readbyte f #unsigned
  676. bone3 = readbyte f #unsigned
  677. bone4 = readbyte f #unsigned    
  678. weight1 = readbyte f #unsigned
  679. weight2 = readbyte f #unsigned
  680. weight3 = readbyte f #unsigned
  681. weight4 =readbyte f #unsigned    
  682.  
  683. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)    
  684. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  685. append vertArray ([-vx,-vz,vy]*100)    
  686. append UVarray [tu,tv,0]        
  687. )
  688.  
  689. num_compare=UsedBoneCount[i]
  690.  
  691. for b = 1 to W1_array.count Do (
  692. w = (weight_data boneids:#() weights:#())
  693. maxweight = 0
  694.    
  695. if(W1_array[b].Weight1 != 0) then
  696.    maxweight = maxweight + W1_array[b].Weight1
  697. if(B1_array[b].Bone1 > num_compare ) then (W1_array[b].Weight1)=0    
  698. if((B1_array[b].Bone1+1) > num_compare ) then (B1_array[b].Bone1)=0    
  699. if(W1_array[b].Weight2 != 0) then
  700.    maxweight = maxweight + W1_array[b].Weight2
  701. if(B1_array[b].Bone2 > num_compare) then (W1_array[b].Weight2)=0    
  702. if((B1_array[b].Bone2+1) > num_compare) then (B1_array[b].Bone2)=0
  703. if(W1_array[b].Weight3 != 0) then
  704.    maxweight = maxweight + W1_array[b].Weight3
  705. if(B1_array[b].Bone3 > num_compare) then (W1_array[b].Weight3)=0    
  706. if((B1_array[b].Bone3+1) > num_compare ) then (B1_array[b].Bone3)=0
  707. if(W1_array[b].Weight4 != 0) then
  708.    maxweight = maxweight + W1_array[b].Weight4
  709. if(B1_array[b].Bone4 > num_compare) then (W1_array[b].Weight4)=0        
  710. if((B1_array[b].Bone4+1) > num_compare ) then (B1_array[b].Bone4)=0
  711.  
  712. if(maxweight != 0) then
  713.    (
  714.       if(W1_array[b].Weight1 != 0) then
  715.       (
  716.          w1 = W1_array[b].Weight1 as float
  717.          append w.boneids (B1_array[b].Bone1 + 1)
  718.          append w.weights (w1/255)
  719.       )
  720.       if(W1_array[b].Weight2 != 0) then
  721.       (
  722.          w2 = W1_array[b].Weight2 as float
  723.          append w.boneids (B1_array[b].Bone2 + 1)
  724.          append w.weights (w2/255)
  725.       )
  726.       if(W1_array[b].Weight3 != 0) then
  727.       (
  728.          w3 = W1_array[b].Weight3 as float
  729.          append w.boneids (B1_array[b].Bone3 + 1)
  730.          append w.weights (w3/255)
  731.       )
  732.       if(W1_array[b].Weight4 != 0) then
  733.       (
  734.          w4 = W1_array[b].Weight4 as float
  735.          append w.boneids (B1_array[b].Bone4 + 1)
  736.          append w.weights (w4/255)
  737.       )      
  738.    )
  739. append Weight_array w
  740. )
  741.  
  742. FaceStart = (ftell f)    
  743. faceOffset = (MeshInfoArray[i].FacePos)*2
  744.     
  745. print num_compare
  746. print NumVert    
  747. print faceOffset
  748. print FaceStart
  749.     
  750. fseek f (FaceStart+faceOffset)  #seek_set    
  751.     
  752. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  753.     
  754. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  755. fa=readshort f + 1
  756. fb=readshort f + 1
  757. fc=readshort f + 1
  758. append faceArray [fc,fb,fa]     
  759. )    
  760.  
  761. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  762.     
  763. fseek f vertOffset  #seek_set    
  764.  
  765. try(        
  766. msh = mesh vertices:vertArray faces:faceArray
  767. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  768. msh.numTVerts = UVarray.count
  769. buildTVFaces msh
  770. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  771. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  772.  
  773.  
  774. -- max modify mode
  775. -- select msh
  776. -- skinMod = skin ()
  777. -- addModifier msh skinMod
  778. -- for i = 1 to UsedBoneCount[i] do
  779. -- (
  780. --     maxbone = getnodebyname BoneNamesArray[(UsedBoneCountArray[i].BoneMapId)]
  781. --     if i != UsedBoneCount[i] then 
  782. --         skinOps.addBone skinMod maxbone 0
  783. --     else
  784. --         skinOps.addBone skinMod maxbone 1
  785. -- )
  786. -- modPanel.setCurrentObject skinMod
  787. -- for i = 1 to NumVert do (
  788. --    w = Weight_array[i]
  789. --    bi = #() --bone index array
  790. --    wv = #() --weight value array
  791. --    
  792. --    for j = 1 to w.boneids.count do
  793. --    (
  794. --       boneid = w.boneids[j]
  795. --       weight = w.weights[j]
  796. --       append bi boneid
  797. --       append wv weight
  798. --    )   
  799. --    
  800. --    skinOps.ReplaceVertexWeights skinMod i bi wv
  801. -- )
  802. )catch(format "failed!!\n")
  803. )
  804.  
  805. -------------------------------------------------
  806. vertOffset=(ftell f)
  807. vertStart=(ftell f)
  808. if NumMorph[1]!=0 then    
  809. for i = 1 to MeshCount do (    
  810.     
  811. vertArray=#()
  812. faceArray =#()
  813. UVarray=#()
  814. W1_array=#() 
  815. B1_array=#()
  816. Weight_array=#()
  817. UsedBoneCountArray =#()
  818.     
  819. fseek g BoneMapStart #seek_set    
  820.  
  821. num = readlong g    
  822. for x = 1 to num do (
  823. BoneMapId=(readlong g+1)    
  824. append UsedBoneCountArray (BoneMap_Struct BoneMapId:BoneMapId)        
  825. )    
  826.  
  827. BoneMapStart+=(num*4)+4
  828. -- print UsedBoneCountArray    
  829.  
  830. print vertOffset
  831.  
  832. fseek f vertStart #seek_set        
  833.  
  834. NumVert=VCount[i]    
  835.     
  836. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  837.     
  838. for x =1 to NumVert do (    
  839.     
  840. vx = readHalfFloat f    
  841. vy = readHalfFloat f    
  842. vz = readHalfFloat f    
  843. fseek f 0xA #seek_cur
  844. tu = readHalfFloat f    
  845. tv = readHalfFloat f*-1
  846. tu00 = readHalfFloat f    
  847. tv00 = readHalfFloat f*-1    
  848. bone1 = readbyte f #unsigned
  849. bone2 = readbyte f #unsigned
  850. bone3 = readbyte f #unsigned
  851. bone4 = readbyte f #unsigned    
  852. weight1 = readbyte f #unsigned
  853. weight2 = readbyte f #unsigned
  854. weight3 = readbyte f #unsigned
  855. weight4 =readbyte f #unsigned    
  856.  
  857. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)    
  858. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  859. append vertArray ([-vx,-vz,vy]*100)    
  860. append UVarray [tu,tv,0]        
  861. )
  862.  
  863. num_compare=UsedBoneCount[i]
  864.  
  865. for b = 1 to W1_array.count Do (
  866. w = (weight_data boneids:#() weights:#())
  867. maxweight = 0
  868.    
  869. if(W1_array[b].Weight1 != 0) then
  870.    maxweight = maxweight + W1_array[b].Weight1
  871. if(B1_array[b].Bone1 > num_compare ) then (W1_array[b].Weight1)=0    
  872. if((B1_array[b].Bone1+1) > num_compare ) then (B1_array[b].Bone1)=0    
  873. if(W1_array[b].Weight2 != 0) then
  874.    maxweight = maxweight + W1_array[b].Weight2
  875. if(B1_array[b].Bone2 > num_compare) then (W1_array[b].Weight2)=0    
  876. if((B1_array[b].Bone2+1) > num_compare) then (B1_array[b].Bone2)=0
  877. if(W1_array[b].Weight3 != 0) then
  878.    maxweight = maxweight + W1_array[b].Weight3
  879. if(B1_array[b].Bone3 > num_compare) then (W1_array[b].Weight3)=0    
  880. if((B1_array[b].Bone3+1) > num_compare ) then (B1_array[b].Bone3)=0
  881. if(W1_array[b].Weight4 != 0) then
  882.    maxweight = maxweight + W1_array[b].Weight4
  883. if(B1_array[b].Bone4 > num_compare) then (W1_array[b].Weight4)=0        
  884. if((B1_array[b].Bone4+1) > num_compare ) then (B1_array[b].Bone4)=0
  885.  
  886. if(maxweight != 0) then
  887.    (
  888.       if(W1_array[b].Weight1 != 0) then
  889.       (
  890.          w1 = W1_array[b].Weight1 as float
  891.          append w.boneids (B1_array[b].Bone1 + 1)
  892.          append w.weights (w1/255)
  893.       )
  894.       if(W1_array[b].Weight2 != 0) then
  895.       (
  896.          w2 = W1_array[b].Weight2 as float
  897.          append w.boneids (B1_array[b].Bone2 + 1)
  898.          append w.weights (w2/255)
  899.       )
  900.       if(W1_array[b].Weight3 != 0) then
  901.       (
  902.          w3 = W1_array[b].Weight3 as float
  903.          append w.boneids (B1_array[b].Bone3 + 1)
  904.          append w.weights (w3/255)
  905.       )
  906.       if(W1_array[b].Weight4 != 0) then
  907.       (
  908.          w4 = W1_array[b].Weight4 as float
  909.          append w.boneids (B1_array[b].Bone4 + 1)
  910.          append w.weights (w4/255)
  911.       )      
  912.    )
  913. append Weight_array w
  914. )
  915.  
  916. VertexEnd=vertOffset+(VertexCount[1]*32)
  917.  
  918. fseek f VertexEnd #seek_set    
  919.  
  920. print VertexEnd
  921.  
  922. Print ("Vertex End @ 0x"+((bit.intAsHex(ftell f))as string))    
  923.  
  924. for x=1 to NumMorph[1] do (
  925. getPos = ftell f + 16        
  926. fseek f getPos #seek_set        
  927. )    
  928.  
  929. FaceStart = (ftell f)    
  930. faceOffset = (MeshInfoArray[i].FacePos)*2
  931.     
  932. print num_compare
  933. print NumVert    
  934. print faceOffset
  935. print FaceStart
  936.     
  937. fseek f (FaceStart+faceOffset)  #seek_set    
  938.     
  939. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  940.     
  941. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  942. fa=readshort f + 1
  943. fb=readshort f + 1
  944. fc=readshort f + 1
  945. append faceArray [fc,fb,fa]     
  946. )    
  947.  
  948. vertStart+=NumVert*32
  949.  
  950. try(        
  951. msh = mesh vertices:vertArray faces:faceArray
  952. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  953. msh.numTVerts = UVarray.count
  954. buildTVFaces msh
  955. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  956. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  957.  
  958.  
  959. -- max modify mode
  960. -- select msh
  961. -- skinMod = skin ()
  962. -- addModifier msh skinMod
  963. -- for i = 1 to UsedBoneCount[i] do
  964. -- (
  965. --     maxbone = getnodebyname BoneNamesArray[(UsedBoneCountArray[i].BoneMapId)]
  966. --     if i != UsedBoneCount[i] then 
  967. --         skinOps.addBone skinMod maxbone 0
  968. --     else
  969. --         skinOps.addBone skinMod maxbone 1
  970. -- )
  971. -- modPanel.setCurrentObject skinMod
  972. -- for i = 1 to NumVert do (
  973. --    w = Weight_array[i]
  974. --    bi = #() --bone index array
  975. --    wv = #() --weight value array
  976. --    
  977. --    for j = 1 to w.boneids.count do
  978. --    (
  979. --       boneid = w.boneids[j]
  980. --       weight = w.weights[j]
  981. --       append bi boneid
  982. --       append wv weight
  983. --    )   
  984. --    
  985. --    skinOps.ReplaceVertexWeights skinMod i bi wv
  986. -- )
  987. )catch(format "failed!!\n")
  988. )
  989. )
  990.  
  991. -----------------------------------------------------------------------------------------
  992. fseek f 0x0 #seek_set    
  993. StrCheck=ReadFixedString f 8
  994. print     StrCheck
  995. if StaticOrRigged==71 then
  996. if StrCheck=="NXSMESH" then (
  997. fseek f 0xC #seek_cur    
  998. FaceType=readlong f    
  999. UnkHash=readlong f    
  1000. ColVertCount=readlong f
  1001. ColFaceCount=readlong f    
  1002. fseek f 0x0 #seek_set    
  1003. print "Type 71+Static+Collision"        
  1004. for i = 1 to MeshCount do (
  1005.     
  1006. vertArray=#()
  1007. faceArray =#()    
  1008. vertArray2=#()
  1009. faceArray2 =#()
  1010. UVarray=#()
  1011.     
  1012. fseek f 0xC #seek_cur    
  1013. FaceType=readlong f    
  1014. UnkHash=readlong f    
  1015. ColVertCount=readlong f
  1016. ColFaceCount=readlong f
  1017.     
  1018. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1019.     
  1020. for x =1 to ColVertCount do (    
  1021.     
  1022. vx = readFloat f    
  1023. vy = readFloat f    
  1024. vz = readFloat f    
  1025.  
  1026. append vertArray2 ([-vx,-vz,vy]*100)        
  1027. )
  1028.     
  1029. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1030.     
  1031. if FaceType==6 then (
  1032. for x = 1 to ColFaceCount do (
  1033. fa=readbyte f #unsigned + 1
  1034. fb=readbyte f #unsigned + 1
  1035. fc=readbyte f #unsigned + 1
  1036. append faceArray2 [fc,fb,fa]     
  1037. )
  1038.  
  1039. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1040.     
  1041. FaceOrderCount=(readlong f+1)
  1042.  
  1043. if ColFaceCount==FaceOrderCount then     
  1044. for i=1 to (FaceOrderCount) do (
  1045. readbyte f    
  1046. )    
  1047.  
  1048. if ColFaceCount!=FaceOrderCount then     
  1049. for i=1 to ColFaceCount do (
  1050. readshort f
  1051. )    
  1052.  
  1053. Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))        
  1054. )        
  1055.     
  1056. if FaceType==10 then (    
  1057. for x = 1 to ColFaceCount do (
  1058. fa=readshort f #unsigned + 1
  1059. fb=readshort f #unsigned + 1
  1060. fc=readshort f #unsigned + 1
  1061. append faceArray2 [fc,fb,fa]     
  1062. )    
  1063. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1064.     
  1065. FaceOrderCount=(readlong f+1)
  1066.  
  1067. for i=1 to ColFaceCount do (
  1068. readshort f    
  1069. )    
  1070.  
  1071. Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))        
  1072. )    
  1073.  
  1074. msh2 = mesh vertices:vertArray2 faces:faceArray2
  1075. msh2.name=(("Collison Mesh_")+i as string)
  1076.  
  1077. fseek f 0x5B #seek_cur
  1078.  
  1079. Print ("BNE Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1080.  
  1081. BNECount=readlong f
  1082. pad2=readbyte f
  1083. for i=1 to BNECount do (
  1084. getPos = ftell f + 128
  1085. fseek f getPos #seek_set        
  1086. )    
  1087.  
  1088. Print ("BNE End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1089.     
  1090. fseek f 0x1C #seek_cur    
  1091.  
  1092. FaceOrderCount2=(readlong f)
  1093.  
  1094. for i=1 to FaceOrderCount2 do (
  1095. readbyte f    
  1096. )    
  1097. Print ("NXE End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1098. )
  1099.  
  1100. fseek f 0x2 #seek_cur
  1101.  
  1102. if NumMorph[1]==0 then    
  1103. for i = 1 to MeshCount do (    
  1104.     
  1105. vertArray=#()
  1106. faceArray =#()    
  1107. UVarray=#()    
  1108.     
  1109. Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1110.     
  1111. print (VertexCount[1] as string)    
  1112.     
  1113. VertexStart=ftell f    
  1114.     
  1115. for x =1 to VertexCount[1] do (    
  1116. getPos = ftell f + 24    
  1117. vx = readHalfFloat f    
  1118. vy = readHalfFloat f    
  1119. vz = readHalfFloat f    
  1120. fseek f 0xA #seek_cur
  1121. tu = readHalfFloat f    
  1122. tv = readHalfFloat f*-1
  1123. fseek f getPos #seek_set    
  1124. append vertArray ([-vx,-vz,vy]*100)    
  1125. append UVarray [tu,tv,0]        
  1126. )
  1127.     
  1128. FaceStart = (ftell f)    
  1129. faceOffset = (MeshInfoArray[i].FacePos)*2
  1130.         
  1131. fseek f (FaceStart+faceOffset)  #seek_set    
  1132.     
  1133. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1134.     
  1135. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  1136. fa=readshort f #unsigned + 1
  1137. fb=readshort f #unsigned + 1
  1138. fc=readshort f #unsigned + 1
  1139. append faceArray [fc,fb,fa]     
  1140. )
  1141.  
  1142. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1143.     
  1144. fseek f VertexStart #seek_set    
  1145.  
  1146. msh = mesh vertices:vertArray faces:faceArray
  1147. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  1148. msh.numTVerts = UVarray.count
  1149. buildTVFaces msh
  1150. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  1151. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  1152. )
  1153. if NumMorph[1]!=0 then    
  1154. for i = 1 to MeshCount do (    
  1155.     
  1156. vertArray=#()
  1157. faceArray =#()    
  1158. UVarray=#()    
  1159.     
  1160. Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1161.     
  1162. print (VertexCount[1] as string)    
  1163.     
  1164. VertexStart=ftell f    
  1165.     
  1166. for x =1 to VertexCount[1] do (    
  1167. getPos = ftell f + 24    
  1168. vx = readHalfFloat f    
  1169. vy = readHalfFloat f    
  1170. vz = readHalfFloat f    
  1171. fseek f 0xA #seek_cur
  1172. tu = readHalfFloat f    
  1173. tv = readHalfFloat f*-1
  1174. fseek f getPos #seek_set    
  1175. append vertArray ([-vx,-vz,vy]*100)    
  1176. append UVarray [tu,tv,0]        
  1177. )
  1178.     
  1179. FaceStart = (ftell f)    
  1180. faceOffset = (MeshInfoArray[i].FacePos)*2
  1181.         
  1182. fseek f (FaceStart+faceOffset)  #seek_set    
  1183.     
  1184. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1185.     
  1186. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  1187. fa=readshort f #unsigned + 1
  1188. fb=readshort f #unsigned + 1
  1189. fc=readshort f #unsigned + 1
  1190. append faceArray [fc,fb,fa]     
  1191. )
  1192.  
  1193. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1194.     
  1195. fseek f VertexStart #seek_set    
  1196.  
  1197. msh = mesh vertices:vertArray faces:faceArray
  1198. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  1199. msh.numTVerts = UVarray.count
  1200. buildTVFaces msh
  1201. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  1202. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  1203. )
  1204. )
  1205. -----------------------------------------------------------------------------------------
  1206. if StaticOrRigged==82 then
  1207. if StrCheck=="NXSMESH" then (
  1208. fseek f 0xC #seek_cur    
  1209. FaceType=readlong f    
  1210. UnkHash=readlong f    
  1211. ColVertCount=readlong f
  1212. ColFaceCount=readlong f    
  1213. fseek f 0x0 #seek_set    
  1214. print "Type 71+Static+Collision"        
  1215. for i = 1 to MeshCount do (
  1216.     
  1217. vertArray=#()
  1218. faceArray =#()    
  1219. vertArray2=#()
  1220. faceArray2 =#()
  1221. UVarray=#()
  1222.     
  1223. fseek f 0xC #seek_cur    
  1224. FaceType=readlong f    
  1225. UnkHash=readlong f    
  1226. ColVertCount=readlong f
  1227. ColFaceCount=readlong f
  1228.     
  1229. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1230.     
  1231. for x =1 to ColVertCount do (    
  1232.     
  1233. vx = readFloat f    
  1234. vy = readFloat f    
  1235. vz = readFloat f    
  1236.  
  1237. append vertArray2 ([-vx,-vz,vy]*100)        
  1238. )
  1239.     
  1240. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1241.     
  1242. if FaceType==6 then (
  1243. for x = 1 to ColFaceCount do (
  1244. fa=readbyte f #unsigned + 1
  1245. fb=readbyte f #unsigned + 1
  1246. fc=readbyte f #unsigned + 1
  1247. append faceArray2 [fc,fb,fa]     
  1248. )
  1249.  
  1250. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1251.     
  1252. FaceOrderCount=(readlong f+1)
  1253.  
  1254. if ColFaceCount==FaceOrderCount then     
  1255. for i=1 to (FaceOrderCount) do (
  1256. readbyte f    
  1257. )    
  1258.  
  1259. if ColFaceCount!=FaceOrderCount then     
  1260. for i=1 to ColFaceCount do (
  1261. readshort f
  1262. )    
  1263.  
  1264. Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))        
  1265. )        
  1266.     
  1267. if FaceType==10 then (    
  1268. for x = 1 to ColFaceCount do (
  1269. fa=readshort f #unsigned + 1
  1270. fb=readshort f #unsigned + 1
  1271. fc=readshort f #unsigned + 1
  1272. append faceArray2 [fc,fb,fa]     
  1273. )    
  1274. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1275.     
  1276. FaceOrderCount=(readlong f+1)
  1277.  
  1278. for i=1 to ColFaceCount do (
  1279. readshort f    
  1280. )    
  1281.  
  1282. Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))        
  1283. )    
  1284.  
  1285. msh2 = mesh vertices:vertArray2 faces:faceArray2
  1286. msh2.name=(("Collison Mesh_")+i as string)
  1287.  
  1288. fseek f 0x5B #seek_cur
  1289.  
  1290. Print ("BNE Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1291.  
  1292. BNECount=readlong f
  1293. pad2=readbyte f
  1294. for i=1 to BNECount do (
  1295. getPos = ftell f + 112
  1296. fseek f getPos #seek_set        
  1297. )    
  1298.  
  1299. Print ("BNE @ 0x"+((bit.intAsHex(ftell f))as string))    
  1300.     
  1301. fseek f 0x1C #seek_cur    
  1302.  
  1303. FaceOrderCount2=(readlong f)
  1304.  
  1305. for i=1 to FaceOrderCount2 do (
  1306. readbyte f    
  1307. )    
  1308. Print ("NXE End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1309. )
  1310.  
  1311. fseek f 0x2 #seek_cur
  1312.  
  1313. if NumMorph[1]==0 then    
  1314. for i = 1 to MeshCount do (    
  1315.     
  1316. vertArray=#()
  1317. faceArray =#()    
  1318. UVarray=#()    
  1319.     
  1320. Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1321.     
  1322. print (VertexCount[1] as string)    
  1323.     
  1324. VertexStart=ftell f    
  1325.     
  1326. for x =1 to VertexCount[1] do (    
  1327. getPos = ftell f + 24    
  1328. vx = readHalfFloat f    
  1329. vy = readHalfFloat f    
  1330. vz = readHalfFloat f    
  1331. fseek f 0xA #seek_cur
  1332. tu = readHalfFloat f    
  1333. tv = readHalfFloat f*-1
  1334. fseek f getPos #seek_set    
  1335. append vertArray ([-vx,-vz,vy]*100)    
  1336. append UVarray [tu,tv,0]        
  1337. )
  1338.     
  1339. Print ("Mesh End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1340.  
  1341. FaceStart = (ftell f)    
  1342. faceOffset = (MeshInfoArray[i].FacePos)*2
  1343.         
  1344. fseek f (FaceStart+faceOffset)  #seek_set    
  1345.     
  1346. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1347.     
  1348. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  1349. fa=readshort f #unsigned + 1
  1350. fb=readshort f #unsigned + 1
  1351. fc=readshort f #unsigned + 1
  1352. append faceArray [fc,fb,fa]     
  1353. )
  1354.  
  1355. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1356.     
  1357. fseek f VertexStart #seek_set    
  1358.  
  1359. msh = mesh vertices:vertArray faces:faceArray
  1360. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  1361. msh.numTVerts = UVarray.count
  1362. buildTVFaces msh
  1363. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  1364. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  1365. )
  1366. if NumMorph[1]!=0 then    
  1367. for i = 1 to MeshCount do (    
  1368.     
  1369. vertArray=#()
  1370. faceArray =#()    
  1371. UVarray=#()    
  1372.     
  1373. Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1374.     
  1375. print (VertexCount[1] as string)    
  1376.     
  1377. VertexStart=ftell f    
  1378.     
  1379. for x =1 to VertexCount[1] do (    
  1380. getPos = ftell f + 24    
  1381. vx = readHalfFloat f    
  1382. vy = readHalfFloat f    
  1383. vz = readHalfFloat f    
  1384. fseek f 0xA #seek_cur
  1385. tu = readHalfFloat f    
  1386. tv = readHalfFloat f*-1
  1387. fseek f getPos #seek_set    
  1388. append vertArray ([-vx,-vz,vy]*100)    
  1389. append UVarray [tu,tv,0]        
  1390. )
  1391.     
  1392. FaceStart = (ftell f)    
  1393. faceOffset = (MeshInfoArray[i].FacePos)*2
  1394.         
  1395. fseek f (FaceStart+faceOffset)  #seek_set    
  1396.     
  1397. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1398.     
  1399. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  1400. fa=readshort f #unsigned + 1
  1401. fb=readshort f #unsigned + 1
  1402. fc=readshort f #unsigned + 1
  1403. append faceArray [fc,fb,fa]     
  1404. )
  1405.  
  1406. Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))    
  1407.     
  1408. fseek f VertexStart #seek_set    
  1409.  
  1410. msh = mesh vertices:vertArray faces:faceArray
  1411. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  1412. msh.numTVerts = UVarray.count
  1413. buildTVFaces msh
  1414. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  1415. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  1416. )
  1417. )
  1418. -----------------------------------------------------------------------------------------
  1419. if StaticOrRigged==71 or StaticOrRigged==82 then
  1420. if StrCheck!="NXSMESH" then (
  1421. print "Type 71+StaticNoCollision"        
  1422. fseek f 0x0 #seek_set        
  1423. for i=1 to MeshCount do (
  1424.     
  1425. vertArray=#()
  1426. faceArray =#()    
  1427. UVarray=#()
  1428.     
  1429. fseek f 0x2 #seek_cur
  1430.     
  1431. Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1432.     
  1433. print (VertexCount[1] as string)    
  1434.     
  1435. for x =1 to VertexCount[1] do (    
  1436. getPos = ftell f + 24    
  1437. vx = readHalfFloat f    
  1438. vy = readHalfFloat f    
  1439. vz = readHalfFloat f    
  1440. fseek f 0xA #seek_cur
  1441. tu = readHalfFloat f    
  1442. tv = readHalfFloat f*-1
  1443. fseek f getPos #seek_set    
  1444. append vertArray ([-vx,-vz,vy]*100)    
  1445. append UVarray [tu,tv,0]        
  1446. )
  1447.     
  1448. FaceStart = (ftell f)    
  1449. faceOffset = (MeshInfoArray[i].FacePos)*2
  1450.         
  1451. fseek f (FaceStart+faceOffset)  #seek_set    
  1452.     
  1453. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  1454.     
  1455. for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
  1456. fa=readshort f #unsigned + 1
  1457. fb=readshort f #unsigned + 1
  1458. fc=readshort f #unsigned + 1
  1459. append faceArray [fc,fb,fa]     
  1460. )
  1461.  
  1462. msh = mesh vertices:vertArray faces:faceArray
  1463. msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
  1464. msh.numTVerts = UVarray.count
  1465. buildTVFaces msh
  1466. for j = 1 to UVarray.count do setTVert msh j UVarray[j]
  1467. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  1468. )
  1469. )
  1470. ---------------------------------------------------------------------------------------------------------
  1471. fclose g
  1472. fclose f