home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 13562 / WWE_2k18_PC_Exclusive.7z / WWE_2k18_PC_Exclusive.ms
Encoding:
Text File  |  2017-11-18  |  23.0 KB  |  836 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 1 (*.yobj)|*.yobj|WWEModel File 2 (*.yob)|*.yob|WWEModel File 3 (*.jbo)|*.jbo" \
  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. Print ("Bone Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  125.  
  126. for a = 1 to BoneCount Do (
  127. BoneName = ReadFixedString f 16
  128. tx = ReadBEfloat f
  129. ty = ReadBEfloat f
  130. tz = ReadBEfloat f
  131. tw = ReadBEfloat f
  132. rx = (ReadBEfloat f * 180) / pi
  133. ry = (ReadBEfloat f * 180) / pi
  134. rz = (ReadBEfloat f * 180) / pi
  135. rw = ReadBEfloat f
  136. parent = ReadBElong f
  137. fseek f 0xC#seek_cur
  138. qx = ReadBEfloat f
  139. qy = ReadBEfloat f
  140. qz = ReadBEfloat f
  141. qw = ReadBEfloat f
  142. tfm = (eulerangles rx ry rz) as matrix3
  143. append tarr [tx,ty,tz]
  144. append rarr tfm
  145. append qarr [qx,qy,qz,qw]
  146. append Barr BoneName
  147. append Parr parent
  148. )
  149. BNArr = #()
  150. for a = 1 to BoneCount Do (
  151. if isvalidnode (getNodeByName Barr[a]) != true then (
  152. tfm = rarr[a]
  153. tfm.row4 = tarr[a]
  154. if (Parr[a] != -1) do (
  155. tfm = tfm * BNArr[(Parr[a] + 1)].objecttransform
  156. )
  157. newBone = bonesys.createbone   \
  158.               tfm.row4   \
  159.               (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  160.               (normalize tfm.row3)
  161.          newBone.name = Barr[a]
  162.          newBone.width  = 0.01
  163.          newBone.height = 0.01
  164.          newBone.transform = tfm
  165.          newBone.setBoneEnable false 0
  166.          newBone.wirecolor = yellow
  167.          newbone.showlinks = true
  168.          newBone.pos.controller      = TCB_position ()
  169.          newBone.rotation.controller = TCB_rotation ()
  170.               )
  171. if isvalidnode (getNodeByName Barr[a]) == true then (
  172. newBone = getNodeByName Barr[a]
  173. )
  174. if (Parr[a] != -1) then
  175. newBone.parent = BNArr[(Parr[a] + 1)]
  176. append BNArr newBone
  177.  
  178. )
  179.  
  180. rootRT = dummy name:"Main_Root" boxsize:[.1,.1,.1]
  181. for b in BNArr where b.parent==undefined do b.parent = rootRT
  182. rootRT.transform = (matrix3 [1,0,0] [0,0,-1] [0,1,0] [0,0,0])
  183.  
  184. Print ("Bone End @ 0x"+((bit.intAsHex(ftell f))as string))    
  185.  
  186. fseek f MeshOff#seek_set
  187. Mesh_Info_Arr = #()
  188. Mesh_Info_Arr2 = #()    
  189. for a = 1 to MeshCount Do (
  190. VCount1 = ReadBElong f
  191. FaceSec = ReadBElong f
  192. BtableStart = (ftell f)
  193. UsedBoneID = ReadBElong f
  194. fseek f 0x50#seek_cur
  195. WeightCount = ReadBElong f
  196. Unk102 = ReadBElong f
  197. Unk103 = ReadBElong f
  198. VertOff = ReadBElong f + 8
  199. WeightOff = ReadBElong f + 8
  200. UVOff = ReadBElong f + 8
  201. Unk999 = ReadBElong f
  202. Unk107 = ReadBElong f
  203. Objname = ReadFixedString f 16
  204. Unk108 = ReadBElong f
  205. Unk109 = ReadBElong f
  206. MatPCount = ReadBElong f
  207. matPOff = ReadBElong f + 8
  208. FaceOff = ReadBElong f + 8
  209. VertCount = ReadBElong f
  210. Unk114 = ReadBElong f
  211. fseek f 0x10#seek_cur
  212. 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 )
  213. append Mesh_Info_Arr2 (Mesh_Info_Struct2 Unk102:Unk102 Unk103:Unk103 Unk999:Unk999 Unk108:Unk108 Unk114:Unk114)
  214. )
  215.  
  216. print Mesh_Info_Arr
  217. print Mesh_Info_Arr2
  218.  
  219. fseek f BoneMapOff #seek_set
  220. Print ("Bone Map @ 0x"+((bit.intAsHex(ftell f))as string))    
  221. usedID = ReadBElong f
  222. BoneMapOffset = ReadBElong f
  223. Pos1=ftell f        
  224. Check=ReadBElong f
  225. if Check!=0 then fseek f Pos1 #seek_set
  226. if Check==0 then (
  227. fseek f 0x0#seek_cur    
  228. Pos2=ftell f    
  229. Check1=ReadBElong f    
  230. if Check1==0 then fseek f 0x0#seek_cur
  231. if Check1!=0 then fseek f Pos2 #seek_set
  232. )    
  233. Used_Bone_array = #()
  234. for b = 1 to usedID do (
  235. bid = ReadBElong f+1
  236. append Used_Bone_array bid
  237. )
  238.  
  239. print (usedID  as string)
  240.  
  241. for a = 1 to MeshCount Do (
  242. Vert_array = #()
  243. Normal_array = #()
  244. UV_array = #()
  245. Face_array = #()
  246. Weight_array = #()
  247.  
  248. fseek f Mesh_Info_Arr[a].VertOff#seek_set
  249. scale1 = 10
  250. VertOff = ReadBElong f + 8
  251. print VertOff
  252. fseek f VertOff#seek_set   
  253. for b = 1 to Mesh_Info_Arr[a].VertCount Do (
  254. vx = ReadBEfloat f
  255. vy = ReadBEfloat f
  256. vz = ReadBEfloat f
  257. fseek f 0x10#seek_cur
  258. append Vert_array [vx,vz,-vy]
  259. )
  260.  
  261. fseek f Mesh_Info_Arr[a].UVOff#seek_set
  262. Print ("Uv's Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  263. if Mesh_Info_Arr2[a].Unk114==320 then 
  264. for b = 1 to Mesh_Info_Arr[a].VertCount Do (
  265. tu = ReadBEfloat f
  266. tv = ReadBEfloat f* -1
  267. ReadBEfloat f
  268. ReadBEfloat f    
  269. append UV_array [tu,tv,0]
  270. )
  271. if Mesh_Info_Arr2[a].Unk114!=320 then 
  272. for b = 1 to Mesh_Info_Arr[a].VertCount Do (
  273. tu = ReadBEfloat f
  274. tv = ReadBEfloat f * -1
  275. append UV_array [tu,tv,0]
  276. )
  277.  
  278. print ("This is Endianness Type: "+Mesh_Info_Arr2[a].Unk114 as string)
  279. print ("This is Weight Size: "+Mesh_Info_Arr[a].WeightCount as string)
  280.  
  281. fseek f Mesh_Info_Arr[a].WeightOff#seek_set
  282. Print ("Weight Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  283. for b = 1 to Mesh_Info_Arr[a].VertCount Do (
  284. Bone1 = 65535
  285. Bone2 = 65535
  286. Bone3 = 65535
  287. Bone4 = 65535
  288. Bone5 = 65535
  289. Bone6 = 65535
  290. Bone7 = 65535
  291. Bone8 = 65535    
  292. if Mesh_Info_Arr2[a].Unk114==64 then    
  293. if Mesh_Info_Arr[a].WeightCount == 1 do (
  294. Bone1=Readshort    f#unsigned 
  295. fseek f 0x2#seek_cur    
  296. Weight1 = ReadBEfloat f
  297. if Bone1<0 or Bone1>usedID then Bone1=65535        
  298. )
  299. if Mesh_Info_Arr2[a].Unk114==192 then 
  300. if Mesh_Info_Arr[a].WeightCount == 1 do (
  301. Bone1 = readBEshort f
  302. fseek f 0x2#seek_cur    
  303. Weight1 = ReadBEfloat f
  304. if Bone1<0 or Bone1>usedID then Bone1=65535        
  305. )
  306. if Mesh_Info_Arr2[a].Unk114==320 then 
  307. if Mesh_Info_Arr[a].WeightCount == 1 do (
  308. Bone1 = readshort f
  309. fseek f 0x2#seek_cur    
  310. Weight1 = ReadBEfloat f
  311. if Bone1<0 or Bone1>BoneCount then Bone1=65535        
  312. )
  313. if Mesh_Info_Arr2[a].Unk114==64 then    
  314. if Mesh_Info_Arr[a].WeightCount == 2 do (
  315. Bone1=Readshort    f#unsigned 
  316. if Bone1<0 or Bone1>usedID then Bone1=65535    
  317. fseek f 0x2#seek_cur    
  318. Weight1 = ReadBEfloat f
  319. Bone2=Readshort    f#unsigned 
  320. if Bone2<0 or Bone2>usedID then Bone2=65535        
  321. fseek f 0x2#seek_cur    
  322. Weight2 = ReadBEfloat f
  323. )
  324. if Mesh_Info_Arr2[a].Unk114==192 then    
  325. if Mesh_Info_Arr[a].WeightCount == 2 do (
  326. Bone1=ReadBEshort    f
  327. if Bone1<0 or Bone1>usedID then Bone1=65535    
  328. fseek f 0x2#seek_cur    
  329. Weight1 = ReadBEfloat f
  330. Bone2=ReadBEshort    f
  331. if Bone2<0 or Bone2>usedID then Bone2=65535        
  332. fseek f 0x2#seek_cur    
  333. Weight2 = ReadBEfloat f
  334. )
  335. if Mesh_Info_Arr2[a].Unk114==320 then    
  336. if Mesh_Info_Arr[a].WeightCount == 2 do (
  337. Bone1=Readshort    f#unsigned 
  338. if Bone1<0 or Bone1>BoneCount then Bone1=65535    
  339. fseek f 0x2#seek_cur    
  340. Weight1 = ReadBEfloat f
  341. Bone2=Readshort    f#unsigned 
  342. if Bone2<0 or Bone2>BoneCount then Bone2=65535        
  343. fseek f 0x2#seek_cur    
  344. Weight2 = ReadBEfloat f
  345. )
  346. if Mesh_Info_Arr2[a].Unk114==64 then    
  347. if Mesh_Info_Arr[a].WeightCount == 3 do (
  348. Bone1=Readshort    f#unsigned 
  349. if Bone1<0 or Bone1>usedID then Bone1=65535                
  350. fseek f 0x2#seek_cur    
  351. Weight1 = ReadBEfloat f
  352. Bone2=Readshort    f#unsigned  
  353. if Bone2<0 or Bone2>usedID then Bone2=65535            
  354. fseek f 0x2#seek_cur    
  355. Weight2 = ReadBEfloat f
  356. Bone3=Readshort    f#unsigned 
  357. if Bone3<0 or Bone3>usedID then Bone3=65535            
  358. fseek f 0x2#seek_cur    
  359. Weight3 = ReadBEfloat f
  360. )
  361. if Mesh_Info_Arr2[a].Unk114==192 then    
  362. if Mesh_Info_Arr[a].WeightCount == 3 do (
  363. Bone1=ReadBEshort    f
  364. if Bone1<0 or Bone1>usedID then Bone1=65535            
  365. fseek f 0x2#seek_cur    
  366. Weight1 = ReadBEfloat f
  367. Bone2=ReadBEshort    f 
  368. if Bone2<0 or Bone2>usedID then Bone2=65535            
  369. fseek f 0x2#seek_cur    
  370. Weight2 = ReadBEfloat f
  371. Bone3=ReadBEshort    f
  372. if Bone3<0 or Bone3>usedID then Bone3=65535            
  373. fseek f 0x2#seek_cur    
  374. Weight3 = ReadBEfloat f
  375. )
  376. if Mesh_Info_Arr2[a].Unk114==320 then    
  377. if Mesh_Info_Arr[a].WeightCount == 3 do (
  378. Bone1=Readshort    f#unsigned 
  379. if Bone1<0 or Bone1>BoneCount then Bone1=65535    
  380. fseek f 0x2#seek_cur    
  381. Weight1 = ReadBEfloat f
  382. Bone2=Readshort    f#unsigned 
  383. if Bone2<0 or Bone2>BoneCount then Bone2=65535        
  384. fseek f 0x2#seek_cur    
  385. Weight2 = ReadBEfloat f
  386. Bone3=Readshort    f#unsigned 
  387. if Bone3<0 or Bone3>BoneCount then Bone3=65535        
  388. fseek f 0x2#seek_cur    
  389. Weight3 = ReadBEfloat f
  390. )
  391. if Mesh_Info_Arr2[a].Unk114==64 then    
  392. if Mesh_Info_Arr[a].WeightCount == 4 do (
  393. Bone1=Readshort    f#unsigned 
  394. if Bone1<0 or Bone1>usedID then Bone1=65535                
  395. fseek f 0x2#seek_cur    
  396. Weight1 = ReadBEfloat f
  397. Bone2=Readshort    f#unsigned  
  398. if Bone2<0 or Bone2>usedID then Bone2=65535            
  399. fseek f 0x2#seek_cur    
  400. Weight2 = ReadBEfloat f
  401. Bone3=Readshort    f#unsigned 
  402. if Bone3<0 or Bone3>usedID then Bone3=65535            
  403. fseek f 0x2#seek_cur    
  404. Weight3 = ReadBEfloat f
  405. Bone4=Readshort    f#unsigned 
  406. if Bone4<0 or Bone4>usedID then Bone4=65535            
  407. fseek f 0x2#seek_cur    
  408. Weight4 = ReadBEfloat f
  409. )
  410. if Mesh_Info_Arr2[a].Unk114==192 then    
  411. if Mesh_Info_Arr[a].WeightCount == 4 do (
  412. Bone1=ReadBEshort    f
  413. if Bone1<0 or Bone1>BoneCount then Bone1=65535            
  414. fseek f 0x2#seek_cur    
  415. Weight1 = ReadBEfloat f
  416. Bone2=ReadBEshort    f 
  417. if Bone2<0 or Bone2>BoneCount then Bone2=65535            
  418. fseek f 0x2#seek_cur    
  419. Weight2 = ReadBEfloat f
  420. Bone3=ReadBEshort    f
  421. if Bone3<0 or Bone3>BoneCount then Bone3=65535            
  422. fseek f 0x2#seek_cur    
  423. Weight3 = ReadBEfloat f
  424. Bone4=ReadBEshort    f
  425. if Bone4<0 or Bone4>BoneCount then Bone4=65535            
  426. fseek f 0x2#seek_cur    
  427. Weight4 = ReadBEfloat f
  428. )
  429. if Mesh_Info_Arr2[a].Unk114==320 then    
  430. if Mesh_Info_Arr[a].WeightCount == 4 do (
  431. Bone1=Readshort    f
  432. if Bone1<0 or Bone1>BoneCount then Bone1=65535            
  433. fseek f 0x2#seek_cur    
  434. Weight1 = ReadBEfloat f
  435. Bone2=Readshort    f 
  436. if Bone2<0 or Bone2>BoneCount then Bone2=65535            
  437. fseek f 0x2#seek_cur    
  438. Weight2 = ReadBEfloat f
  439. Bone3=Readshort    f
  440. if Bone3<0 or Bone3>BoneCount then Bone3=65535            
  441. fseek f 0x2#seek_cur    
  442. Weight3 = ReadBEfloat f
  443. Bone4=Readshort    f
  444. if Bone4<0 or Bone4>BoneCount then Bone4=65535            
  445. fseek f 0x2#seek_cur    
  446. Weight4 = ReadBEfloat f
  447. )
  448. if Mesh_Info_Arr2[a].Unk114==64 then    
  449. if Mesh_Info_Arr[a].WeightCount == 5 do (
  450. Bone1=Readshort    f#unsigned 
  451. if Bone1<0 or Bone1>usedID then Bone1=65535                
  452. fseek f 0x2#seek_cur    
  453. Weight1 = ReadBEfloat f
  454. Bone2=Readshort    f#unsigned  
  455. if Bone2<0 or Bone2>usedID then Bone2=65535            
  456. fseek f 0x2#seek_cur    
  457. Weight2 = ReadBEfloat f
  458. Bone3=Readshort    f#unsigned 
  459. if Bone3<0 or Bone3>usedID then Bone3=65535            
  460. fseek f 0x2#seek_cur    
  461. Weight3 = ReadBEfloat f
  462. Bone4=Readshort    f#unsigned 
  463. if Bone4<0 or Bone4>usedID then Bone4=65535            
  464. fseek f 0x2#seek_cur    
  465. Weight4 = ReadBEfloat f
  466. Bone5=Readshort    f#unsigned 
  467. if Bone5<0 or Bone5>usedID then Bone5=65535            
  468. fseek f 0x2#seek_cur    
  469. Weight5 = ReadBEfloat f
  470. )
  471. if Mesh_Info_Arr2[a].Unk114!=64 then    
  472. if Mesh_Info_Arr[a].WeightCount == 5 do (
  473. Bone1=ReadBEshort    f
  474. if Bone1<0 or Bone1>usedID then Bone1=65535            
  475. fseek f 0x2#seek_cur    
  476. Weight1 = ReadBEfloat f
  477. Bone2=ReadBEshort    f 
  478. if Bone2<0 or Bone2>usedID then Bone2=65535            
  479. fseek f 0x2#seek_cur    
  480. Weight2 = ReadBEfloat f
  481. Bone3=ReadBEshort    f
  482. if Bone3<0 or Bone3>usedID then Bone3=65535            
  483. fseek f 0x2#seek_cur    
  484. Weight3 = ReadBEfloat f
  485. Bone4=ReadBEshort    f
  486. if Bone4<0 or Bone4>usedID then Bone4=65535            
  487. fseek f 0x2#seek_cur    
  488. Weight4 = ReadBEfloat f
  489. Bone5=ReadBEshort    f
  490. if Bone5<0 or Bone5>usedID then Bone5=65535            
  491. fseek f 0x2#seek_cur    
  492. Weight5 = ReadBEfloat f
  493. )
  494. if Mesh_Info_Arr2[a].Unk114==64 then    
  495. if Mesh_Info_Arr[a].WeightCount == 6 do (
  496. Bone1=Readshort    f#unsigned 
  497. if Bone1<0 or Bone1>usedID then Bone1=65535                
  498. fseek f 0x2#seek_cur    
  499. Weight1 = ReadBEfloat f
  500. Bone2=Readshort    f#unsigned  
  501. if Bone2<0 or Bone2>usedID then Bone2=65535            
  502. fseek f 0x2#seek_cur    
  503. Weight2 = ReadBEfloat f
  504. Bone3=Readshort    f#unsigned 
  505. if Bone3<0 or Bone3>usedID then Bone3=65535            
  506. fseek f 0x2#seek_cur    
  507. Weight3 = ReadBEfloat f
  508. Bone4=Readshort    f#unsigned 
  509. if Bone4<0 or Bone4>usedID then Bone4=65535            
  510. fseek f 0x2#seek_cur    
  511. Weight4 = ReadBEfloat f
  512. Bone5=Readshort    f#unsigned 
  513. if Bone5<0 or Bone5>usedID then Bone5=65535            
  514. fseek f 0x2#seek_cur    
  515. Weight5 = ReadBEfloat f
  516. Bone6=Readshort    f#unsigned 
  517. if Bone6<0 or Bone6>usedID then Bone6=65535            
  518. fseek f 0x2#seek_cur    
  519. Weight6 = ReadBEfloat f
  520. )
  521. if Mesh_Info_Arr2[a].Unk114!=64 then    
  522. if Mesh_Info_Arr[a].WeightCount == 6 do (
  523. Bone1=ReadBEshort    f
  524. if Bone1<0 or Bone1>usedID then Bone1=65535            
  525. fseek f 0x2#seek_cur    
  526. Weight1 = ReadBEfloat f
  527. Bone2=ReadBEshort    f 
  528. if Bone2<0 or Bone2>usedID then Bone2=65535            
  529. fseek f 0x2#seek_cur    
  530. Weight2 = ReadBEfloat f
  531. Bone3=ReadBEshort    f
  532. if Bone3<0 or Bone3>usedID then Bone3=65535            
  533. fseek f 0x2#seek_cur    
  534. Weight3 = ReadBEfloat f
  535. Bone4=ReadBEshort    f
  536. if Bone4<0 or Bone4>usedID then Bone4=65535            
  537. fseek f 0x2#seek_cur    
  538. Weight4 = ReadBEfloat f
  539. Bone5=ReadBEshort    f
  540. if Bone5<0 or Bone5>usedID then Bone5=65535            
  541. fseek f 0x2#seek_cur    
  542. Weight5 = ReadBEfloat f
  543. Bone6=ReadBEshort    f
  544. if Bone6<0 or Bone6>usedID then Bone6=65535            
  545. fseek f 0x2#seek_cur    
  546. Weight6 = ReadBEfloat f
  547. )
  548. if Mesh_Info_Arr2[a].Unk114==64 then    
  549. if Mesh_Info_Arr[a].WeightCount == 7 do (
  550. Bone1=Readshort    f#unsigned 
  551. if Bone1<0 or Bone1>usedID then Bone1=65535                
  552. fseek f 0x2#seek_cur    
  553. Weight1 = ReadBEfloat f
  554. Bone2=Readshort    f#unsigned  
  555. if Bone2<0 or Bone2>usedID then Bone2=65535            
  556. fseek f 0x2#seek_cur    
  557. Weight2 = ReadBEfloat f
  558. Bone3=Readshort    f#unsigned 
  559. if Bone3<0 or Bone3>usedID then Bone3=65535            
  560. fseek f 0x2#seek_cur    
  561. Weight3 = ReadBEfloat f
  562. Bone4=Readshort    f#unsigned 
  563. if Bone4<0 or Bone4>usedID then Bone4=65535            
  564. fseek f 0x2#seek_cur    
  565. Weight4 = ReadBEfloat f
  566. Bone5=Readshort    f#unsigned 
  567. if Bone5<0 or Bone5>usedID then Bone5=65535            
  568. fseek f 0x2#seek_cur    
  569. Weight5 = ReadBEfloat f
  570. Bone6=Readshort    f#unsigned 
  571. if Bone6<0 or Bone6>usedID then Bone6=65535            
  572. fseek f 0x2#seek_cur    
  573. Weight6 = ReadBEfloat f
  574. Bone7=Readshort    f#unsigned 
  575. if Bone7<0 or Bone7>usedID then Bone7=65535            
  576. fseek f 0x2#seek_cur    
  577. Weight7 = ReadBEfloat f
  578. )
  579. if Mesh_Info_Arr2[a].Unk114!=64 then    
  580. if Mesh_Info_Arr[a].WeightCount == 7 do (
  581. Bone1=ReadBEshort    f
  582. if Bone1<0 or Bone1>usedID then Bone1=65535            
  583. fseek f 0x2#seek_cur    
  584. Weight1 = ReadBEfloat f
  585. Bone2=ReadBEshort    f 
  586. if Bone2<0 or Bone2>usedID then Bone2=65535            
  587. fseek f 0x2#seek_cur    
  588. Weight2 = ReadBEfloat f
  589. Bone3=ReadBEshort    f
  590. if Bone3<0 or Bone3>usedID then Bone3=65535            
  591. fseek f 0x2#seek_cur    
  592. Weight3 = ReadBEfloat f
  593. Bone4=ReadBEshort    f
  594. if Bone4<0 or Bone4>usedID then Bone4=65535            
  595. fseek f 0x2#seek_cur    
  596. Weight4 = ReadBEfloat f
  597. Bone5=ReadBEshort    f
  598. if Bone5<0 or Bone5>usedID then Bone5=65535            
  599. fseek f 0x2#seek_cur    
  600. Weight5 = ReadBEfloat f
  601. Bone6=ReadBEshort    f
  602. if Bone6<0 or Bone6>usedID then Bone6=65535            
  603. fseek f 0x2#seek_cur    
  604. Weight6 = ReadBEfloat f
  605. Bone7=ReadBEshort    f
  606. if Bone7<0 or Bone7>usedID then Bone7=65535            
  607. fseek f 0x2#seek_cur    
  608. Weight7 = ReadBEfloat f
  609. )
  610. if Mesh_Info_Arr2[a].Unk114==64 then    
  611. if Mesh_Info_Arr[a].WeightCount == 8 do (
  612. Bone1=Readshort    f#unsigned 
  613. if Bone1<0 or Bone1>usedID then Bone1=65535                
  614. fseek f 0x2#seek_cur    
  615. Weight1 = ReadBEfloat f
  616. Bone2=Readshort    f#unsigned  
  617. if Bone2<0 or Bone2>usedID then Bone2=65535            
  618. fseek f 0x2#seek_cur    
  619. Weight2 = ReadBEfloat f
  620. Bone3=Readshort    f#unsigned 
  621. if Bone3<0 or Bone3>usedID then Bone3=65535            
  622. fseek f 0x2#seek_cur    
  623. Weight3 = ReadBEfloat f
  624. Bone4=Readshort    f#unsigned 
  625. if Bone4<0 or Bone4>usedID then Bone4=65535            
  626. fseek f 0x2#seek_cur    
  627. Weight4 = ReadBEfloat f
  628. Bone5=Readshort    f#unsigned 
  629. if Bone5<0 or Bone5>usedID then Bone5=65535            
  630. fseek f 0x2#seek_cur    
  631. Weight5 = ReadBEfloat f
  632. Bone6=Readshort    f#unsigned 
  633. if Bone6<0 or Bone6>usedID then Bone6=65535            
  634. fseek f 0x2#seek_cur    
  635. Weight6 = ReadBEfloat f
  636. Bone7=Readshort    f#unsigned 
  637. if Bone7<0 or Bone7>usedID then Bone7=65535            
  638. fseek f 0x2#seek_cur    
  639. Weight7 = ReadBEfloat f
  640. Bone8=Readshort    f#unsigned 
  641. if Bone8<0 or Bone8>usedID then Bone8=65535            
  642. fseek f 0x2#seek_cur    
  643. Weight8 = ReadBEfloat f
  644. )
  645. if Mesh_Info_Arr2[a].Unk114!=64 then    
  646. if Mesh_Info_Arr[a].WeightCount == 8 do (
  647. Bone1=ReadBEshort    f
  648. if Bone1<0 or Bone1>usedID then Bone1=65535            
  649. fseek f 0x2#seek_cur    
  650. Weight1 = ReadBEfloat f
  651. Bone2=ReadBEshort    f 
  652. if Bone2<0 or Bone2>usedID then Bone2=65535            
  653. fseek f 0x2#seek_cur    
  654. Weight2 = ReadBEfloat f
  655. Bone3=ReadBEshort    f
  656. if Bone3<0 or Bone3>usedID then Bone3=65535            
  657. fseek f 0x2#seek_cur    
  658. Weight3 = ReadBEfloat f
  659. Bone4=ReadBEshort    f
  660. if Bone4<0 or Bone4>usedID then Bone4=65535            
  661. fseek f 0x2#seek_cur    
  662. Weight4 = ReadBEfloat f
  663. Bone5=ReadBEshort    f
  664. if Bone5<0 or Bone5>usedID then Bone5=65535            
  665. fseek f 0x2#seek_cur    
  666. Weight5 = ReadBEfloat f
  667. Bone6=ReadBEshort    f
  668. if Bone6<0 or Bone6>usedID then Bone6=65535            
  669. fseek f 0x2#seek_cur    
  670. Weight6 = ReadBEfloat f
  671. Bone7=ReadBEshort    f
  672. if Bone7<0 or Bone7>usedID then Bone7=65535            
  673. fseek f 0x2#seek_cur    
  674. Weight7 = ReadBEfloat f
  675. Bone7=ReadBEshort    f
  676. if Bone8<0 or Bone8>usedID then Bone8=65535            
  677. fseek f 0x2#seek_cur    
  678. Weight8 = ReadBEfloat f
  679. )
  680.  
  681. w = (weight_data boneids:#() weights:#())
  682. maxweight = 0        
  683. if(Bone1 != 65535) then (
  684. if(weight1 != 0) then    
  685.    maxweight = maxweight + weight1
  686. )    
  687. if(Bone2 != 65535) then (
  688. if(weight2 != 0) then        
  689.    maxweight = maxweight + weight2
  690. )
  691. if(Bone3 != 65535) then (
  692. if(weight3 != 0) then    
  693.    maxweight = maxweight + weight3
  694. )
  695. if(Bone4 != 65535) then (
  696. if(weigh4 != 0) then        
  697.    maxweight = maxweight + weight4
  698. )    
  699. if(Bone5 != 65535) then (
  700. if(weight5 != 0) then        
  701.    maxweight = maxweight + weight5
  702. )    
  703. if(Bone6 != 65535) then (
  704. if(weight6 != 0) then        
  705.    maxweight = maxweight + weight6
  706. )
  707. if(Bone7 != 65535) then (
  708. if(weight7 != 0) then        
  709.    maxweight = maxweight + weight7
  710. )    
  711. if(Bone8 != 65535) then (
  712. if(weight8 != 0) then        
  713.    maxweight = maxweight + weight8
  714. )    
  715. if(maxweight != 0) then (
  716.       if(Bone1 != 65535) then (
  717.          w1 = weight1 as float
  718.          append w.boneids (bone1 + 1)
  719.          append w.weights w1
  720.       )
  721.       if(Bone2 != 65535) then (
  722.          w2 = weight2 as float
  723.          append w.boneids (bone2 + 1)
  724.          append w.weights w2
  725.       )
  726.       if(Bone3 != 65535) then (
  727.          w3 = weight3 as float
  728.          append w.boneids (bone3 + 1)
  729.          append w.weights w3
  730.       )  
  731.       if(Bone4 != 65535) then (
  732.          w4 = weight4 as float
  733.          append w.boneids (bone4 + 1)
  734.          append w.weights w4
  735.       )  
  736.       if(Bone5 != 65535) then (
  737.          w5 = weight5 as float
  738.          append w.boneids (bone5 + 1)
  739.          append w.weights w5
  740.       )        
  741.       if(Bone6 != 65535) then (
  742.          w6 = weight6 as float
  743.          append w.boneids (bone6 + 1)
  744.          append w.weights w6
  745.       )    
  746.       if(Bone7 != 65535) then (
  747.          w7 = weight7 as float
  748.          append w.boneids (bone7 + 1)
  749.          append w.weights w7
  750.       )    
  751.       if(Bone8 != 65535) then (
  752.          w8 = weight8 as float
  753.          append w.boneids (bone8 + 1)
  754.          append w.weights w8
  755.       )          
  756.    )
  757. append Weight_array w
  758. )
  759.  
  760. fseek f Mesh_Info_Arr[a].FaceOff#seek_set
  761. Ftmp = #()
  762. for b = 1 to Mesh_Info_Arr[a].FaceSec Do (
  763. FSize = ReadBElong f as float
  764. FCount = ReadBElong f as float
  765. FStart = (ReadBElong f + 8) as float
  766. append Ftmp [FSize,FCount,FStart]
  767. )
  768. for b = 1 to Mesh_Info_Arr[a].FaceSec Do (
  769. fseek f Ftmp[b].z#seek_set
  770. FaceEnd = ((ftell f) + (2 * Ftmp[b].y))
  771. StartDirection = 1
  772. Face_array2 = #()
  773. f1 = ReadBEword f + 1
  774. f2 = ReadBEword f + 1
  775. FaceDirection = StartDirection
  776. do (
  777. f3 = ReadBEword f
  778. if (f3==0xFFFF) then (
  779. f1 = ReadBEword f + 1
  780. f2 = ReadBEword f + 1
  781. FaceDirection = StartDirection   
  782. ) else (
  783. f3 += 1
  784. FaceDirection *= -1
  785. if (f1!=f2)AND(f2!=f3)AND(f3!=f1) then (
  786. append Face_array2 [(f1),(f2),(f3)]
  787. if FaceDirection > 0 then append Face_array [(f1),(f2),(f3)]
  788. else append Face_array [(f1),(f3),(f2)]
  789. )
  790. f1 = f2
  791. f2 = f3
  792. )
  793. )while (ftell f) < (FaceEnd)
  794. )
  795.  
  796. try(
  797. msh = mesh vertices:Vert_array faces:Face_array
  798. msh.numTVerts = UV_array.count
  799. buildTVFaces msh
  800. msh.name = Mesh_Info_Arr[a].Objname
  801. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  802. for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
  803. for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]
  804.  
  805. max modify mode
  806. select msh
  807. skinMod = skin ()
  808. addModifier msh skinMod
  809. for i = 1 to Used_Bone_array.count do
  810. (
  811.     maxbone = BNArr[(Used_Bone_array[i])]
  812.     if i != Used_Bone_array.count then 
  813.         skinOps.addBone skinMod maxbone 0
  814.     else
  815.         skinOps.addBone skinMod maxbone 1
  816. )
  817. modPanel.setCurrentObject skinMod
  818. for i = 1 to Vert_array.count do (
  819.    w = Weight_array[i]
  820.    bi = #() --bone index array
  821.    wv = #() --weight value array
  822.    
  823.    for j = 1 to w.boneids.count do
  824.    (
  825.       boneid = w.boneids[j]
  826.       weight = w.weights[j]
  827.       append bi boneid
  828.       append wv weight
  829.    )   
  830.    
  831.    skinOps.ReplaceVertexWeights skinMod i bi wv
  832. )
  833. )catch(format "Wrong Skel or Messed Bones!!\n")
  834. )
  835.  
  836. fclose f