home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 10318 / WWE_2k15.7z / WWE_2k15.ms
Encoding:
Text File  |  2016-01-16  |  18.3 KB  |  679 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. fname = getOpenFileName \
  4. caption:"WWE 2015 [PC] Model File" \
  5. types:"WWEModel File(*.yobj)|*.yobj" \
  6. historyCategory:"WWE Object Presets"
  7. f = fopen fname "rb"
  8.  
  9. fn ReadBEShort fstream = (
  10. short = readshort fstream #unsigned
  11. short = bit.swapBytes short 2 1
  12. b = (bit.get short 16)
  13. for i = 17 to 32 do short = bit.set short i b
  14. return short
  15. )
  16.  
  17. fn PrintOffset Var =
  18. (
  19.         local Var = Var
  20. print ("This is the offset 0x" + (bit.intAsHex Var) as string)
  21.         Var
  22. )
  23.  
  24. fn floatSwap2 f =
  25. (
  26.         i = bit.floatAsInt f
  27.         h = bit.intashex i
  28.         while h.count < 8 do h = "0" + h
  29.        
  30.         s = (substring h 7 2) + (substring h 5 2) + (substring h 3 2) + (substring h 1 2)
  31.         bit.intAsFloat (bit.hexasint s)
  32. )       
  33.  
  34. fn ReadBEword fstream = (
  35. return (bit.swapBytes (readshort fstream #unsigned) 1 2)
  36. )
  37.  
  38.         fn convertTo32 input16 = (
  39.                 inputAsInt = input16
  40.                 sign = bit.get inputAsInt 16
  41.                 exponent = (bit.shift (bit.and inputAsInt (bit.hexasint "7C00")) -10) as integer - 16
  42.                 fraction = bit.and inputAsInt (bit.hexasint "03FF")
  43.                 if sign==true then sign = 1 else sign = 0
  44.                 exponentF = exponent + 127
  45.                 --Ouput 32 bit integer representing a 32 bit float
  46.                 outputAsFloat = bit.or (bit.or (bit.shift fraction 13) (bit.shift exponentF 23)) (bit.shift sign 31)
  47.                 --Output Check 
  48.                 return bit.intasfloat outputasfloat
  49.         )
  50.  
  51. fn ReadBEHalfFloat fstream = (
  52. return convertTo32(ReadBEword fstream)
  53. )
  54.  
  55. fn ReadHalfFloat fstream = (
  56. return convertTo32(readshort fstream#unsigned)
  57. )
  58.  
  59. fn ReadBElong fstream = (
  60. long = readlong fstream
  61. long = bit.swapBytes long 1 4
  62. long = bit.swapBytes long 2 3
  63. return long
  64. )
  65.  
  66. fn ReadBEfloat fstream = (
  67. return floatSwap2(readfloat fstream)
  68. )
  69.  
  70. fn ReadFixedString bstream fixedLen =
  71. (
  72.         local str = ""
  73.         for i = 1 to fixedLen do
  74.         (
  75.                 str += bit.intAsChar (ReadByte bstream #unsigned)
  76.         )
  77.         str
  78. )
  79.  
  80. struct weight_data
  81. (
  82.    boneids,weights
  83. )
  84.  
  85. struct Mesh_Info_Struct
  86. (
  87.    Unk109,Unk107,Objname,VertOff,WeightOff,UVOff,MatPCount,matPOff,FaceOff,FaceSec,VertCount,WeightCount,BtableStart
  88. )
  89. struct Mesh_Info_Struct2
  90. (
  91. Unk102, Unk103, Unk999, Unk108, Unk114
  92. )
  93.  
  94. Idstring = ReadFixedString f 4
  95. Totalsize = ReadBElong f
  96. Unk001 = ReadBElong f
  97. Unk002 = ReadBElong f
  98. Unk003 = ReadBElong f
  99. Unk004 = ReadBElong f
  100. MeshCount = ReadBElong f
  101. MeshOff = ReadBElong f + 8
  102. BoneCount = ReadBElong f
  103. TexCount = ReadBElong f
  104. BoneOffset = ReadBElong f + 8
  105. TexOff = ReadBElong f + 8
  106. MnameOff = ReadBElong f + 8
  107. MnameCount = ReadBElong f
  108. Unk013 = ReadBElong f
  109. Unk014 = ReadBElong f
  110. Unk015 = ReadBElong f
  111. Unk016 = ReadBElong f
  112. fseek f 0x54 #seek_set
  113. BoneMapOff=ReadBElong f+8
  114.  
  115. fseek f BoneOffset#seek_set
  116. tarr = #()
  117. rarr = #()
  118. qarr = #()
  119. Barr = #()
  120. Parr = #()
  121.  
  122. clearlistener()
  123.  
  124. for a = 1 to BoneCount Do (
  125. BoneName = ReadFixedString f 16
  126. tx = ReadBEfloat f
  127. ty = ReadBEfloat f
  128. tz = ReadBEfloat f
  129. tw = ReadBEfloat f
  130. rx = (ReadBEfloat f * 180) / pi
  131. ry = (ReadBEfloat f * 180) / pi
  132. rz = (ReadBEfloat f * 180) / pi
  133. rw = ReadBEfloat f
  134. parent = ReadBElong f
  135. fseek f 0xC#seek_cur
  136. qx = ReadBEfloat f
  137. qy = ReadBEfloat f
  138. qz = ReadBEfloat f
  139. qw = ReadBEfloat f
  140. tfm = (eulerangles rx ry rz) as matrix3
  141. append tarr [tx,ty,tz]
  142. append rarr tfm
  143. append qarr [qx,qy,qz,qw]
  144. append Barr BoneName
  145. append Parr parent
  146. )
  147. BNArr = #()
  148. for a = 1 to BoneCount Do (
  149. if isvalidnode (getNodeByName Barr[a]) != true then (
  150. tfm = rarr[a]
  151. tfm.row4 = tarr[a]
  152. if (Parr[a] != -1) do (
  153. tfm = tfm * BNArr[(Parr[a] + 1)].objecttransform
  154. )
  155. newBone = bonesys.createbone   \
  156.               tfm.row4   \
  157.               (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  158.               (normalize tfm.row3)
  159.          newBone.name = Barr[a]
  160.          newBone.width  = 0.01
  161.          newBone.height = 0.01
  162.          newBone.transform = tfm
  163.          newBone.setBoneEnable false 0
  164.          newBone.wirecolor = yellow
  165.          newbone.showlinks = true
  166.          newBone.pos.controller      = TCB_position ()
  167.          newBone.rotation.controller = TCB_rotation ()
  168.               )
  169. if isvalidnode (getNodeByName Barr[a]) == true then (
  170. newBone = getNodeByName Barr[a]
  171. )
  172. if (Parr[a] != -1) then
  173. newBone.parent = BNArr[(Parr[a] + 1)]
  174. append BNArr newBone
  175.  
  176. )
  177.  
  178. rootRT = dummy name:"Main_Root" boxsize:[.1,.1,.1]
  179. for b in BNArr where b.parent==undefined do b.parent = rootRT
  180. rootRT.transform = (matrix3 [1,0,0] [0,0,-1] [0,1,0] [0,0,0])
  181.  
  182. Print ("Bone End @ 0x"+((bit.intAsHex(ftell f))as string))    
  183.  
  184. fseek f MeshOff#seek_set
  185. Mesh_Info_Arr = #()
  186. Mesh_Info_Arr2 = #()    
  187. for a = 1 to MeshCount Do (
  188. VCount1 = ReadBElong f
  189. FaceSec = ReadBElong f
  190. BtableStart = (ftell f)
  191. UsedBoneID = ReadBElong f
  192. fseek f 0x50#seek_cur
  193. WeightCount = ReadBElong f
  194. Unk102 = ReadBElong f
  195. Unk103 = ReadBElong f
  196. VertOff = ReadBElong f + 8
  197. WeightOff = ReadBElong f + 8
  198. UVOff = ReadBElong f + 8
  199. Unk999 = ReadBElong f
  200. Unk107 = ReadBElong f
  201. Objname = ReadFixedString f 16
  202. Unk108 = ReadBElong f
  203. Unk109 = ReadBElong f
  204. MatPCount = ReadBElong f
  205. matPOff = ReadBElong f + 8
  206. FaceOff = ReadBElong f + 8
  207. VertCount = ReadBElong f
  208. Unk114 = ReadBElong f
  209. fseek f 0x10#seek_cur
  210. append Mesh_Info_Arr (Mesh_Info_Struct Unk109:Unk109 Unk107:Unk107 Objname:Objname VertOff:VertOff WeightOff:WeightOff UVOff:UVOff MatPCount:MatPCount matPOff:matPOff FaceOff:FaceOff FaceSec:FaceSec VertCount:VertCount WeightCount:WeightCount BtableStart:BtableStart )
  211. append Mesh_Info_Arr2 (Mesh_Info_Struct2 Unk102:Unk102 Unk103:Unk103 Unk999:Unk999 Unk108:Unk108 Unk114:Unk114)
  212. )
  213.  
  214. print Mesh_Info_Arr
  215. print Mesh_Info_Arr2
  216.  
  217. fseek f BoneMapOff #seek_set
  218. Print ("Bone Map @ 0x"+((bit.intAsHex(ftell f))as string))    
  219. usedID = ReadBElong f
  220. BoneMapOffset = ReadBElong f    
  221. Used_Bone_array = #()
  222. for b = 1 to usedID do (
  223. bid = ReadBElong f+1
  224. append Used_Bone_array bid
  225. )
  226.  
  227. print (usedID  as string)
  228.  
  229. for a = 1 to MeshCount Do (
  230. Vert_array = #()
  231. Normal_array = #()
  232. UV_array = #()
  233. Face_array = #()
  234. Weight_array = #()
  235.  
  236. fseek f Mesh_Info_Arr[a].VertOff#seek_set
  237. scale1 = 10
  238. VertOff = ReadBElong f + 8
  239. print VertOff
  240. fseek f VertOff#seek_set   
  241. for b = 1 to Mesh_Info_Arr[a].VertCount Do (
  242. vx = ReadBEfloat f
  243. vy = ReadBEfloat f
  244. vz = ReadBEfloat f
  245. fseek f 0x10#seek_cur
  246. append Vert_array [vx,vz,-vy]
  247. )
  248.  
  249. fseek f Mesh_Info_Arr[a].UVOff#seek_set
  250. for b = 1 to Mesh_Info_Arr[a].VertCount Do (
  251. tu = ReadBEfloat f
  252. tv = ReadBEfloat f * -1
  253. append UV_array [tu,tv,0]
  254. )
  255.  
  256. fseek f Mesh_Info_Arr[a].WeightOff#seek_set
  257. Print ("Weight Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  258. for b = 1 to Mesh_Info_Arr[a].VertCount Do (
  259. Bone1 = 65535
  260. Bone2 = 65535
  261. Bone3 = 65535
  262. Bone4 = 65535
  263. Bone5 = 65535
  264. Bone6 = 65535
  265. Bone7 = 65535
  266. if Mesh_Info_Arr2[a].Unk114==0 then    
  267. if Mesh_Info_Arr[a].WeightCount == 1 do (
  268. Bone1=Readshort    f#unsigned 
  269. fseek f 0x2#seek_cur    
  270. Weight1 = ReadBEfloat f
  271. if Bone1<0 or Bone1>usedID then Bone1=65535        
  272. )
  273. if Mesh_Info_Arr2[a].Unk114!=0    then 
  274. if Mesh_Info_Arr[a].WeightCount == 1 do (
  275. Bone1 = readBEshort f
  276. fseek f 0x2#seek_cur    
  277. Weight1 = ReadBEfloat f
  278. if Bone1<0 or Bone1>usedID then Bone1=65535        
  279. )
  280. if Mesh_Info_Arr2[a].Unk114==0 then    
  281. if Mesh_Info_Arr[a].WeightCount == 2 do (
  282. Bone1=Readshort    f#unsigned 
  283. if Bone1<0 or Bone1>usedID then Bone1=65535    
  284. fseek f 0x2#seek_cur    
  285. Weight1 = ReadBEfloat f
  286. Bone2=Readshort    f#unsigned 
  287. if Bone2<0 or Bone2>usedID then Bone2=65535        
  288. fseek f 0x2#seek_cur    
  289. Weight2 = ReadBEfloat f
  290. )
  291. if Mesh_Info_Arr2[a].Unk114!=0 then    
  292. if Mesh_Info_Arr[a].WeightCount == 2 do (
  293. Bone1=ReadBEshort    f
  294. if Bone1<0 or Bone1>usedID then Bone1=65535    
  295. fseek f 0x2#seek_cur    
  296. Weight1 = ReadBEfloat f
  297. Bone2=ReadBEshort    f
  298. if Bone2<0 or Bone2>usedID then Bone2=65535        
  299. fseek f 0x2#seek_cur    
  300. Weight2 = ReadBEfloat f
  301. )
  302. if Mesh_Info_Arr2[a].Unk114==0 then    
  303. if Mesh_Info_Arr[a].WeightCount == 3 do (
  304. Bone1=Readshort    f#unsigned 
  305. if Bone1<0 or Bone1>usedID then Bone1=65535                
  306. fseek f 0x2#seek_cur    
  307. Weight1 = ReadBEfloat f
  308. Bone2=Readshort    f#unsigned  
  309. if Bone2<0 or Bone2>usedID then Bone2=65535            
  310. fseek f 0x2#seek_cur    
  311. Weight2 = ReadBEfloat f
  312. Bone3=Readshort    f#unsigned 
  313. if Bone3<0 or Bone3>usedID then Bone3=65535            
  314. fseek f 0x2#seek_cur    
  315. Weight3 = ReadBEfloat f
  316. )
  317. if Mesh_Info_Arr2[a].Unk114!=0 then    
  318. if Mesh_Info_Arr[a].WeightCount == 3 do (
  319. Bone1=ReadBEshort    f
  320. if Bone1<0 or Bone1>usedID then Bone1=65535            
  321. fseek f 0x2#seek_cur    
  322. Weight1 = ReadBEfloat f
  323. Bone2=ReadBEshort    f 
  324. if Bone2<0 or Bone2>usedID then Bone2=65535            
  325. fseek f 0x2#seek_cur    
  326. Weight2 = ReadBEfloat f
  327. Bone3=ReadBEshort    f
  328. if Bone3<0 or Bone3>usedID then Bone3=65535            
  329. fseek f 0x2#seek_cur    
  330. Weight3 = ReadBEfloat f
  331. )
  332. if Mesh_Info_Arr2[a].Unk114==0 then    
  333. if Mesh_Info_Arr[a].WeightCount == 4 do (
  334. Bone1=Readshort    f#unsigned 
  335. if Bone1<0 or Bone1>usedID then Bone1=65535                
  336. fseek f 0x2#seek_cur    
  337. Weight1 = ReadBEfloat f
  338. Bone2=Readshort    f#unsigned  
  339. if Bone2<0 or Bone2>usedID then Bone2=65535            
  340. fseek f 0x2#seek_cur    
  341. Weight2 = ReadBEfloat f
  342. Bone3=Readshort    f#unsigned 
  343. if Bone3<0 or Bone3>usedID then Bone3=65535            
  344. fseek f 0x2#seek_cur    
  345. Weight3 = ReadBEfloat f
  346. Bone4=Readshort    f#unsigned 
  347. if Bone4<0 or Bone4>usedID then Bone4=65535            
  348. fseek f 0x2#seek_cur    
  349. Weight4 = ReadBEfloat f
  350. )
  351. if Mesh_Info_Arr2[a].Unk114!=0 then    
  352. if Mesh_Info_Arr[a].WeightCount == 4 do (
  353. Bone1=ReadBEshort    f
  354. if Bone1<0 or Bone1>usedID then Bone1=65535            
  355. fseek f 0x2#seek_cur    
  356. Weight1 = ReadBEfloat f
  357. Bone2=ReadBEshort    f 
  358. if Bone2<0 or Bone2>usedID then Bone2=65535            
  359. fseek f 0x2#seek_cur    
  360. Weight2 = ReadBEfloat f
  361. Bone3=ReadBEshort    f
  362. if Bone3<0 or Bone3>usedID then Bone3=65535            
  363. fseek f 0x2#seek_cur    
  364. Weight3 = ReadBEfloat f
  365. Bone4=ReadBEshort    f
  366. if Bone4<0 or Bone4>usedID then Bone4=65535            
  367. fseek f 0x2#seek_cur    
  368. Weight4 = ReadBEfloat f
  369. )
  370. if Mesh_Info_Arr2[a].Unk114==0 then    
  371. if Mesh_Info_Arr[a].WeightCount == 5 do (
  372. Bone1=Readshort    f#unsigned 
  373. if Bone1<0 or Bone1>usedID then Bone1=65535                
  374. fseek f 0x2#seek_cur    
  375. Weight1 = ReadBEfloat f
  376. Bone2=Readshort    f#unsigned  
  377. if Bone2<0 or Bone2>usedID then Bone2=65535            
  378. fseek f 0x2#seek_cur    
  379. Weight2 = ReadBEfloat f
  380. Bone3=Readshort    f#unsigned 
  381. if Bone3<0 or Bone3>usedID then Bone3=65535            
  382. fseek f 0x2#seek_cur    
  383. Weight3 = ReadBEfloat f
  384. Bone4=Readshort    f#unsigned 
  385. if Bone4<0 or Bone4>usedID then Bone4=65535            
  386. fseek f 0x2#seek_cur    
  387. Weight4 = ReadBEfloat f
  388. Bone5=Readshort    f#unsigned 
  389. if Bone5<0 or Bone5>usedID then Bone5=65535            
  390. fseek f 0x2#seek_cur    
  391. Weight5 = ReadBEfloat f
  392. )
  393. if Mesh_Info_Arr2[a].Unk114!=0 then    
  394. if Mesh_Info_Arr[a].WeightCount == 5 do (
  395. Bone1=ReadBEshort    f
  396. if Bone1<0 or Bone1>usedID then Bone1=65535            
  397. fseek f 0x2#seek_cur    
  398. Weight1 = ReadBEfloat f
  399. Bone2=ReadBEshort    f 
  400. if Bone2<0 or Bone2>usedID then Bone2=65535            
  401. fseek f 0x2#seek_cur    
  402. Weight2 = ReadBEfloat f
  403. Bone3=ReadBEshort    f
  404. if Bone3<0 or Bone3>usedID then Bone3=65535            
  405. fseek f 0x2#seek_cur    
  406. Weight3 = ReadBEfloat f
  407. Bone4=ReadBEshort    f
  408. if Bone4<0 or Bone4>usedID then Bone4=65535            
  409. fseek f 0x2#seek_cur    
  410. Weight4 = ReadBEfloat f
  411. Bone5=ReadBEshort    f
  412. if Bone5<0 or Bone5>usedID then Bone5=65535            
  413. fseek f 0x2#seek_cur    
  414. Weight5 = ReadBEfloat f
  415. )
  416. if Mesh_Info_Arr2[a].Unk114==0 then    
  417. if Mesh_Info_Arr[a].WeightCount == 6 do (
  418. Bone1=Readshort    f#unsigned 
  419. if Bone1<0 or Bone1>usedID then Bone1=65535                
  420. fseek f 0x2#seek_cur    
  421. Weight1 = ReadBEfloat f
  422. Bone2=Readshort    f#unsigned  
  423. if Bone2<0 or Bone2>usedID then Bone2=65535            
  424. fseek f 0x2#seek_cur    
  425. Weight2 = ReadBEfloat f
  426. Bone3=Readshort    f#unsigned 
  427. if Bone3<0 or Bone3>usedID then Bone3=65535            
  428. fseek f 0x2#seek_cur    
  429. Weight3 = ReadBEfloat f
  430. Bone4=Readshort    f#unsigned 
  431. if Bone4<0 or Bone4>usedID then Bone4=65535            
  432. fseek f 0x2#seek_cur    
  433. Weight4 = ReadBEfloat f
  434. Bone5=Readshort    f#unsigned 
  435. if Bone5<0 or Bone5>usedID then Bone5=65535            
  436. fseek f 0x2#seek_cur    
  437. Weight5 = ReadBEfloat f
  438. Bone6=Readshort    f#unsigned 
  439. if Bone6<0 or Bone6>usedID then Bone6=65535            
  440. fseek f 0x2#seek_cur    
  441. Weight6 = ReadBEfloat f
  442. )
  443. if Mesh_Info_Arr2[a].Unk114!=0 then    
  444. if Mesh_Info_Arr[a].WeightCount == 6 do (
  445. Bone1=ReadBEshort    f
  446. if Bone1<0 or Bone1>usedID then Bone1=65535            
  447. fseek f 0x2#seek_cur    
  448. Weight1 = ReadBEfloat f
  449. Bone2=ReadBEshort    f 
  450. if Bone2<0 or Bone2>usedID then Bone2=65535            
  451. fseek f 0x2#seek_cur    
  452. Weight2 = ReadBEfloat f
  453. Bone3=ReadBEshort    f
  454. if Bone3<0 or Bone3>usedID then Bone3=65535            
  455. fseek f 0x2#seek_cur    
  456. Weight3 = ReadBEfloat f
  457. Bone4=ReadBEshort    f
  458. if Bone4<0 or Bone4>usedID then Bone4=65535            
  459. fseek f 0x2#seek_cur    
  460. Weight4 = ReadBEfloat f
  461. Bone5=ReadBEshort    f
  462. if Bone5<0 or Bone5>usedID then Bone5=65535            
  463. fseek f 0x2#seek_cur    
  464. Weight5 = ReadBEfloat f
  465. Bone6=ReadBEshort    f
  466. if Bone6<0 or Bone6>usedID then Bone6=65535            
  467. fseek f 0x2#seek_cur    
  468. Weight6 = ReadBEfloat f
  469. )
  470. if Mesh_Info_Arr2[a].Unk114==0 then    
  471. if Mesh_Info_Arr[a].WeightCount == 7 do (
  472. Bone1=Readshort    f#unsigned 
  473. if Bone1<0 or Bone1>usedID then Bone1=65535                
  474. fseek f 0x2#seek_cur    
  475. Weight1 = ReadBEfloat f
  476. Bone2=Readshort    f#unsigned  
  477. if Bone2<0 or Bone2>usedID then Bone2=65535            
  478. fseek f 0x2#seek_cur    
  479. Weight2 = ReadBEfloat f
  480. Bone3=Readshort    f#unsigned 
  481. if Bone3<0 or Bone3>usedID then Bone3=65535            
  482. fseek f 0x2#seek_cur    
  483. Weight3 = ReadBEfloat f
  484. Bone4=Readshort    f#unsigned 
  485. if Bone4<0 or Bone4>usedID then Bone4=65535            
  486. fseek f 0x2#seek_cur    
  487. Weight4 = ReadBEfloat f
  488. Bone5=Readshort    f#unsigned 
  489. if Bone5<0 or Bone5>usedID then Bone5=65535            
  490. fseek f 0x2#seek_cur    
  491. Weight5 = ReadBEfloat f
  492. Bone6=Readshort    f#unsigned 
  493. if Bone6<0 or Bone6>usedID then Bone6=65535            
  494. fseek f 0x2#seek_cur    
  495. Weight6 = ReadBEfloat f
  496. Bone7=Readshort    f#unsigned 
  497. if Bone7<0 or Bone7>usedID then Bone7=65535            
  498. fseek f 0x2#seek_cur    
  499. Weight7 = ReadBEfloat f
  500. )
  501. if Mesh_Info_Arr2[a].Unk114!=0 then    
  502. if Mesh_Info_Arr[a].WeightCount == 7 do (
  503. Bone1=ReadBEshort    f
  504. if Bone1<0 or Bone1>usedID then Bone1=65535            
  505. fseek f 0x2#seek_cur    
  506. Weight1 = ReadBEfloat f
  507. Bone2=ReadBEshort    f 
  508. if Bone2<0 or Bone2>usedID then Bone2=65535            
  509. fseek f 0x2#seek_cur    
  510. Weight2 = ReadBEfloat f
  511. Bone3=ReadBEshort    f
  512. if Bone3<0 or Bone3>usedID then Bone3=65535            
  513. fseek f 0x2#seek_cur    
  514. Weight3 = ReadBEfloat f
  515. Bone4=ReadBEshort    f
  516. if Bone4<0 or Bone4>usedID then Bone4=65535            
  517. fseek f 0x2#seek_cur    
  518. Weight4 = ReadBEfloat f
  519. Bone5=ReadBEshort    f
  520. if Bone5<0 or Bone5>usedID then Bone5=65535            
  521. fseek f 0x2#seek_cur    
  522. Weight5 = ReadBEfloat f
  523. Bone6=ReadBEshort    f
  524. if Bone6<0 or Bone6>usedID then Bone6=65535            
  525. fseek f 0x2#seek_cur    
  526. Weight6 = ReadBEfloat f
  527. Bone7=ReadBEshort    f
  528. if Bone7<0 or Bone7>usedID then Bone7=65535            
  529. fseek f 0x2#seek_cur    
  530. Weight7 = ReadBEfloat f
  531. )
  532.  
  533. w = (weight_data boneids:#() weights:#())
  534. maxweight = 0        
  535. if(Bone1 != 65535) then (
  536. if(weight1 != 0) then    
  537.    maxweight = maxweight + weight1
  538. )    
  539. if(Bone2 != 65535) then (
  540. if(weight2 != 0) then        
  541.    maxweight = maxweight + weight2
  542. )
  543. if(Bone3 != 65535) then (
  544. if(weight3 != 0) then    
  545.    maxweight = maxweight + weight3
  546. )
  547. if(Bone4 != 65535) then (
  548. if(weigh4 != 0) then        
  549.    maxweight = maxweight + weight4
  550. )    
  551. if(Bone5 != 65535) then (
  552. if(weight5 != 0) then        
  553.    maxweight = maxweight + weight5
  554. )    
  555. if(Bone6 != 65535) then (
  556. if(weight6 != 0) then        
  557.    maxweight = maxweight + weight6
  558. )
  559. if(Bone7 != 65535) then (
  560. if(weight7 != 0) then        
  561.    maxweight = maxweight + weight7
  562. )    
  563. if(maxweight != 0) then (
  564.       if(Bone1 != 65535) then (
  565.          w1 = weight1 as float
  566.          append w.boneids (bone1 + 1)
  567.          append w.weights w1
  568.       )
  569.       if(Bone2 != 65535) then (
  570.          w2 = weight2 as float
  571.          append w.boneids (bone2 + 1)
  572.          append w.weights w2
  573.       )
  574.       if(Bone3 != 65535) then (
  575.          w3 = weight3 as float
  576.          append w.boneids (bone3 + 1)
  577.          append w.weights w3
  578.       )  
  579.       if(Bone4 != 65535) then (
  580.          w4 = weight4 as float
  581.          append w.boneids (bone4 + 1)
  582.          append w.weights w4
  583.       )  
  584.       if(Bone5 != 65535) then (
  585.          w5 = weight5 as float
  586.          append w.boneids (bone5 + 1)
  587.          append w.weights w5
  588.       )        
  589.       if(Bone6 != 65535) then (
  590.          w6 = weight6 as float
  591.          append w.boneids (bone6 + 1)
  592.          append w.weights w6
  593.       )    
  594.       if(Bone7 != 65535) then (
  595.          w7 = weight7 as float
  596.          append w.boneids (bone7 + 1)
  597.          append w.weights w7
  598.       )      
  599.    )
  600. append Weight_array w
  601. )
  602.  
  603. fseek f Mesh_Info_Arr[a].FaceOff#seek_set
  604. Ftmp = #()
  605. for b = 1 to Mesh_Info_Arr[a].FaceSec Do (
  606. FSize = ReadBElong f as float
  607. FCount = ReadBElong f as float
  608. FStart = (ReadBElong f + 8) as float
  609. append Ftmp [FSize,FCount,FStart]
  610. )
  611. for b = 1 to Mesh_Info_Arr[a].FaceSec Do (
  612. fseek f Ftmp[b].z#seek_set
  613. FaceEnd = ((ftell f) + (2 * Ftmp[b].y))
  614. StartDirection = 1
  615. Face_array2 = #()
  616. f1 = ReadBEword f + 1
  617. f2 = ReadBEword f + 1
  618. FaceDirection = StartDirection
  619. do (
  620. f3 = ReadBEword f
  621. if (f3==0xFFFF) then (
  622. f1 = ReadBEword f + 1
  623. f2 = ReadBEword f + 1
  624. FaceDirection = StartDirection   
  625. ) else (
  626. f3 += 1
  627. FaceDirection *= -1
  628. if (f1!=f2)AND(f2!=f3)AND(f3!=f1) then (
  629. append Face_array2 [(f1),(f2),(f3)]
  630. if FaceDirection > 0 then append Face_array [(f1),(f2),(f3)]
  631. else append Face_array [(f1),(f3),(f2)]
  632. )
  633. f1 = f2
  634. f2 = f3
  635. )
  636. )while (ftell f) < (FaceEnd)
  637. )
  638.  
  639. try(
  640. msh = mesh vertices:Vert_array faces:Face_array
  641. msh.numTVerts = UV_array.count
  642. buildTVFaces msh
  643. msh.name = Mesh_Info_Arr[a].Objname
  644. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  645. for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
  646. for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]
  647.  
  648. max modify mode
  649. select msh
  650. skinMod = skin ()
  651. addModifier msh skinMod
  652. for i = 1 to Used_Bone_array.count do
  653. (
  654.     maxbone = BNArr[(Used_Bone_array[i])]
  655.     if i != Used_Bone_array.count then 
  656.         skinOps.addBone skinMod maxbone 0
  657.     else
  658.         skinOps.addBone skinMod maxbone 1
  659. )
  660. modPanel.setCurrentObject skinMod
  661. for i = 1 to Vert_array.count do (
  662.    w = Weight_array[i]
  663.    bi = #() --bone index array
  664.    wv = #() --weight value array
  665.    
  666.    for j = 1 to w.boneids.count do
  667.    (
  668.       boneid = w.boneids[j]
  669.       weight = w.weights[j]
  670.       append bi boneid
  671.       append wv weight
  672.    )   
  673.    
  674.    skinOps.ReplaceVertexWeights skinMod i bi wv
  675. )
  676. )catch(format "Wrong Skel or Messed Bones!!\n")
  677. )
  678.  
  679. fclose f