home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 7130 / SB_4.7z / SB_4.ms < prev   
Encoding:
Text File  |  2014-03-24  |  33.4 KB  |  1,357 lines

  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:"Sengoku Basara 4  (*.mod)|*.mod" \
  7. historyCategory:"SB_4ObjectPresets"
  8. f = fopen fname "rb"
  9.  
  10. clearlistener()
  11.  
  12. fn readBElong fstream = (bit.swapBytes (bit.swapBytes (readlong fstream #unsigned) 1 4) 2 3)
  13.  
  14. fn readBEword fstream = (
  15. short = readshort fstream #unsigned
  16. short = bit.swapBytes short 1 2
  17. return short
  18. )
  19.  
  20. fn readBEfloat fstream = (bit.intAsFloat (bit.swapBytes (bit.swapBytes (readlong fstream #unsigned) 1 4) 2 3))    
  21.  
  22. fn ReadBEHalfFloat fstream = 
  23.     (
  24.     hf=readBEword fstream
  25.     sign = bit.get hf 16
  26.     exponent = (bit.shift (bit.and hf (bit.hexasint "7C00")) -10) as integer - 16
  27.     fraction = bit.and hf (bit.hexasint "03FF")
  28.     if sign==true then sign = 1 else sign = 0
  29.     exponentF = exponent + 127
  30.     outputAsFloat = bit.or (bit.or (bit.shift fraction 13) \
  31.     (bit.shift exponentF 23)) (bit.shift sign 31)
  32.     return bit.intasfloat outputasfloat*2
  33. )
  34.  
  35. fn readFixedString bstream fixedLen = (
  36. local str = ""
  37. for i = 1 to fixedLen do (
  38. str += bit.intAsChar (ReadByte bstream #unsigned))
  39. str
  40. )
  41. struct weight_data
  42. (
  43.     boneids,weights
  44. )
  45. struct Mesh_Info_Struct
  46. (
  47. VertCount, VSize,VId,VId2,VType, FacePos, FaceCount,VStart 
  48. )
  49.  
  50. clearlistener()
  51.  
  52. fseek f 0x6 #seek_set
  53. BoneCount = ReadBEword f
  54. meshcount = ReadBEword f
  55. fseek f 0xc #seek_set
  56. VertexCount = ReadBElong f --12
  57. fseek f 0x18 #seek_set
  58. VertSize = ReadBElong f --24
  59. Long05 = ReadBElong f --28
  60. Long06 = ReadBElong f  --32
  61. BoneOff = ReadBElong f  --36
  62. print (meshcount as string)
  63. matcount2 = ReadBEword f
  64. fseek f 0x30 #seek_set
  65. itemoff = readBElong f
  66. print (itemoff as string)
  67. fseek f 0x34 #seek_set
  68. vertOffset = readBElong f
  69. print (vertOffset as string)
  70. faceOffset = readBElong f
  71. fileEnd = readBElong f
  72. print (faceOffset as string)
  73.  
  74. fseek f BoneOff  #seek_set    
  75. BNArr = #()
  76. BoneParent = #()
  77. for a = 1 to BoneCount Do (
  78. boneid = readbyte f#unsigned
  79. append BoneParent (readbyte f#unsigned)
  80. childid = readbyte f#unsigned
  81. unkid = readbyte f#unsigned
  82. floata = ReadBEfloat f
  83. floatb = ReadBEfloat f
  84. bonex  = ReadBEfloat f
  85. boney  = ReadBEfloat f
  86. bonez  = ReadBEfloat f                  
  87. )
  88.  
  89. for a = 1 to BoneCount do (
  90. getPos = ftell f + 64
  91. fseek f getPos #seek_set    
  92. )    
  93.  
  94. for a = 1 to BoneCount do (
  95.  
  96. c11 = ReadBEfloat f; c12 = ReadBEfloat f; c13 = ReadBEfloat f; c14 = ReadBEfloat f    
  97. c21 = ReadBEfloat f; c22 = ReadBEfloat f; c23 = ReadBEfloat f; c24 = ReadBEfloat f    
  98. c31 = ReadBEfloat f; c32 = ReadBEfloat f; c33 = ReadBEfloat f; c34 = ReadBEfloat f
  99. c41 = ReadBEfloat f; c42 = ReadBEfloat f; c43 = ReadBEfloat f; c44 = ReadBEfloat f
  100.     
  101. tfm = matrix3 [c11,c12,c13] [c21,c22,c23] [c31,c32,c33] ([c41,c42,c43]*100)    
  102.     
  103. newBone = bonesys.createbone    \
  104.                   tfm.row4    \
  105.                   (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  106.                   (normalize tfm.row3)
  107.             newBone.name = (a as string)
  108.             newBone.width  = 0.01
  109.             newBone.height = 0.01
  110.             newBone.transform = inverse tfm
  111.             newBone.setBoneEnable false 0
  112.             newBone.wirecolor = white
  113.             newbone.showlinks = true
  114.             newBone.pos.controller      = TCB_position ()
  115.             newBone.rotation.controller = TCB_rotation ()    
  116.  if (BoneParent[a] != -1) then
  117.  newBone.parent = BNArr[(BoneParent[a])+1]                          
  118. append BNArr newBone                      
  119. )    
  120.  
  121. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  122.     
  123. Mesh_Info=#()
  124.  
  125. fseek f itemoff #seek_set
  126.  
  127. for i = 1 to meshcount do (
  128. getPos = ftell f + 56
  129. unk1 = ReadBEword f
  130. VertCount = ReadBEword f    
  131. unk2 = readBElong f    
  132. VId2 = readbyte f #unsigned    
  133. VId = readbyte f    #unsigned
  134. VSize = readbyte f
  135. VType = readbyte f    
  136. null = ReadBEword f    
  137. unk4 = readbyte f
  138. unk5 = readBElong f        
  139. unk6 = readBElong f    
  140. unk7 = readbyte f    
  141. FacePos = readBElong f
  142. FaceCount = readBElong f
  143. Null01 = ReadBElong f
  144. bone0 = ReadBEword f+1
  145. MeshtID = ReadBEword f
  146. VStart = ReadBEword f
  147. VEnd = ReadBEword f
  148. Mshj = ReadBElong f
  149. Null02 = ReadBElong f
  150. Null03 = ReadBElong f    
  151. append Mesh_Info (Mesh_Info_Struct VertCount:VertCount VSize:VSize VId:VId VId2:VId2 VType:VType FacePos:FacePos FaceCount:FaceCount VStart:VStart )        
  152. fseek f getPos #seek_set
  153. )
  154.  
  155. Print ("Item Off End Read @ 0x"+((bit.intAsHex(ftell f))as string))
  156.     
  157. print Mesh_Info
  158.     
  159. fseek f vertOffset #seek_set
  160.     
  161. for i = 1 to meshcount do (    
  162.     
  163. vertArray=#()
  164. faceArray=#()
  165. UV_array=#()    
  166. Weight_array=#()        
  167.  
  168. if  (Mesh_Info[i].VSize)==12 do     
  169. for x = 1 to Mesh_Info[i].VertCount do (
  170. Bone3 = -1
  171. Bone4 = -1
  172. weight3 = 0
  173. weight4 = 0    
  174. vx = (ReadBEword f /32767.00)
  175. vy = (ReadBEword f /32767.00)
  176. vz = (ReadBEword f /32767.00)
  177.     
  178. Bone1 = readbyte f #unsigned
  179. Bone2 = readbyte f #unsigned
  180.  
  181. weight1 = 0    
  182. weight2 = 1.00    
  183.     
  184. tu= readBEHalfFloat f    
  185. tv= readBEHalfFloat f*-1
  186.  
  187.     
  188. w = (weight_data boneids:#() weights:#())
  189. maxweight = 0
  190. if(weight1 != 0) then
  191.    maxweight = maxweight + weight1
  192. if(weight2 != 0) then
  193.    maxweight = maxweight + weight2
  194. if(weight3 != 0) then
  195.    maxweight = maxweight + weight3
  196. if(weight4 != 0) then
  197.    maxweight = maxweight + weight4
  198.  
  199. if(maxweight != 0) then (
  200.       if(weight1 != 0) then (
  201.          w1 = weight1 as float
  202.          append w.boneids (bone1 + 1)
  203.          append w.weights (w1 )
  204.       )
  205.       if(weight2 != 0) then (
  206.          w2 = weight2 as float
  207.          append w.boneids (bone2 + 1)
  208.          append w.weights (w2 )
  209.       )
  210.       if(weight3 != 0) then (
  211.          w3 = weight3 as float
  212.          append w.boneids (bone3 + 1)
  213.          append w.weights (w3 )
  214.       )
  215.       if(weight4 != 0) then (
  216.          w4 = weight4 as float
  217.          append w.boneids (bone4 + 1)
  218.          append w.weights (w4 )
  219.       )      
  220.    )
  221. append Weight_array w    
  222. append vertArray ([vx,vy,vz]*100)
  223. append UV_array [tu,tv,0]
  224. )
  225. if  (Mesh_Info[i].VSize)==16 do     
  226. for x = 1 to Mesh_Info[i].VertCount do (
  227. Bone3 = -1
  228. Bone4 = -1
  229. vx = (ReadBEword f /32767.00)
  230. vy = (ReadBEword f /32767.00)
  231. vz = (ReadBEword f /32767.00)
  232. weight1 = (ReadBEword f /32767.00)    
  233. tu= readBEHalfFloat f    
  234. tv= readBEHalfFloat f*-1
  235. unk2    = (readbyte f #unsigned/255.00)
  236. Bone1 = readbyte f #unsigned
  237. unk3    = (readbyte f #unsigned/255.00)
  238. Bone2 = readbyte f #unsigned
  239.     
  240. if weight1!=1.00 then
  241. weight2 = (1.00 - weight1)    
  242. weight4 = 0
  243.  
  244. if weight1==1.00 then
  245. weight2 = 0
  246. weight3 = 0    
  247.         
  248. w = (weight_data boneids:#() weights:#())
  249. maxweight = 0
  250. if(weight1 != 0) then
  251.    maxweight = maxweight + weight1
  252. if(weight2 != 0) then
  253.    maxweight = maxweight + weight2
  254. if(weight3 != 0) then
  255.    maxweight = maxweight + weight3
  256. if(weight4 != 0) then
  257.    maxweight = maxweight + weight4
  258.  
  259. if(maxweight != 0) then (
  260.       if(weight1 != 0) then (
  261.          w1 = weight1 as float
  262.          append w.boneids (bone1 + 1)
  263.          append w.weights (w1 )
  264.       )
  265.       if(weight2 != 0) then (
  266.          w2 = weight2 as float
  267.          append w.boneids (bone2 + 1)
  268.          append w.weights (w2 )
  269.       )
  270.       if(weight3 != 0) then (
  271.          w3 = weight3 as float
  272.          append w.boneids (bone3 + 1)
  273.          append w.weights (w3 )
  274.       )
  275.       if(weight4 != 0) then (
  276.          w4 = weight4 as float
  277.          append w.boneids (bone4 + 1)
  278.          append w.weights (w4 )
  279.       )      
  280.    )
  281. append Weight_array w    
  282. append vertArray ([vx,vy,vz]*100)
  283. append UV_array [tu,tv,0]
  284. )
  285. if  (Mesh_Info[i].VSize)==20 then
  286. if  (Mesh_Info[i].VType)==16 do
  287. for x = 1 to Mesh_Info[i].VertCount do (
  288. Bone3 = -1
  289. Bone4 = -1
  290. weight3 = 0
  291. weight4 = 0    
  292. vx = (ReadBEword f /32767.00)
  293. vy = (ReadBEword f /32767.00)
  294. vz = (ReadBEword f /32767.00)
  295.     
  296. Bone1 = readbyte f #unsigned
  297. Bone2 = readbyte f #unsigned
  298.     
  299. weight1 = 0    
  300. weight2 = 1.00    
  301.         
  302. unk1 = (readbyte f #unsigned/255.00)    
  303. unk2 = (readbyte f #unsigned/255.00)
  304. unk3 = (readbyte f #unsigned/255.00)            
  305. unk4 = (readbyte f #unsigned/255.00)    
  306. unk5 = (readbyte f #unsigned/255.00)    
  307. unk6 = (readbyte f #unsigned/255.00)
  308. unk7 = (readbyte f #unsigned/255.00)    
  309. unk8 = (readbyte f #unsigned/255.00)
  310.  
  311. tu= readBEHalfFloat f    
  312. tv= readBEHalfFloat f*-1    
  313.     
  314. w = (weight_data boneids:#() weights:#())
  315. maxweight = 0
  316. if(weight1 != 0) then
  317.    maxweight = maxweight + weight1
  318. if(weight2 != 0) then
  319.    maxweight = maxweight + weight2
  320. if(weight3 != 0) then
  321.    maxweight = maxweight + weight3
  322. if(weight4 != 0) then
  323.    maxweight = maxweight + weight4
  324.  
  325. if(maxweight != 0) then (
  326.       if(weight1 != 0) then (
  327.          w1 = weight1 as float
  328.          append w.boneids (bone1 + 1)
  329.          append w.weights (w1 )
  330.       )
  331.       if(weight2 != 0) then (
  332.          w2 = weight2 as float
  333.          append w.boneids (bone2 + 1)
  334.          append w.weights (w2 )
  335.       )
  336.       if(weight3 != 0) then (
  337.          w3 = weight3 as float
  338.          append w.boneids (bone3 + 1)
  339.          append w.weights (w3 )
  340.       )
  341.       if(weight4 != 0) then (
  342.          w4 = weight4 as float
  343.          append w.boneids (bone4 + 1)
  344.          append w.weights (w4 )
  345.       )      
  346.    )
  347. append Weight_array w    
  348. append vertArray ([vx,vy,vz]*100)
  349. append UV_array [tu,tv,0]
  350. )
  351. if  (Mesh_Info[i].VSize)==20 then
  352. if  (Mesh_Info[i].VType)==18 do
  353. for x = 1 to Mesh_Info[i].VertCount do (
  354. Bone3 = -1
  355. Bone4 = -1
  356. weight3 = 0
  357. weight4 = 0    
  358. vx = (ReadBEword f /32767.00)
  359. vy = (ReadBEword f /32767.00)
  360. vz = (ReadBEword f /32767.00)
  361.     
  362. Bone1 = readbyte f #unsigned
  363. Bone2 = readbyte f #unsigned
  364.  
  365. weight1 = 0    
  366. weight2 = 1.00    
  367.         
  368. unk1 = (readbyte f #unsigned/255.00)    
  369. unk2 = (readbyte f #unsigned/255.00)
  370. unk3 = (readbyte f #unsigned/255.00)            
  371. unk4 = (readbyte f #unsigned/255.00)    
  372. unk5 = (readbyte f #unsigned/255.00)    
  373. unk6 = (readbyte f #unsigned/255.00)
  374. unk7 = (readbyte f #unsigned/255.00)    
  375. unk8 = (readbyte f #unsigned/255.00)
  376.  
  377. tu= readBEHalfFloat f    
  378. tv= readBEHalfFloat f*-1    
  379.     
  380. w = (weight_data boneids:#() weights:#())
  381. maxweight = 0
  382. if(weight1 != 0) then
  383.    maxweight = maxweight + weight1
  384. if(weight2 != 0) then
  385.    maxweight = maxweight + weight2
  386. if(weight3 != 0) then
  387.    maxweight = maxweight + weight3
  388. if(weight4 != 0) then
  389.    maxweight = maxweight + weight4
  390.  
  391. if(maxweight != 0) then (
  392.       if(weight1 != 0) then (
  393.          w1 = weight1 as float
  394.          append w.boneids (bone1 + 1)
  395.          append w.weights (w1 )
  396.       )
  397.       if(weight2 != 0) then (
  398.          w2 = weight2 as float
  399.          append w.boneids (bone2 + 1)
  400.          append w.weights (w2 )
  401.       )
  402.       if(weight3 != 0) then (
  403.          w3 = weight3 as float
  404.          append w.boneids (bone3 + 1)
  405.          append w.weights (w3 )
  406.       )
  407.       if(weight4 != 0) then (
  408.          w4 = weight4 as float
  409.          append w.boneids (bone4 + 1)
  410.          append w.weights (w4 )
  411.       )      
  412.    )
  413. append Weight_array w    
  414. append vertArray ([vx,vy,vz]*100)
  415. append UV_array [tu,tv,0]
  416. )
  417. if  (Mesh_Info[i].VSize)==20 then
  418. if  (Mesh_Info[i].VType)==19 do
  419. for x = 1 to Mesh_Info[i].VertCount do (
  420. vx = (ReadBEword f /32767.00)
  421. vy = (ReadBEword f /32767.00)
  422. vz = (ReadBEword f /32767.00)
  423. p1 = ReadBEword f 
  424.  
  425. Bone1 = readbyte f #unsigned
  426. Bone2 = readbyte f #unsigned
  427. Bone3 = readbyte f #unsigned
  428. Bone4 = readbyte f #unsigned
  429.     
  430. weight1 = (readbyte f #unsigned/255.00)
  431. weight2 = (readbyte f #unsigned/255.00)
  432. weight3 = (readbyte f #unsigned/255.00)
  433. weight4 = (readbyte f #unsigned/255.00)    
  434.     
  435. tu= readBEHalfFloat f    
  436. tv= readBEHalfFloat f*-1    
  437.     
  438. w = (weight_data boneids:#() weights:#())
  439. maxweight = 0
  440. if(weight1 != 0) then
  441.    maxweight = maxweight + weight1
  442. if(weight2 != 0) then
  443.    maxweight = maxweight + weight2
  444. if(weight3 != 0) then
  445.    maxweight = maxweight + weight3
  446. if(weight4 != 0) then
  447.    maxweight = maxweight + weight4
  448.  
  449. if(maxweight != 0) then (
  450.       if(weight1 != 0) then (
  451.          w1 = weight1 as float
  452.          append w.boneids (bone1 + 1)
  453.          append w.weights (w1 )
  454.       )
  455.       if(weight2 != 0) then (
  456.          w2 = weight2 as float
  457.          append w.boneids (bone2 + 1)
  458.          append w.weights (w2 )
  459.       )
  460.       if(weight3 != 0) then (
  461.          w3 = weight3 as float
  462.          append w.boneids (bone3 + 1)
  463.          append w.weights (w3 )
  464.       )
  465.       if(weight4 != 0) then (
  466.          w4 = weight4 as float
  467.          append w.boneids (bone4 + 1)
  468.          append w.weights (w4 )
  469.       )      
  470.    )
  471. append Weight_array w    
  472. append vertArray ([vx,vy,vz]*100)
  473. append UV_array [tu,tv,0]
  474. )
  475. if  (Mesh_Info[i].VSize)==24 then
  476. if  (Mesh_Info[i].VId2)==129 do
  477. for x = 1 to Mesh_Info[i].VertCount do (
  478. Bone3 = -1
  479. Bone4 = -1
  480. weight3 = 0
  481. weight4 = 0    
  482. vx = (ReadBEword f /32767.00)
  483. vy = (ReadBEword f /32767.00)
  484. vz = (ReadBEword f /32767.00)
  485.     
  486. Bone1 = readbyte f #unsigned
  487. Bone2 = readbyte f #unsigned
  488.  
  489. weight1 = 0    
  490. weight2 = 1.00    
  491.     
  492. unk1 = (readbyte f #unsigned/255.00)    
  493. unk2 = (readbyte f #unsigned/255.00)
  494. unk3 = (readbyte f #unsigned/255.00)            
  495. unk4 = (readbyte f #unsigned/255.00)    
  496. unk5 = (readbyte f #unsigned/255.00)    
  497. unk6 = (readbyte f #unsigned/255.00)
  498. unk7 = (readbyte f #unsigned/255.00)    
  499. unk8 = (readbyte f #unsigned/255.00)
  500.  
  501. tu= readBEHalfFloat f    
  502. tv= readBEHalfFloat f*-1    
  503.  
  504. unk1= readBEHalfFloat f    
  505. unk2= readBEHalfFloat f*-1    
  506.     
  507. w = (weight_data boneids:#() weights:#())
  508. maxweight = 0
  509. if(weight1 != 0) then
  510.    maxweight = maxweight + weight1
  511. if(weight2 != 0) then
  512.    maxweight = maxweight + weight2
  513. if(weight3 != 0) then
  514.    maxweight = maxweight + weight3
  515. if(weight4 != 0) then
  516.    maxweight = maxweight + weight4
  517.  
  518. if(maxweight != 0) then (
  519.       if(weight1 != 0) then (
  520.          w1 = weight1 as float
  521.          append w.boneids (bone1 + 1)
  522.          append w.weights (w1 )
  523.       )
  524.       if(weight2 != 0) then (
  525.          w2 = weight2 as float
  526.          append w.boneids (bone2 + 1)
  527.          append w.weights (w2 )
  528.       )
  529.       if(weight3 != 0) then (
  530.          w3 = weight3 as float
  531.          append w.boneids (bone3 + 1)
  532.          append w.weights (w3 )
  533.       )
  534.       if(weight4 != 0) then (
  535.          w4 = weight4 as float
  536.          append w.boneids (bone4 + 1)
  537.          append w.weights (w4 )
  538.       )      
  539.    )
  540. append Weight_array w    
  541. append vertArray ([vx,vy,vz]*100)
  542. append UV_array [tu,tv,0]
  543. )
  544. if  (Mesh_Info[i].VSize)==24 then
  545. if  (Mesh_Info[i].VId2)==130 do
  546. for x = 1 to Mesh_Info[i].VertCount do (    
  547. Bone3 = -1
  548. Bone4 = -1
  549. vx = (ReadBEword f /32767.00)
  550. vy = (ReadBEword f /32767.00)
  551. vz = (ReadBEword f /32767.00)
  552. weight1 = (ReadBEword f /32767.00)
  553. p1= ReadBEword f
  554. p2= ReadBEword f
  555. p3= ReadBEword f
  556. p4= ReadBEword f        
  557. tu= readBEHalfFloat f    
  558. tv= readBEHalfFloat f*-1
  559. bone1 = (ReadBEHalfFloat f) as integer
  560. bone2 = (ReadBEHalfFloat f) as integer
  561.  
  562. -- print bone1
  563. -- print bone2
  564.  
  565. weight4 = 0
  566.  
  567. if weight1!=1.00 then
  568. weight2 = (1.00 - weight1)    
  569. weight3 = 0
  570.  
  571.  
  572. if weight1==1.00 then
  573. weight2 = 0
  574. weight3 = 0    
  575.         
  576. w = (weight_data boneids:#() weights:#())
  577. maxweight = 0
  578. if(weight1 != 0) then
  579.    maxweight = maxweight + weight1
  580. if(weight2 != 0) then
  581.    maxweight = maxweight + weight2
  582. if(weight3 != 0) then
  583.    maxweight = maxweight + weight3
  584. if(weight4 != 0) then
  585.    maxweight = maxweight + weight4
  586.  
  587. if(maxweight != 0) then (
  588.       if(weight1 != 0) then (
  589.          w1 = weight1 as float
  590.          append w.boneids (bone1 + 1)
  591.          append w.weights (w1 )
  592.       )
  593.       if(weight2 != 0) then (
  594.          w2 = weight2 as float
  595.          append w.boneids (bone2 + 1)
  596.          append w.weights (w2 )
  597.       )
  598.       if(weight3 != 0) then (
  599.          w3 = weight3 as float
  600.          append w.boneids (bone3 + 1)
  601.          append w.weights (w3 )
  602.       )
  603.       if(weight4 != 0) then (
  604.          w4 = weight4 as float
  605.          append w.boneids (bone4 + 1)
  606.          append w.weights (w4 )
  607.       )      
  608.    )
  609. append Weight_array w    
  610. append vertArray ([vx,vy,vz]*100)
  611. append UV_array [tu,tv,0]
  612. )
  613. if  (Mesh_Info[i].VSize)==28 then
  614. if  (Mesh_Info[i].VType)==16 do    
  615. for x = 1 to Mesh_Info[i].VertCount do (    
  616. vx = (ReadBEword f /32767.00)
  617. vy = (ReadBEword f /32767.00)
  618. vz = (ReadBEword f /32767.00)
  619.  
  620. weight1 =  (ReadBEword f /32767.00)
  621.  
  622. p1= ReadBEword f
  623. p2= ReadBEword f    
  624. p3= ReadBEword f    
  625. p4= ReadBEword f    
  626.  
  627. bone1 = readbyte f #unsigned
  628. bone2 = readbyte f #unsigned
  629. bone3 = readbyte f #unsigned    
  630. bone4 = readbyte f #unsigned
  631.         
  632. tu= readBEHalfFloat f    
  633. tv= readBEHalfFloat f*-1    
  634.     
  635. weight2 = readBEHalfFloat f    
  636. weight3 = readBEHalfFloat f    
  637.  
  638. weight4 = 1.00-(weight1+weight2+weight3)
  639.  
  640. if weight1==1.00 then
  641. weight2 = 0
  642. weight3 = 0
  643. weight4 = 0
  644.  
  645. w = (weight_data boneids:#() weights:#())
  646. maxweight = 0
  647. if(weight1 != 0) then
  648.    maxweight = maxweight + weight1
  649. if(weight2 != 0) then
  650.    maxweight = maxweight + weight2
  651. if(weight3 != 0) then
  652.    maxweight = maxweight + weight3
  653. if(weight4 != 0) then
  654.    maxweight = maxweight + weight4
  655.  
  656. if(maxweight != 0) then (
  657.       if(weight1 != 0) then (
  658.          w1 = weight1 as float
  659.          append w.boneids (bone1 + 1)
  660.          append w.weights (w1) 
  661.       )
  662.       if(weight2 != 0) then (
  663.          w2 = weight2 as float
  664.          append w.boneids (bone2 + 1)
  665.          append w.weights (w2) 
  666.       )
  667.       if(weight3 != 0) then (
  668.          w3 = weight3 as float
  669.          append w.boneids (bone3 + 1)
  670.          append w.weights (w3)  
  671.       )
  672.       if(weight4 != 0) then (
  673.          w4 = weight4 as float
  674.          append w.boneids (bone4 + 1)
  675.          append w.weights (w4) 
  676.       )      
  677.    )
  678. append Weight_array w    
  679. append vertArray ([vx,vy,vz]*100)
  680. append UV_array [tu,tv,0]
  681. )
  682. if  (Mesh_Info[i].VSize)==28 then
  683. if  (Mesh_Info[i].VType)==18 do
  684. if  (Mesh_Info[i].VId2)==128 do
  685. for x = 1 to Mesh_Info[i].VertCount do (    
  686. Bone1 = -1
  687. Bone2 = -1    
  688. Bone3 = -1
  689. Bone4 = -1
  690. weight1 = 0
  691. weight2 = 0    
  692. weight3 = 0
  693. weight4 = 0    
  694. vx = readBEfloat f
  695. vy = readBEfloat f
  696. vz = readBEfloat f
  697.  
  698. p1= ReadBEword f
  699. p2= ReadBEword f    
  700. p3= ReadBEword f    
  701. p4= ReadBEword f    
  702.  
  703. tu= readBEHalfFloat f    
  704. tv= readBEHalfFloat f*-1    
  705.     
  706. weight01 = readbyte f #unsigned    
  707. weight02 = readbyte f #unsigned
  708. weight03 = readbyte f #unsigned
  709. weight04 = readbyte f #unsigned
  710.     
  711. w = (weight_data boneids:#() weights:#())
  712. maxweight = 0
  713. if(weight1 != 0) then
  714.    maxweight = maxweight + weight1
  715. if(weight2 != 0) then
  716.    maxweight = maxweight + weight2
  717. if(weight3 != 0) then
  718.    maxweight = maxweight + weight3
  719. if(weight4 != 0) then
  720.    maxweight = maxweight + weight4
  721.  
  722. if(maxweight != 0) then (
  723.       if(weight1 != 0) then (
  724.          w1 = weight1 as float
  725.          append w.boneids (bone1 + 1)
  726.          append w.weights (w1/255.00) 
  727.       )
  728.       if(weight2 != 0) then (
  729.          w2 = weight2 as float
  730.          append w.boneids (bone2 + 1)
  731.          append w.weights (w2/255.00) 
  732.       )
  733.       if(weight3 != 0) then (
  734.          w3 = weight3 as float
  735.          append w.boneids (bone3 + 1)
  736.          append w.weights (w3/255.00)  
  737.       )
  738.       if(weight4 != 0) then (
  739.          w4 = weight4 as float
  740.          append w.boneids (bone4 + 1)
  741.          append w.weights (w4/255.00) 
  742.       )      
  743.    )
  744. append Weight_array w    
  745. append vertArray [vx,vy,vz]
  746. append UV_array [tu,tv,0]
  747. )
  748. if  (Mesh_Info[i].VSize)==28 then
  749. if  (Mesh_Info[i].VType)==18 do
  750. if  (Mesh_Info[i].VId2)==129 do
  751. for x = 1 to Mesh_Info[i].VertCount do (    
  752. vx = (ReadBEword f /32767.00)
  753. vy = (ReadBEword f /32767.00)
  754. vz = (ReadBEword f /32767.00)
  755.  
  756. weight1 =  (ReadBEword f /32767.00)
  757.  
  758. p1= ReadBEword f
  759. p2= ReadBEword f    
  760. p3= ReadBEword f    
  761. p4= ReadBEword f    
  762.  
  763. tu= readBEHalfFloat f    
  764. tv= readBEHalfFloat f*-1    
  765.     
  766. bone1 = (ReadBEHalfFloat f) as integer
  767. bone2 = (ReadBEHalfFloat f) as integer
  768.     
  769. unk2 = readBEHalfFloat f    
  770. unk3 = readBEHalfFloat f    
  771.  
  772. -- print bone1
  773. -- print bone2
  774.  
  775. weight4 = 0
  776.  
  777. if weight1!=1.00 then
  778. weight2 = (1.00 - weight1)    
  779. weight3 = 0
  780.  
  781.  
  782. if weight1==1.00 then
  783. weight2 = 0
  784. weight3 = 0
  785.  
  786. w = (weight_data boneids:#() weights:#())
  787. maxweight = 0
  788. if(weight1 != 0) then
  789.    maxweight = maxweight + weight1
  790. if(weight2 != 0) then
  791.    maxweight = maxweight + weight2
  792. if(weight3 != 0) then
  793.    maxweight = maxweight + weight3
  794. if(weight4 != 0) then
  795.    maxweight = maxweight + weight4
  796.  
  797. if(maxweight != 0) then (
  798.       if(weight1 != 0) then (
  799.          w1 = weight1 as float
  800.          append w.boneids (bone1 + 1)
  801.          append w.weights (w1) 
  802.       )
  803.       if(weight2 != 0) then (
  804.          w2 = weight2 as float
  805.          append w.boneids (bone2 + 1)
  806.          append w.weights (w2) 
  807.       )
  808.       if(weight3 != 0) then (
  809.          w3 = weight3 as float
  810.          append w.boneids (bone3 + 1)
  811.          append w.weights (w3)  
  812.       )
  813.       if(weight4 != 0) then (
  814.          w4 = weight4 as float
  815.          append w.boneids (bone4 + 1)
  816.          append w.weights (w4) 
  817.       )      
  818.    )
  819. append Weight_array w    
  820. append vertArray ([vx,vy,vz]*100)
  821. append UV_array [tu,tv,0]
  822. )
  823. if  (Mesh_Info[i].VSize)==28 then
  824. if  (Mesh_Info[i].VType)==18 do
  825. if  (Mesh_Info[i].VId2)==130 do
  826. for x = 1 to Mesh_Info[i].VertCount do (    
  827. vx = (ReadBEword f /32767.00)
  828. vy = (ReadBEword f /32767.00)
  829. vz = (ReadBEword f /32767.00)
  830.  
  831. weight1 =  (ReadBEword f /32767.00)
  832.  
  833. p1= ReadBEword f
  834. p2= ReadBEword f    
  835. p3= ReadBEword f    
  836. p4= ReadBEword f    
  837.  
  838. tu= readBEHalfFloat f    
  839. tv= readBEHalfFloat f*-1    
  840.     
  841. bone1 = (ReadBEHalfFloat f) as integer
  842. bone2 = (ReadBEHalfFloat f) as integer
  843.     
  844. unk2 = readBEHalfFloat f    
  845. unk3 = readBEHalfFloat f    
  846.  
  847. -- print bone1
  848. -- print bone2
  849.  
  850. weight4 = 0
  851.  
  852. if weight1!=1.00 then
  853. weight2 = (1.00 - weight1)    
  854. weight3 = 0
  855.  
  856.  
  857. if weight1==1.00 then
  858. weight2 = 0
  859. weight3 = 0
  860.  
  861. w = (weight_data boneids:#() weights:#())
  862. maxweight = 0
  863. if(weight1 != 0) then
  864.    maxweight = maxweight + weight1
  865. if(weight2 != 0) then
  866.    maxweight = maxweight + weight2
  867. if(weight3 != 0) then
  868.    maxweight = maxweight + weight3
  869. if(weight4 != 0) then
  870.    maxweight = maxweight + weight4
  871.  
  872. if(maxweight != 0) then (
  873.       if(weight1 != 0) then (
  874.          w1 = weight1 as float
  875.          append w.boneids (bone1 + 1)
  876.          append w.weights (w1) 
  877.       )
  878.       if(weight2 != 0) then (
  879.          w2 = weight2 as float
  880.          append w.boneids (bone2 + 1)
  881.          append w.weights (w2) 
  882.       )
  883.       if(weight3 != 0) then (
  884.          w3 = weight3 as float
  885.          append w.boneids (bone3 + 1)
  886.          append w.weights (w3)  
  887.       )
  888.       if(weight4 != 0) then (
  889.          w4 = weight4 as float
  890.          append w.boneids (bone4 + 1)
  891.          append w.weights (w4) 
  892.       )      
  893.    )
  894. append Weight_array w    
  895. append vertArray ([vx,vy,vz]*100)
  896. append UV_array [tu,tv,0]
  897. )
  898. if  (Mesh_Info[i].VSize)==28 then
  899. if  (Mesh_Info[i].VType)==18 do
  900. if  (Mesh_Info[i].VId2)==131 do
  901. for x = 1 to Mesh_Info[i].VertCount do (    
  902. vx = (ReadBEword f /32767.00)
  903. vy = (ReadBEword f /32767.00)
  904. vz = (ReadBEword f /32767.00)
  905.  
  906. weight1 =  (ReadBEword f /32767.00)
  907.  
  908. p1= ReadBEword f
  909. p2= ReadBEword f    
  910. p3= ReadBEword f    
  911. p4= ReadBEword f    
  912.  
  913. bone1 = readbyte f #unsigned
  914. bone2 = readbyte f #unsigned
  915. bone3 = readbyte f #unsigned    
  916. bone4 = readbyte f #unsigned    
  917.     
  918. tu= readBEHalfFloat f    
  919. tv= readBEHalfFloat f*-1    
  920.     
  921. weight2 = readBEHalfFloat f    
  922. weight3 = readBEHalfFloat f    
  923.  
  924. weight4 = 1.00-(weight1+weight2+weight3)
  925.     
  926. if weight1==1.00 then
  927. weight2 = 0
  928. weight3 = 0
  929. weight4 = 0
  930.  
  931. w = (weight_data boneids:#() weights:#())
  932. maxweight = 0
  933. if(weight1 != 0) then
  934.    maxweight = maxweight + weight1
  935. if(weight2 != 0) then
  936.    maxweight = maxweight + weight2
  937. if(weight3 != 0) then
  938.    maxweight = maxweight + weight3
  939. if(weight4 != 0) then
  940.    maxweight = maxweight + weight4
  941.  
  942. if(maxweight != 0) then (
  943.       if(weight1 != 0) then (
  944.          w1 = weight1 as float
  945.          append w.boneids (bone1 + 1)
  946.          append w.weights (w1) 
  947.       )
  948.       if(weight2 != 0) then (
  949.          w2 = weight2 as float
  950.          append w.boneids (bone2 + 1)
  951.          append w.weights (w2) 
  952.       )
  953.       if(weight3 != 0) then (
  954.          w3 = weight3 as float
  955.          append w.boneids (bone3 + 1)
  956.          append w.weights (w3)  
  957.       )
  958.       if(weight4 != 0) then (
  959.          w4 = weight4 as float
  960.          append w.boneids (bone4 + 1)
  961.          append w.weights (w4) 
  962.       )      
  963.    )
  964. append Weight_array w    
  965. append vertArray ([vx,vy,vz]*100)
  966. append UV_array [tu,tv,0]
  967. )
  968. if  (Mesh_Info[i].VSize)==28 then
  969. if  (Mesh_Info[i].VType)==18 do
  970. if  (Mesh_Info[i].VId2)==132 do
  971. for x = 1 to Mesh_Info[i].VertCount do (    
  972. vx = (ReadBEword f /32767.00)
  973. vy = (ReadBEword f /32767.00)
  974. vz = (ReadBEword f /32767.00)
  975.  
  976. weight1 =  (ReadBEword f /32767.00)
  977.  
  978. p1= ReadBEword f
  979. p2= ReadBEword f    
  980. p3= ReadBEword f    
  981. p4= ReadBEword f    
  982.  
  983.  
  984. bone1 = readbyte f #unsigned
  985. bone2 = readbyte f #unsigned
  986. bone3 = readbyte f #unsigned    
  987. bone4 = readbyte f #unsigned    
  988.     
  989. tu= readBEHalfFloat f    
  990. tv= readBEHalfFloat f*-1    
  991.     
  992. weight2 = readBEHalfFloat f    
  993. weight3 = readBEHalfFloat f    
  994.  
  995. weight4 = 1.00-(weight1+weight2+weight3)
  996.     
  997. if weight1==1.00 then
  998. weight2 = 0
  999. weight3 = 0    
  1000. weight4 = 0
  1001.  
  1002. w = (weight_data boneids:#() weights:#())
  1003. maxweight = 0
  1004. if(weight1 != 0) then
  1005.    maxweight = maxweight + weight1
  1006. if(weight2 != 0) then
  1007.    maxweight = maxweight + weight2
  1008. if(weight3 != 0) then
  1009.    maxweight = maxweight + weight3
  1010. if(weight4 != 0) then
  1011.    maxweight = maxweight + weight4
  1012.  
  1013. if(maxweight != 0) then (
  1014.       if(weight1 != 0) then (
  1015.          w1 = weight1 as float
  1016.          append w.boneids (bone1 + 1)
  1017.          append w.weights (w1) 
  1018.       )
  1019.       if(weight2 != 0) then (
  1020.          w2 = weight2 as float
  1021.          append w.boneids (bone2 + 1)
  1022.          append w.weights (w2) 
  1023.       )
  1024.       if(weight3 != 0) then (
  1025.          w3 = weight3 as float
  1026.          append w.boneids (bone3 + 1)
  1027.          append w.weights (w3)  
  1028.       )
  1029.       if(weight4 != 0) then (
  1030.          w4 = weight4 as float
  1031.          append w.boneids (bone4 + 1)
  1032.          append w.weights (w4) 
  1033.       )      
  1034.    )
  1035. append Weight_array w    
  1036. append vertArray ([vx,vy,vz]*100)
  1037. append UV_array [tu,tv,0]
  1038. )
  1039. if  (Mesh_Info[i].VSize)==28 then
  1040. if (Mesh_Info[i].VType)==19 do    
  1041. for x = 1 to Mesh_Info[i].VertCount do (    
  1042. vx = (ReadBEword f /32767.00)
  1043. vy = (ReadBEword f /32767.00)
  1044. vz = (ReadBEword f /32767.00)
  1045.     
  1046. p1= ReadBEword f
  1047.  
  1048. bone1 = readbyte f #unsigned    
  1049. bone2 = readbyte f #unsigned    
  1050. bone3 = readbyte f #unsigned    
  1051. bone4 = readbyte f #unsigned
  1052. bone5 = readbyte f #unsigned    
  1053. bone6 = readbyte f #unsigned    
  1054. bone7 = readbyte f #unsigned    
  1055. bone8 = readbyte f #unsigned
  1056.     
  1057. weight1 = readbyte f #unsigned    
  1058. weight2 = readbyte f #unsigned    
  1059. weight3 = readbyte f #unsigned    
  1060. weight4 = readbyte f #unsigned
  1061. weight5 = readbyte f #unsigned    
  1062. weight6 = readbyte f #unsigned    
  1063. weight7 = readbyte f #unsigned    
  1064. weight8 = readbyte f #unsigned
  1065.  
  1066. tu= readBEHalfFloat f    
  1067. tv= readBEHalfFloat f*-1    
  1068.  
  1069. w = (weight_data boneids:#() weights:#())
  1070. maxweight = 0
  1071. if(weight1 != 0) then
  1072.    maxweight = maxweight + weight1
  1073. if(weight2 != 0) then
  1074.    maxweight = maxweight + weight2
  1075. if(weight3 != 0) then
  1076.    maxweight = maxweight + weight3
  1077. if(weight4 != 0) then
  1078.    maxweight = maxweight + weight4
  1079. if(weight1 != 0) then
  1080.    maxweight = maxweight + weight5
  1081. if(weight2 != 0) then
  1082.    maxweight = maxweight + weight6
  1083. if(weight3 != 0) then
  1084.    maxweight = maxweight + weight7
  1085. if(weight4 != 0) then
  1086.    maxweight = maxweight + weight8
  1087.  
  1088. if(maxweight != 0) then (
  1089.       if(weight1 != 0) then (
  1090.          w1 = weight1 as float
  1091.          append w.boneids (bone1 + 1)
  1092.          append w.weights (w1/255.00)
  1093.       )
  1094.       if(weight2 != 0) then (
  1095.          w2 = weight2 as float
  1096.          append w.boneids (bone2 + 1)
  1097.          append w.weights (w2/255.00)
  1098.       )
  1099.       if(weight3 != 0) then (
  1100.          w3 = weight3 as float
  1101.          append w.boneids (bone3 + 1)
  1102.          append w.weights (w3/255.00)
  1103.       )
  1104.       if(weight4 != 0) then (
  1105.          w4 = weight4 as float
  1106.          append w.boneids (bone4 + 1)
  1107.         append w.weights (w4/255.00)
  1108.       )      
  1109.       if(weight5 != 0) then (
  1110.          w1 = weight5 as float
  1111.          append w.boneids (bone1 + 1)
  1112.          append w.weights (w1/255.00)
  1113.       )
  1114.       if(weight6 != 0) then (
  1115.          w2 = weight6 as float
  1116.          append w.boneids (bone2 + 1)
  1117.          append w.weights (w2/255.00)
  1118.       )
  1119.       if(weight7 != 0) then (
  1120.          w3 = weight7 as float
  1121.          append w.boneids (bone3 + 1)
  1122.          append w.weights (w3/255.00)
  1123.       )
  1124.       if(weight8 != 0) then (
  1125.          w8 = weight4 as float
  1126.          append w.boneids (bone4 + 1)
  1127.         append w.weights (w4/255.00)
  1128.       )  
  1129.    )
  1130. append Weight_array w    
  1131. append vertArray ([vx,vy,vz]*100)
  1132. append UV_array [tu,tv,0]
  1133. )
  1134. if  (Mesh_Info[i].VSize)==32 do 
  1135. for x = 1 to Mesh_Info[i].VertCount do (    
  1136. vx = (ReadBEword f /32767.00)
  1137. vy = (ReadBEword f /32767.00)
  1138. vz = (ReadBEword f /32767.00)
  1139. weight1 = (ReadBEword f/32767.00)
  1140.     
  1141. p1= ReadBEword f
  1142. p2= ReadBEword f
  1143. p3= ReadBEword f
  1144. p4= ReadBEword f
  1145.     
  1146. bone1 = readbyte f #unsigned
  1147. bone2 = readbyte f #unsigned    
  1148. bone3 = readbyte f #unsigned        
  1149. bone4 = readbyte f #unsigned
  1150.  
  1151. tu= readBEHalfFloat f    
  1152. tv= readBEHalfFloat f*-1    
  1153.  
  1154. weight2 = readBEHalfFloat f    
  1155. weight3 = readBEHalfFloat f    
  1156.  
  1157. p5= ReadBEword f
  1158. p6= ReadBEword f    
  1159.  
  1160. weight4 = 1.00-(weight1+weight2+weight3)
  1161.  
  1162. if weight1==1.00 then
  1163. weight2 = 0
  1164. weight3 = 0
  1165.  
  1166.  
  1167. w = (weight_data boneids:#() weights:#())
  1168. maxweight = 0
  1169. if(weight1 != 0) then
  1170.    maxweight = maxweight + weight1
  1171. if(weight2 != 0) then
  1172.    maxweight = maxweight + weight2
  1173. if(weight3 != 0) then
  1174.    maxweight = maxweight + weight3
  1175. if(weight4 != 0) then
  1176.    maxweight = maxweight + weight4
  1177.  
  1178. if(maxweight != 0) then (
  1179.       if(weight1 != 0) then (
  1180.          w1 = weight1 as float
  1181.          append w.boneids (bone1 + 1)
  1182.          append w.weights (w1) 
  1183.       )
  1184.       if(weight2 != 0) then (
  1185.          w2 = weight2 as float
  1186.          append w.boneids (bone2 + 1)
  1187.          append w.weights (w2) 
  1188.       )
  1189.       if(weight3 != 0) then (
  1190.          w3 = weight3 as float
  1191.          append w.boneids (bone3 + 1)
  1192.          append w.weights (w3) 
  1193.       )
  1194.       if(weight4 != 0) then (
  1195.          w4 = weight4 as float
  1196.          append w.boneids (bone4 + 1)
  1197.          append w.weights (w4) 
  1198.       )      
  1199.    )
  1200. append Weight_array w    
  1201. append vertArray ([vx,vy,vz]*100)
  1202. append UV_array [tu,tv,0]
  1203. )
  1204. if  (Mesh_Info[i].VSize)==36 do 
  1205. for x = 1 to Mesh_Info[i].VertCount do (    
  1206. vx = (ReadBEword f /32767.00)
  1207. vy = (ReadBEword f /32767.00)
  1208. vz = (ReadBEword f /32767.00)
  1209. weight1 = (ReadBEword f/32767.00)
  1210.     
  1211. p1= ReadBEword f
  1212. p2= ReadBEword f
  1213.  
  1214. unk1 = readbyte f #unsigned
  1215. weight2 = readbyte f #unsigned /255.00
  1216. weight3 = readbyte f #unsigned    /255.00    
  1217. weight4 = readbyte f #unsigned    /255.00
  1218.         
  1219. bone1 = readbyte f #unsigned
  1220. bone2 = readbyte f #unsigned    
  1221. bone3 = readbyte f #unsigned        
  1222. bone4 = readbyte f #unsigned
  1223.  
  1224. p5= ReadBEword f
  1225. p6= ReadBEword f        
  1226.     
  1227. tu= readBEHalfFloat f    
  1228. tv= readBEHalfFloat f*-1    
  1229.  
  1230. unk2 = (ReadBEword f/32767.00)
  1231. unk3 = (ReadBEword f/32767.00)
  1232.  
  1233. weight4 = 1.00-(weight1+weight2+weight3)
  1234.  
  1235. if weight1==1.00 then
  1236. weight2 = 0
  1237. weight3 = 0
  1238. weight4 = 0
  1239.  
  1240. p7= readBEHalfFloat f    
  1241. p8= readBEHalfFloat f
  1242.  
  1243. w = (weight_data boneids:#() weights:#())
  1244. maxweight = 0
  1245. if(weight1 != 0) then
  1246.    maxweight = maxweight + weight1
  1247. if(weight2 != 0) then
  1248.    maxweight = maxweight + weight2
  1249. if(weight3 != 0) then
  1250.    maxweight = maxweight + weight3
  1251. if(weight4 != 0) then
  1252.    maxweight = maxweight + weight4
  1253.  
  1254. if(maxweight != 0) then (
  1255.       if(weight1 != 0) then (
  1256.          w1 = weight1 as float
  1257.          append w.boneids (bone1 + 1)
  1258.          append w.weights (w1) 
  1259.       )
  1260.       if(weight2 != 0) then (
  1261.          w2 = weight2 as float
  1262.          append w.boneids (bone2 + 1)
  1263.          append w.weights (w2) 
  1264.       )
  1265.       if(weight3 != 0) then (
  1266.          w3 = weight3 as float
  1267.          append w.boneids (bone3 + 1)
  1268.          append w.weights (w3) 
  1269.       )
  1270.       if(weight4 != 0) then (
  1271.          w4 = weight4 as float
  1272.          append w.boneids (bone4 + 1)
  1273.          append w.weights (w4) 
  1274.       )      
  1275.    )
  1276. append Weight_array w    
  1277. append vertArray ([vx,vy,vz]*100)
  1278. append UV_array [tu,tv,0]
  1279. )
  1280.  
  1281. ModelEnd=ftell f
  1282.  
  1283. fseek f faceOffset #seek_set
  1284. FaceBuffStart=ftell f
  1285. faceStart=(FaceBuffStart+(Mesh_Info[i].FacePos*2))
  1286.  
  1287. fseek f (FaceBuffStart+(Mesh_Info[i].FacePos*2)) #seek_set
  1288.  
  1289. StartDirection = -1
  1290. f1 = ((ReadBEword f) + 1) - Mesh_Info[i].VStart
  1291. f2 = ((ReadBEword f) + 1) - Mesh_Info[i].VStart 
  1292. FaceDirection = StartDirection
  1293. while ((ftell f) < (faceStart + (2 * Mesh_Info[i].FaceCount))) Do (
  1294. f3 = (ReadBEword f)
  1295. if (f3==0xFFFF) then (
  1296. f1 = ((ReadBEword f) + 1) - Mesh_Info[i].VStart
  1297. f2 = ((ReadBEword f) + 1) - Mesh_Info[i].VStart
  1298. FaceDirection = StartDirection 
  1299. ) else (
  1300. f3 += (1 - Mesh_Info[i].VStart)
  1301. FaceDirection *= -1
  1302. if (f1!=f2)AND(f2!=f3)AND(f3!=f1) then (
  1303. if FaceDirection > 0 then append Facearray [f1,f2,f3]
  1304. else append Facearray [f1,f3,f2]
  1305. )
  1306. f1 = f2
  1307. f2 = f3
  1308.  
  1309. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  1310.         
  1311. try(
  1312. msh = mesh vertices:vertArray faces:faceArray
  1313. msh.numTVerts = UV_array.count
  1314. buildTVFaces msh
  1315. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  1316. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  1317. msh.displayByLayer = false
  1318. msh.backfacecull = on
  1319. msh.wirecolor = (color 230 200 210)
  1320.  
  1321. max modify mode
  1322. select msh
  1323. skinMod = skin ()
  1324. addModifier msh skinMod
  1325. for i = 1 to BoneCount do
  1326. (
  1327.     maxbone = BNArr[i] 
  1328.     if i != BoneCount then 
  1329.         skinOps.addBone skinMod maxbone 0
  1330.     else
  1331.         skinOps.addBone skinMod maxbone 1
  1332. )
  1333. modPanel.setCurrentObject skinMod
  1334. for i = 1 to (Mesh_Info[i].VertCount) do (
  1335.    w = Weight_array[i]
  1336.    bi = #() --bone index array
  1337.    wv = #() --weight value array
  1338.    
  1339.    for j = 1 to w.boneids.count do
  1340.    (
  1341.       boneid = w.boneids[j]
  1342.       weight = w.weights[j]
  1343.       append bi boneid
  1344.       append wv weight
  1345.    )   
  1346.    
  1347.    skinOps.ReplaceVertexWeights skinMod i bi wv
  1348.    
  1349. )
  1350. )catch(format "failed!!\n")
  1351. fseek f ModelEnd #seek_set
  1352. format "Mesh %\n\tMesh End: %\n\tFace Start: %\n\tVertex Size: %\n\tVertex Id: %\n\tVertex Type: %\n\n" i ("0x"+((bit.intAsHex(ModelEnd))as string)) ("0x"+((bit.intAsHex(faceStart))as string)) (Mesh_Info[i].VSize as string) (Mesh_Info[i].VId as string) (Mesh_Info[i].VType as string)
  1353. )
  1354.     
  1355. fclose f