home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 7119 / Dragon's_Dogma.7z / DD_TEMP.ms
Encoding:
Text File  |  2014-03-22  |  16.8 KB  |  677 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:"Dragon's Dogma (*.mod)|*.mod" \
  7. historyCategory:"DDObjectPresets"
  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.  
  42. fn hexAsSting hx = (
  43. num = (bit.intashex hx) as string
  44. str=""
  45. pos=num.count;for i = 1 to (num.count/2) do (
  46. str+=bit.intaschar (execute ("0x"+(num[(pos-1)]+num[(pos)])))
  47. pos-=2
  48. )
  49. str
  50. )
  51.  
  52. struct weight_data
  53. (
  54.     boneids,weights
  55. )    
  56. struct Mesh_Info_Struct
  57. (
  58. VertCount, VSize,VType, FacePos, FaceCount,VStart  
  59. )
  60. clearlistener()
  61.  
  62. fseek f 0x6 #seek_set
  63. BoneCount = ReadBEword f
  64. meshcount = ReadBEword f
  65. fseek f 0xc #seek_set
  66. VertexCount = ReadBElong f 
  67. fseek f 0x18 #seek_set
  68. VertSize = ReadBElong f 
  69. Long05 = ReadBElong f 
  70. Long06 = ReadBElong f  
  71. BoneOff = ReadBElong f 
  72. print (meshcount as string)
  73. matcount2 = ReadBEword f
  74. fseek f 0x30 #seek_set
  75. itemoff = readBElong f
  76. print (itemoff as string)
  77. fseek f 0x34 #seek_set
  78. vertOffset = readBElong f
  79. print (vertOffset as string)
  80. faceOffset = readBElong f
  81. fileEnd = readBElong f
  82. print (faceOffset as string)
  83.  
  84. fseek f BoneOff  #seek_set    
  85. BNArr = #()
  86. BoneParent = #()
  87. for a = 1 to BoneCount Do (
  88. boneid = readbyte f#unsigned
  89. append BoneParent (readbyte f#unsigned)
  90. childid = readbyte f#unsigned
  91. unkid = readbyte f#unsigned
  92. floata = ReadBEfloat f
  93. floatb = ReadBEfloat f
  94. bonex  = ReadBEfloat f
  95. boney  = ReadBEfloat f
  96. bonez  = ReadBEfloat f                  
  97. )
  98.  
  99. for a = 1 to BoneCount do (
  100. getPos = ftell f + 64
  101. fseek f getPos #seek_set    
  102. )    
  103.  
  104. for a = 1 to BoneCount do (
  105.  
  106. c11 = ReadBEfloat f; c12 = ReadBEfloat f; c13 = ReadBEfloat f; c14 = ReadBEfloat f    
  107. c21 = ReadBEfloat f; c22 = ReadBEfloat f; c23 = ReadBEfloat f; c24 = ReadBEfloat f    
  108. c31 = ReadBEfloat f; c32 = ReadBEfloat f; c33 = ReadBEfloat f; c34 = ReadBEfloat f
  109. c41 = ReadBEfloat f; c42 = ReadBEfloat f; c43 = ReadBEfloat f; c44 = ReadBEfloat f
  110.     
  111. tfm = matrix3 [c11,c12,c13] [c21,c22,c23] [c31,c32,c33] ([c41,c42,c43]*100)    
  112.     
  113. newBone = bonesys.createbone    \
  114.                   tfm.row4    \
  115.                   (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  116.                   (normalize tfm.row3)
  117.             newBone.name = (a as string)
  118.             newBone.width  = 0.01
  119.             newBone.height = 0.01
  120.             newBone.transform = inverse tfm
  121.             newBone.setBoneEnable false 0
  122.             newBone.wirecolor = white
  123.             newbone.showlinks = true
  124.             newBone.pos.controller      = TCB_position ()
  125.             newBone.rotation.controller = TCB_rotation ()    
  126.  if (BoneParent[a] != -1) then
  127.  newBone.parent = BNArr[(BoneParent[a])+1]                          
  128. append BNArr newBone                      
  129. )    
  130.  
  131. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  132.     
  133. Mesh_Info=#()
  134.  
  135. fseek f itemoff #seek_set
  136.  
  137. for i = 1 to meshcount do (
  138. getPos = ftell f + 48
  139. unk1 = ReadBEword f
  140. VertCount = ReadBEword f    
  141. unk2 = readBElong f    
  142. unk3 = ReadBEword f
  143. VSize = readbyte f
  144. VType = readbyte f    
  145. null = ReadBEword f    
  146. unk4 = readbyte f
  147. unk5 = readBElong f        
  148. unk6 = readBElong f    
  149. unk7 = readbyte f    
  150. FacePos = readBElong f
  151. unk9 = ReadBEword f    
  152. FaceCount = ReadBEword f
  153. Null01 = ReadBElong f
  154. Unk05 = ReadBEword f
  155. MatID = ReadBEword f
  156. VStart = ReadBEword f
  157. VEnd = ReadBEword f
  158. Mshj = ReadBElong f
  159. Null02 = ReadBElong f
  160. Null03 = ReadBElong f    
  161. append Mesh_Info (Mesh_Info_Struct VertCount:VertCount VSize:VSize VType:VType FacePos:FacePos FaceCount:FaceCount VStart:VStart)        
  162. fseek f getPos #seek_set
  163. )
  164.  
  165. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  166.     
  167. print Mesh_Info
  168.     
  169. fseek f vertOffset #seek_set
  170.     
  171. for i = 1 to meshcount do (    
  172.     
  173. vertArray=#()
  174. faceArray=#()
  175. UV_array=#()    
  176. Weight_array=#()        
  177.  
  178.  
  179. if  (Mesh_Info[i].VSize)==0x14 do     
  180. for x = 1 to Mesh_Info[i].VertCount do (
  181. vx = (ReadBEword f /32767.00)
  182. vy = (ReadBEword f /32767.00)
  183. vz = (ReadBEword f /32767.00)
  184. p1= ReadBEword f
  185. bone4 = readbyte f #unsigned
  186. bone3 = readbyte f #unsigned    
  187. bone2 = readbyte f #unsigned    
  188. bone1 = readbyte f #unsigned
  189. weight4 = readbyte f #unsigned    /255.00
  190. weight3 = readbyte f #unsigned    /255.00
  191. weight2 = readbyte f #unsigned /255.00    
  192. weight1 = readbyte f #unsigned /255.00        
  193. p2= ReadBEword f
  194. p3= ReadBEword f
  195.  
  196.     
  197. w = (weight_data boneids:#() weights:#())
  198. maxweight = 0
  199. if(weight1 != 0) then
  200.    maxweight = maxweight + weight1
  201. if(weight2 != 0) then
  202.    maxweight = maxweight + weight2
  203. if(weight3 != 0) then
  204.    maxweight = maxweight + weight3
  205. if(weight4 != 0) then
  206.    maxweight = maxweight + weight4
  207.  
  208. if(maxweight != 0) then (
  209.       if(weight1 != 0) then (
  210.          w1 = weight1 as float
  211.          append w.boneids (bone1 + 1)
  212.          append w.weights (w1 )
  213.       )
  214.       if(weight2 != 0) then (
  215.          w2 = weight2 as float
  216.          append w.boneids (bone2 + 1)
  217.          append w.weights (w2 )
  218.       )
  219.       if(weight3 != 0) then (
  220.          w3 = weight3 as float
  221.          append w.boneids (bone3 + 1)
  222.          append w.weights (w3 )
  223.       )
  224.       if(weight4 != 0) then (
  225.          w4 = weight4 as float
  226.          append w.boneids (bone4 + 1)
  227.          append w.weights (w4 )
  228.       )      
  229.    )
  230. append Weight_array w    
  231. append vertArray ([vx,vy,vz]*100)
  232. append UV_array ([0,0,0]*2)
  233. )
  234. if  (Mesh_Info[i].VSize)==0x18 do 
  235. for x = 1 to Mesh_Info[i].VertCount do (
  236. Bone1 = -1
  237. Bone2 = -1
  238. Bone3 = -1
  239. Bone4 = -1
  240. weight1 = 0
  241. weight2 = 0
  242. weight3 = 0
  243. weight4 = 0    
  244. vx = (ReadBEword f /32767.00)
  245. vy = (ReadBEword f /32767.00)
  246. vz = (ReadBEword f /32767.00)
  247. p1= ReadBEword f
  248. p2= ReadBEword f
  249. p3= ReadBEword f
  250. p4= ReadBEword f    
  251. p5= ReadBEword f
  252. tu= readBEHalfFloat f    
  253. tv= readBEHalfFloat f*-1
  254. p8= ReadBEword f    
  255. p9= ReadBEword f
  256.     
  257. w = (weight_data boneids:#() weights:#())
  258. maxweight = 0
  259. if(weight1 != 0) then
  260.    maxweight = maxweight + weight1
  261. if(weight2 != 0) then
  262.    maxweight = maxweight + weight2
  263. if(weight3 != 0) then
  264.    maxweight = maxweight + weight3
  265. if(weight4 != 0) then
  266.    maxweight = maxweight + weight4
  267.  
  268. if(maxweight != 0) then (
  269.       if(weight1 != 0) then (
  270.          w1 = weight1 as float
  271.          append w.boneids (bone1 + 1)
  272.          append w.weights (w1 )
  273.       )
  274.       if(weight2 != 0) then (
  275.          w2 = weight2 as float
  276.          append w.boneids (bone2 + 1)
  277.          append w.weights (w2 )
  278.       )
  279.       if(weight3 != 0) then (
  280.          w3 = weight3 as float
  281.          append w.boneids (bone3 + 1)
  282.          append w.weights (w3 )
  283.       )
  284.       if(weight4 != 0) then (
  285.          w4 = weight4 as float
  286.          append w.boneids (bone4 + 1)
  287.          append w.weights (w4 )
  288.       )      
  289.    )
  290. append Weight_array w    
  291. append vertArray ([vx,vy,vz]*100)
  292. append UV_array [tu,tv,0]
  293. )
  294. if  (Mesh_Info[i].VSize)==0x1C then
  295. if  (Mesh_Info[i].VType)==16 do    
  296. for x = 1 to Mesh_Info[i].VertCount do (    
  297. vx = (ReadBEword f /32767.00)
  298. vy = (ReadBEword f /32767.00)
  299. vz = (ReadBEword f /32767.00)
  300.  
  301. weight1 =  (ReadBEword f /32767.00)
  302.  
  303. p1= ReadBEword f
  304. p2= ReadBEword f    
  305. p3= ReadBEword f    
  306. p4= ReadBEword f    
  307.  
  308. bone4 = readbyte f #unsigned
  309. bone3 = readbyte f #unsigned    
  310. bone2 = readbyte f #unsigned    
  311. bone1 = readbyte f #unsigned
  312.     
  313. tu= readBEHalfFloat f    
  314. tv= readBEHalfFloat f*-1    
  315.     
  316. weight2 = readBEHalfFloat f    
  317. weight3 = readBEHalfFloat f    
  318.  
  319. weight4 = 0
  320.  
  321. if weight1==1.00 then
  322. weight2 = 0
  323. weight3 = 0
  324.  
  325. w = (weight_data boneids:#() weights:#())
  326. maxweight = 0
  327. if(weight1 != 0) then
  328.    maxweight = maxweight + weight1
  329. if(weight2 != 0) then
  330.    maxweight = maxweight + weight2
  331. if(weight3 != 0) then
  332.    maxweight = maxweight + weight3
  333. if(weight4 != 0) then
  334.    maxweight = maxweight + weight4
  335.  
  336. if(maxweight != 0) then (
  337.       if(weight1 != 0) then (
  338.          w1 = weight1 as float
  339.          append w.boneids (bone1 + 1)
  340.          append w.weights (w1) 
  341.       )
  342.       if(weight2 != 0) then (
  343.          w2 = weight2 as float
  344.          append w.boneids (bone2 + 1)
  345.          append w.weights (w2) 
  346.       )
  347.       if(weight3 != 0) then (
  348.          w3 = weight3 as float
  349.          append w.boneids (bone3 + 1)
  350.          append w.weights (w3)  
  351.       )
  352.       if(weight4 != 0) then (
  353.          w4 = weight4 as float
  354.          append w.boneids (bone4 + 1)
  355.          append w.weights (w4) 
  356.       )      
  357.    )
  358. append Weight_array w    
  359. append vertArray ([vx,vy,vz]*100)
  360. append UV_array [tu,tv,0]
  361. )
  362. if  (Mesh_Info[i].VSize)==0x1C then
  363. if  (Mesh_Info[i].VType)==18 do    
  364. for x = 1 to Mesh_Info[i].VertCount do (    
  365. vx = (ReadBEword f /32767.00)
  366. vy = (ReadBEword f /32767.00)
  367. vz = (ReadBEword f /32767.00)
  368.  
  369. weight1 =  (ReadBEword f /32767.00)
  370.  
  371. p1= ReadBEword f
  372. p2= ReadBEword f    
  373. p3= ReadBEword f    
  374. p4= ReadBEword f    
  375.  
  376. bone4 = readbyte f #unsigned
  377. bone3 = readbyte f #unsigned    
  378. bone2 = readbyte f #unsigned    
  379. bone1 = readbyte f #unsigned
  380.     
  381. tu= readBEHalfFloat f    
  382. tv= readBEHalfFloat f*-1    
  383.     
  384. weight2 = readBEHalfFloat f    
  385. weight3 = readBEHalfFloat f    
  386.  
  387.  
  388. weight4 = 0
  389.     
  390. if weight1==1.00 then
  391. weight2 = 0
  392. weight3 = 0
  393.  
  394. w = (weight_data boneids:#() weights:#())
  395. maxweight = 0
  396. if(weight1 != 0) then
  397.    maxweight = maxweight + weight1
  398. if(weight2 != 0) then
  399.    maxweight = maxweight + weight2
  400. if(weight3 != 0) then
  401.    maxweight = maxweight + weight3
  402. if(weight4 != 0) then
  403.    maxweight = maxweight + weight4
  404.  
  405. if(maxweight != 0) then (
  406.       if(weight1 != 0) then (
  407.          w1 = weight1 as float
  408.          append w.boneids (bone1 + 1)
  409.          append w.weights (w1) 
  410.       )
  411.       if(weight2 != 0) then (
  412.          w2 = weight2 as float
  413.          append w.boneids (bone2 + 1)
  414.          append w.weights (w2) 
  415.       )
  416.       if(weight3 != 0) then (
  417.          w3 = weight3 as float
  418.          append w.boneids (bone3 + 1)
  419.          append w.weights (w3)  
  420.       )
  421.       if(weight4 != 0) then (
  422.          w4 = weight4 as float
  423.          append w.boneids (bone4 + 1)
  424.          append w.weights (w4) 
  425.       )      
  426.    )
  427. append Weight_array w    
  428. append vertArray ([vx,vy,vz]*100)
  429. append UV_array [tu,tv,0]
  430. )
  431. if  (Mesh_Info[i].VSize)==0x1C then
  432. if (Mesh_Info[i].VType)==19 do    
  433. for x = 1 to Mesh_Info[i].VertCount do (            
  434. vx = (ReadBEword f /32767.00)
  435. vy = (ReadBEword f /32767.00)
  436. vz = (ReadBEword f /32767.00)
  437.     
  438. p1= ReadBEword f
  439.  
  440. bone1 = readbyte f #unsigned    
  441. bone2 = readbyte f #unsigned    
  442. bone3 = readbyte f #unsigned    
  443. bone4 = readbyte f #unsigned
  444. bone5 = readbyte f #unsigned    
  445. bone6 = readbyte f #unsigned    
  446. bone7 = readbyte f #unsigned    
  447. bone8 = readbyte f #unsigned
  448.     
  449. weight1 = readbyte f #unsigned    
  450. weight2 = readbyte f #unsigned    
  451. weight3 = readbyte f #unsigned    
  452. weight4 = readbyte f #unsigned
  453. weight5 = readbyte f #unsigned    
  454. weight6 = readbyte f #unsigned    
  455. weight7 = readbyte f #unsigned    
  456. weight8 = readbyte f #unsigned
  457.  
  458. tu= readBEHalfFloat f    
  459. tv= readBEHalfFloat f*-1    
  460.  
  461. w = (weight_data boneids:#() weights:#())
  462. maxweight = 0
  463. if(weight1 != 0) then
  464.    maxweight = maxweight + weight1
  465. if(weight2 != 0) then
  466.    maxweight = maxweight + weight2
  467. if(weight3 != 0) then
  468.    maxweight = maxweight + weight3
  469. if(weight4 != 0) then
  470.    maxweight = maxweight + weight4
  471. if(weight1 != 0) then
  472.    maxweight = maxweight + weight5
  473. if(weight2 != 0) then
  474.    maxweight = maxweight + weight6
  475. if(weight3 != 0) then
  476.    maxweight = maxweight + weight7
  477. if(weight4 != 0) then
  478.    maxweight = maxweight + weight8
  479.  
  480. if(maxweight != 0) then (
  481.       if(weight1 != 0) then (
  482.          w1 = weight1 as float
  483.          append w.boneids (bone1 + 1)
  484.          append w.weights (w1/255.00)
  485.       )
  486.       if(weight2 != 0) then (
  487.          w2 = weight2 as float
  488.          append w.boneids (bone2 + 1)
  489.          append w.weights (w2/255.00)
  490.       )
  491.       if(weight3 != 0) then (
  492.          w3 = weight3 as float
  493.          append w.boneids (bone3 + 1)
  494.          append w.weights (w3/255.00)
  495.       )
  496.       if(weight4 != 0) then (
  497.          w4 = weight4 as float
  498.          append w.boneids (bone4 + 1)
  499.         append w.weights (w4/255.00)
  500.       )      
  501.       if(weight5 != 0) then (
  502.          w1 = weight5 as float
  503.          append w.boneids (bone1 + 1)
  504.          append w.weights (w1/255.00)
  505.       )
  506.       if(weight6 != 0) then (
  507.          w2 = weight6 as float
  508.          append w.boneids (bone2 + 1)
  509.          append w.weights (w2/255.00)
  510.       )
  511.       if(weight7 != 0) then (
  512.          w3 = weight7 as float
  513.          append w.boneids (bone3 + 1)
  514.          append w.weights (w3/255.00)
  515.       )
  516.       if(weight8 != 0) then (
  517.          w8 = weight4 as float
  518.          append w.boneids (bone4 + 1)
  519.         append w.weights (w4/255.00)
  520.       )  
  521.    )
  522. append Weight_array w    
  523. append vertArray ([vx,vy,vz]*100)
  524. append UV_array [tu,tv,0]
  525. )
  526. if  (Mesh_Info[i].VSize)==0x24 do 
  527. for x = 1 to Mesh_Info[i].VertCount do (    
  528. vx = (ReadBEword f /32767.00)
  529. vy = (ReadBEword f /32767.00)
  530. vz = (ReadBEword f /32767.00)
  531. weight1 = (ReadBEword f/32767.00)
  532.     
  533. p1= ReadBEword f
  534. p2= ReadBEword f
  535.  
  536. unk1 = readbyte f #unsigned
  537. weight4 = readbyte f #unsigned    /255.00
  538. weight3 = readbyte f #unsigned    /255.00
  539. weight2 = readbyte f #unsigned /255.00
  540.         
  541. bone4 = readbyte f #unsigned
  542. bone3 = readbyte f #unsigned    
  543. bone2 = readbyte f #unsigned    
  544. bone1 = readbyte f #unsigned
  545.  
  546. p5= ReadBEword f
  547. p6= ReadBEword f        
  548.     
  549. tu= readBEHalfFloat f    
  550. tv= readBEHalfFloat f*-1    
  551.  
  552. unk2 = (ReadBEword f/32767.00)
  553. unk3 = (ReadBEword f/32767.00)
  554.  
  555. if weight1==1.00 then
  556. weight2 = 0
  557. weight3 = 0
  558. weight4 = 0
  559.  
  560. p7= readBEHalfFloat f    
  561. p8= readBEHalfFloat f
  562.  
  563. w = (weight_data boneids:#() weights:#())
  564. maxweight = 0
  565. if(weight1 != 0) then
  566.    maxweight = maxweight + weight1
  567. if(weight2 != 0) then
  568.    maxweight = maxweight + weight2
  569. if(weight3 != 0) then
  570.    maxweight = maxweight + weight3
  571. if(weight4 != 0) then
  572.    maxweight = maxweight + weight4
  573.  
  574. if(maxweight != 0) then (
  575.       if(weight1 != 0) then (
  576.          w1 = weight1 as float
  577.          append w.boneids (bone1 + 1)
  578.          append w.weights (w1) 
  579.       )
  580.       if(weight2 != 0) then (
  581.          w2 = weight2 as float
  582.          append w.boneids (bone2 + 1)
  583.          append w.weights (w2) 
  584.       )
  585.       if(weight3 != 0) then (
  586.          w3 = weight3 as float
  587.          append w.boneids (bone3 + 1)
  588.          append w.weights (w3) 
  589.       )
  590.       if(weight4 != 0) then (
  591.          w4 = weight4 as float
  592.          append w.boneids (bone4 + 1)
  593.          append w.weights (w4) 
  594.       )      
  595.    )
  596. append Weight_array w    
  597. append vertArray ([vx,vy,vz]*100)
  598. append UV_array [tu,tv,0]
  599. )
  600.  
  601. ModelEnd=ftell f
  602.  
  603. fseek f faceOffset #seek_set
  604. FaceBuffStart=ftell f
  605. faceStart=(FaceBuffStart+(Mesh_Info[i].FacePos*2))
  606.  
  607. fseek f (FaceBuffStart+(Mesh_Info[i].FacePos*2)) #seek_set
  608.  
  609. StartDirection = -1
  610. f1 = (ReadBEword f+1)
  611. f2 = (ReadBEword f+1) 
  612. FaceDirection = StartDirection
  613. while (ftell f) < (faceStart + ((Mesh_Info[i].FaceCount)*2)) Do (
  614. f3 = (ReadBEword f)
  615. if (f3==0xFFFF) then (
  616. f1 = (ReadBEword f+1)
  617. f2 = (ReadBEword f+1)
  618. FaceDirection = StartDirection 
  619. ) else (
  620. f3 += 1
  621. FaceDirection *= -1
  622. if (f1!=f2)AND(f2!=f3)AND(f3!=f1) then (
  623. if FaceDirection > 0 then append faceArray [(f1),(f2),(f3)]
  624. else append faceArray [(f1),(f3),(f2)]
  625. )
  626. f1 = f2
  627. f2 = f3
  628. )
  629. )
  630.  
  631. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  632.         
  633. try(
  634. msh = mesh vertices:vertArray faces:faceArray
  635. msh.numTVerts = UV_array.count
  636. buildTVFaces msh
  637. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  638. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  639. msh.displayByLayer = false
  640. msh.backfacecull = on
  641. msh.wirecolor = (color 230 200 210)
  642.  
  643. max modify mode
  644. select msh
  645. skinMod = skin ()
  646. addModifier msh skinMod
  647. for i = 1 to BoneCount do
  648. (
  649.     maxbone = BNArr[i] 
  650.     if i != BoneCount then 
  651.         skinOps.addBone skinMod maxbone 0
  652.     else
  653.         skinOps.addBone skinMod maxbone 1
  654. )
  655. modPanel.setCurrentObject skinMod
  656. for i = 1 to (Mesh_Info[i].VertCount) do (
  657.    w = Weight_array[i]
  658.    bi = #() 
  659.    wv = #()
  660.    
  661.    for j = 1 to w.boneids.count do
  662.    (
  663.       boneid = w.boneids[j]
  664.       weight = w.weights[j]
  665.       append bi boneid
  666.       append wv weight
  667.    )   
  668.    
  669.    skinOps.ReplaceVertexWeights skinMod i bi wv
  670.    
  671. )
  672. )catch(format "Error!!\n")
  673. fseek f ModelEnd #seek_set
  674. format "Mesh %\n\tMesh End: %\n\tFace Start: %\n\tVertex Type: %\n\n" i ("0x"+((bit.intAsHex(ModelEnd))as string)) ("0x"+((bit.intAsHex(faceStart))as string)) ((((Mesh_Info[i].VType))as string))
  675. )
  676.     
  677. fclose f