Advertisement
Guest User

Unknown Vertex Type

a guest
Feb 7th, 2018
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 113.15 KB | None | 0 0
  1. -- Super Smash Bros. for Wii U / Taiko no Tatsujin Wii U model importer by Random Talking Bush.
  2. -- Updated May 4th, 2017.
  3. -- Fixed rigging being broken in one way or another for newer 3DS Max versions.
  4. -- Added support for vertex types 0x21/0x23/0x26/0x29 (half-float rigging).
  5. -- Changed internal naming from "size" to "type" for vertex/UV/face formats because that makes more sense.
  6. -- Changed "if" setups for vertex/face information to "case of" just because.
  7.  
  8. fn convertTo32 input16 = (
  9. inputAsInt = input16
  10. sign = bit.get inputAsInt 16
  11. exponent = (bit.shift (bit.and inputAsInt (bit.hexasint "7C00")) -10) as integer - 16
  12. fraction = bit.and inputAsInt (bit.hexasint "03FF")
  13. if sign==true then sign = 1 else sign = 0
  14. exponentF = exponent + 127
  15. --Output 32 bit integer representing a 32 bit float
  16. outputAsFloat = bit.or (bit.or (bit.shift fraction 13) (bit.shift exponentF 23)) (bit.shift sign 31)
  17. --Output Check
  18. return bit.intasfloat outputasfloat
  19. )
  20.  
  21. fn floatSwap2 f =
  22. (
  23. i = bit.floatAsInt f
  24. h = bit.intashex i
  25. while h.count < 8 do h = "0" + h
  26.  
  27. s = (substring h 7 2) + (substring h 5 2) + (substring h 3 2) + (substring h 1 2)
  28. bit.intAsFloat (bit.hexasint s)
  29. )
  30.  
  31. fn ReadBEword fstream = (
  32. return (bit.swapBytes (readshort fstream #unsigned) 1 2)
  33. )
  34.  
  35. fn ReadBElong fstream = (
  36. long = readlong fstream
  37. long = bit.swapBytes long 1 4
  38. long = bit.swapBytes long 2 3
  39. return long
  40. )
  41.  
  42. fn ReadBEHalfFloat fstream = (
  43. return convertTo32(ReadBEword fstream)
  44. )
  45.  
  46. fn ReadBEfloat fstream = (
  47. return floatSwap2(readfloat fstream)
  48. )
  49.  
  50. rollout SSB4UImporter "Super Smash Bros. for Wii U / Taiko no Tatsujin model importer" width:390 height:250
  51. (
  52. button btnImport "Import Model" pos:[8,8] width:375 height:40
  53. label lblDisclaimer "This script was written by Random Talking Bush, if you use it, please remember to give me thanks for this. If something doesn't work right, please contact me on The VG Resource (Random Talking Bush), Twitter, Tumblr or Steam (RandomTBush) and let me know, and I'll try to fix it." pos:[8,50] width:375 height:80
  54. checkbox tglColorMult "Multiply vertex colours?" pos:[8,108] width:150 height:15 tooltip: "If this is enabled, the model will multiply the colour values by 2 (so instead of 127 being the default, it'll be 255 -- any colour values above 127 will be lost, though)." checked: false
  55. checkbox tglColorDisable "Disable vertex colours?" pos:[8,125] width:150 height:15 tooltip: "If you'd rather not import the vertex colouring, enable this." checked: false
  56. checkbox tglPNGTex "Use PNG instead of DDS?" pos:[238,108] width:150 height:15 tooltip: "Self explanatory." checked: false
  57. label lblUpdate "(Updated: 05-04-2017)" pos:[268,125]
  58. label lblModding "TEXTURE ID MODIFIER:" pos:[8,150] width:120 height:15
  59. label lblTexIDChangeA "CLASS" pos:[8,165] width:60 height:15
  60. label lblTexIDChangeB "GROUP" pos:[68,165] width:60 height:15
  61. label lblTexIDChangeC "SUBGROUP" pos:[128,165] width:60 height:15
  62. label lblTexIDChangeD "INDEX" pos:[188,165] width:60 height:15
  63. label lblTexIDChange "For use with extra character slots in SSB4U, and to avoid texture conflicts. Input four different values (0-255) here. Make a copy just in case something goes wrong!" pos:[8,200] width:280 height:40
  64. spinner boxTexIDChangeA pos:[8,180] width:40 range:[0,255,64] type:#integer tooltip: "This can probably be changed without side effects. Don't use 16 (Lightwarps/Cubemaps), 21 (Effects), 32 (Stages), 39 (FS BGs), 40 (UI), 43 (Stage Editor), 66 (Enemies), 68 (Items), 70 (Assist), 72 (Pokémon) or 78-81 (Trophies) for characters as they're reserved for the things in brackets."
  65. spinner boxTexIDChangeB pos:[68,180] width:40 range:[0,255,0] type:#integer tooltip: "Each character has a separate number assigned to them."
  66. spinner boxTexIDChangeC pos:[128,180] width:40 range:[0,255,0] type:#integer tooltip: "Costumes are usually set to c## * 4."
  67. radiobuttons tglTexIDChangeD labels:#("No change","0","128") pos:[188,180]
  68. button btnIDFixNUD ".NUD" pos:[295,200] width:40 height:40
  69. button btnIDFixNUT ".NUT" pos:[335,200] width:40 height:40
  70.  
  71. on btnImport pressed do(
  72. local colormult = tglColorMult.checked
  73. local colordisable = tglColorDisable.checked
  74. local PNGTex = tglPNGTex.checked
  75. clearlistener()
  76. fname = getOpenFileName \
  77. caption:"Super Smash Bros. for Wii U / Taiko model file" \
  78. types:"SSB4U/TnTU model(*.nud)|*.nud" \
  79. historyCategory:"SSB4U"
  80.  
  81. if fname != undefined do (
  82. m = fopen fname "rb"
  83. p = getFilenamePath fname
  84. h = getFilenameFile fname
  85. fname2 = p + "model.vbn"
  86. q = fopen fname2 "rb"
  87.  
  88. struct Bone_Info_Struct
  89. (
  90. Bone1, Bone2, Bone3, Bone4
  91. )
  92. struct Weight_Info_Struct
  93. (
  94. Weight1, Weight2, Weight3, Weight4
  95. )
  96. struct weight_data
  97. (
  98. boneids, weights
  99. )
  100. struct TexIDSet_Struct
  101. (
  102. TexClass, TexGroup, TexSubgroup, TexIndex
  103. )
  104.  
  105. BoneName_Array = #()
  106. BoneParent_array = #()
  107. Bone_Matrix_Array = #()
  108. BoneArray = #()
  109. BoneFixArray = #()
  110. BoneCount = #()
  111. VertexStart_array = #()
  112. VertexAmount_array = #()
  113. VertexType_array = #()
  114. PolyStart_array = #()
  115. PolyAmount_array = #()
  116. PolyType_array = #()
  117. VertexAddStart_array = #()
  118. UVType_array = #()
  119. PolyName_array = #()
  120. SingleBind_array = #()
  121. TexturePropertiesS1Start_array = #()
  122. TexturePropertiesS2Start_array = #()
  123. TexturePropertiesS3Start_array = #()
  124. TexturePropertiesS4Start_array = #()
  125. TextureIDL1_array = #()
  126. TextureIDL2_array = #()
  127. TextureIDL3_array = #()
  128. TextureIDL4_array = #()
  129.  
  130. fseek m 0x00 #seek_set
  131. NDP3 = readBElong m
  132. filesize = readBElong m
  133. unknown1 = readBEword m
  134. polysets = readBEword m
  135. unknown2 = readBEword m
  136. somethingsets = readBEword m
  137. PolyClumpStart = (readBElong m) + 0x30
  138. PolyClumpSize = readBElong m
  139. VertexClumpStart = (PolyClumpStart + PolyClumpSize)
  140. VertexClumpSize = readBElong m
  141. VertexAddClumpStart = (VertexClumpStart + VertexClumpSize)
  142. VertexAddClumpSize = readBElong m
  143. NameClumpStart = (VertexAddClumpStart + VertexAddClumpSize)
  144. thisfloat1 = readBEfloat m
  145. thisfloat2 = readBEfloat m
  146. thisfloat3 = readBEfloat m
  147. thisfloat4 = readBEfloat m
  148.  
  149. ObjCount = 0
  150. for z = 1 to polysets do(
  151. Float1A = readBEfloat m
  152. Float2A = readBEfloat m
  153. Float3A = readBEfloat m
  154. Float4 = readBEfloat m
  155. Float1B = readBEfloat m
  156. Float2B = readBEfloat m
  157. Float3B = readBEfloat m
  158. Float5 = readBEfloat m
  159. polynamestart = readBElong m
  160. PolyFlag = readBElong m
  161. singlebind = readBEword m + 1
  162. if SingleBind == 65536 do(SingleBind = 1)
  163. polyamount = readBEword m
  164. ObjPropStart = readBElong m
  165. ObjCount = (ObjCount + polyamount)
  166. for s = 1 to polyamount do(
  167. append PolyName_array polynamestart
  168. append SingleBind_array singlebind
  169. )
  170. )
  171.  
  172. for z = 1 to ObjCount do(
  173. PolyStart = (readBElong m + PolyClumpStart)
  174. VertexStart = (readBElong m + VertexClumpStart)
  175. VertexAddStart = (readBElong m + VertexAddClumpStart)
  176. VertexAmount = readBEword m
  177. VertexType = readbyte m #unsigned
  178. UVType = readbyte m #unsigned
  179. TextureSet1Properties = readBElong m
  180. TextureSet2Properties = readBElong m
  181. TextureSet3Properties = readBElong m
  182. TextureSet4Properties = readBElong m
  183. PolyAmount = readBEword m
  184. PolyType = readbyte m #unsigned
  185. PolyFlag = readbyte m #unsigned
  186. fseek m 0x0C #seek_cur
  187. append VertexStart_array VertexStart
  188. append PolyStart_array PolyStart
  189. append VertexAddStart_array VertexAddStart
  190. append VertexAmount_array VertexAmount
  191. append PolyAmount_array PolyAmount
  192. append VertexType_array VertexType
  193. append UVType_array UVType
  194. append PolyType_array PolyType
  195. append TexturePropertiesS1Start_array TextureSet1Properties
  196. append TexturePropertiesS2Start_array TextureSet2Properties
  197. append TexturePropertiesS3Start_array TextureSet3Properties
  198. append TexturePropertiesS4Start_array TextureSet4Properties
  199. )
  200.  
  201. BoneCount = 0
  202.  
  203. if q != undefined do(
  204. VBN = readlong q
  205. fseek q 0x08 #seek_set
  206.  
  207. if VBN == 0x56424E20 do(
  208. BoneCount = readlong q #unsigned
  209. fseek q 0x1C #seek_set
  210. for x = 1 to BoneCount do(
  211. jumpman = (ftell q + 0x44)
  212. BoneName = readstring q
  213. fseek q jumpman #seek_set
  214. BoneParent = readshort q + 1
  215. fseek q 0x02 #seek_cur
  216. if BoneParent == 0 do(BoneParent = -1)
  217. fseek q 0x04 #seek_cur
  218. append BoneName_array BoneName
  219. append BoneParent_array BoneParent
  220. )
  221.  
  222. Trans_array = #()
  223. Rotation_array = #()
  224. Scale_array = #()
  225.  
  226. for x = 1 to BoneCount do(
  227. tx = Readfloat q
  228. ty = Readfloat q
  229. tz = Readfloat q
  230.  
  231. rx = Readfloat q
  232. ry = Readfloat q
  233. rz = Readfloat q
  234.  
  235. sx = Readfloat q
  236. sy = Readfloat q
  237. sz = Readfloat q
  238.  
  239. append Trans_array [tx,ty,tz]
  240. append Rotation_array [rx,ry,rz]
  241. append Scale_array [sx,sy,sz]
  242. )
  243.  
  244. for x = 1 to BoneCount do(
  245. BoneName = BoneName_array[x]
  246. BoneParent = BoneParent_array[x]
  247.  
  248. tfm = scaleMatrix [Scale_array[x].x,Scale_array[x].y,Scale_array[x].z]
  249. tfm = tfm * (rotateXMatrix (radToDeg Rotation_array[x].x)) * (rotateYMatrix (radToDeg Rotation_array[x].y)) * (rotateZMatrix (radToDeg Rotation_array[x].z))
  250. tfm.row4 = [Trans_array[x].x, Trans_array[x].y, Trans_array[x].z]
  251.  
  252. if (BoneParent_array[x] != -1) and (BoneParent_array[x] < x) then (
  253. tfm = tfm * BoneArray[(BoneParent_array[x])].objecttransform
  254. ) else if (x > 1) and (BoneParent_array[x] > -1) do(append BoneFixArray x)
  255.  
  256. newBone = bonesys.createbone \
  257. tfm.row4 \
  258. (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  259. (normalize tfm.row3)
  260. newBone.name = BoneName
  261. newBone.width = 0.03
  262. newBone.height = 0.03
  263. newBone.transform = tfm
  264. newBone.setBoneEnable false 0
  265. newBone.wirecolor = yellow
  266. newbone.showlinks = true
  267. newBone.pos.controller = TCB_position ()
  268. newBone.rotation.controller = TCB_rotation ()
  269. if (BoneParent != -1) then
  270. newBone.parent = BoneArray[BoneParent]
  271. append BoneArray newBone
  272.  
  273. )
  274.  
  275. for x = 1 to BoneFixArray.count do(
  276. select BoneArray[BoneFixArray[x]]
  277. tfm = scaleMatrix [Scale_array[BoneFixArray[x]].x,Scale_array[BoneFixArray[x]].y,Scale_array[BoneFixArray[x]].z]
  278. tfm = tfm * (rotateXMatrix (radToDeg Rotation_array[BoneFixArray[x]].x)) * (rotateYMatrix (radToDeg Rotation_array[BoneFixArray[x]].y)) * (rotateZMatrix (radToDeg Rotation_array[BoneFixArray[x]].z))
  279. tfm.row4 = [Trans_array[BoneFixArray[x]].x, Trans_array[BoneFixArray[x]].y, Trans_array[BoneFixArray[x]].z]
  280. tfm = tfm * BoneArray[BoneParent_array[BoneFixArray[x]]].objecttransform
  281. $.transform = tfm
  282. $.parent = BoneArray[BoneParent_array[BoneFixArray[x]]]
  283. )
  284.  
  285. )
  286.  
  287. if VBN == 0x204E4256 do(
  288. BoneCount = readBElong q
  289. fseek q 0x1C #seek_set
  290. for x = 1 to BoneCount do(
  291. jumpman = (ftell q + 0x44)
  292. BoneName = readstring q
  293. fseek q jumpman #seek_set
  294. fseek q 0x02 #seek_cur
  295. BoneParent = readBEword q + 1
  296. if BoneParent == 65536 do(BoneParent = -1)
  297. fseek q 0x04 #seek_cur
  298. append BoneName_array BoneName
  299. append BoneParent_array BoneParent
  300. )
  301.  
  302. Trans_array = #()
  303. Rotation_array = #()
  304. Scale_array = #()
  305.  
  306. for x = 1 to BoneCount do(
  307. tx = readBEfloat q
  308. ty = readBEfloat q
  309. tz = readBEfloat q
  310.  
  311. rx = readBEfloat q
  312. ry = readBEfloat q
  313. rz = readBEfloat q
  314.  
  315. sx = readBEfloat q
  316. sy = readBEfloat q
  317. sz = readBEfloat q
  318.  
  319. append Trans_array [tx,ty,tz]
  320. append Rotation_array [rx,ry,rz]
  321. append Scale_array [sx,sy,sz]
  322. )
  323.  
  324. for x = 1 to BoneCount do(
  325. BoneName = BoneName_array[x]
  326. BoneParent = BoneParent_array[x]
  327.  
  328. tfm = scaleMatrix [Scale_array[x].x,Scale_array[x].y,Scale_array[x].z]
  329. tfm = tfm * (rotateXMatrix (radToDeg Rotation_array[x].x)) * (rotateYMatrix (radToDeg Rotation_array[x].y)) * (rotateZMatrix (radToDeg Rotation_array[x].z))
  330. tfm.row4 = [Trans_array[x].x, Trans_array[x].y, Trans_array[x].z]
  331.  
  332. if (BoneParent_array[x] != -1) and (BoneParent_array[x] < x) then (
  333. tfm = tfm * BoneArray[(BoneParent_array[x])].objecttransform
  334. ) else if (x > 1) and (BoneParent_array[x] > -1) do(append BoneFixArray x)
  335.  
  336. newBone = bonesys.createbone \
  337. tfm.row4 \
  338. (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  339. (normalize tfm.row3)
  340. newBone.name = BoneName
  341. newBone.width = 0.03
  342. newBone.height = 0.03
  343. newBone.transform = tfm
  344. newBone.setBoneEnable false 0
  345. newBone.wirecolor = yellow
  346. newbone.showlinks = true
  347. newBone.pos.controller = TCB_position ()
  348. newBone.rotation.controller = TCB_rotation ()
  349. if (BoneParent != -1) then
  350. newBone.parent = BoneArray[BoneParent]
  351. append BoneArray newBone
  352. )
  353.  
  354. for x = 1 to BoneFixArray.count do(
  355. select BoneArray[BoneFixArray[x]]
  356. tfm = scaleMatrix [Scale_array[BoneFixArray[x]].x,Scale_array[BoneFixArray[x]].y,Scale_array[BoneFixArray[x]].z]
  357. tfm = tfm * (rotateXMatrix (radToDeg Rotation_array[BoneFixArray[x]].x)) * (rotateYMatrix (radToDeg Rotation_array[BoneFixArray[x]].y)) * (rotateZMatrix (radToDeg Rotation_array[BoneFixArray[x]].z))
  358. tfm.row4 = [Trans_array[BoneFixArray[x]].x, Trans_array[BoneFixArray[x]].y, Trans_array[BoneFixArray[x]].z]
  359. tfm = tfm * BoneArray[BoneParent_array[BoneFixArray[x]]].objecttransform
  360. $.transform = tfm
  361. $.parent = BoneArray[BoneParent_array[BoneFixArray[x]]]
  362. )
  363.  
  364. )
  365. )
  366.  
  367. for z = 1 to ObjCount do(
  368. Layer1Write = 0
  369. Layer2Write = 0
  370. Layer3Write = 0
  371. Layer4Write = 0
  372.  
  373. fseek m TexturePropertiesS1Start_array[z] #seek_set
  374. print ("Polygon group " + z as string + " material properties start at 0x" + (bit.intAsHex(ftell m))as string)
  375. UnkTex1 = readbyte m #unsigned
  376. UnkTex2 = readbyte m #unsigned
  377. UnkTex3 = readbyte m #unsigned
  378. UnkTex4 = readbyte m #unsigned
  379. nothing1 = readBElong m
  380. TexSomethingCount = readBEword m
  381. TexLayerCount = readBEword m
  382. TexTransparencyA = readbyte m #unsigned
  383. TexTransparencyB = readbyte m #unsigned
  384. TexTransparencyC = readbyte m #unsigned
  385. TexTransparencyD = readbyte m #unsigned
  386. UnkTex9 = readbyte m #unsigned
  387. UnkTex10 = readbyte m #unsigned
  388. UnkTex11 = readbyte m #unsigned
  389. UnkTex12 = readbyte m #unsigned
  390. nothing2 = readBElong m
  391. UnkTex13 = readbyte m #unsigned
  392. UnkTex14 = readbyte m #unsigned
  393. UnkTex15 = readbyte m #unsigned
  394. UnkTex16 = readbyte m #unsigned
  395. UnkTex17 = readBEfloat m
  396. print "Texture information:"
  397.  
  398. for x = 1 to TexLayerCount do(
  399. TexClass = readbyte m #unsigned
  400. TexGroup = readbyte m #unsigned
  401. TexSubgroup = readbyte m #unsigned
  402. TexIndex = readbyte m #unsigned
  403. if x == 1 do(
  404. Layer1Write = 1
  405. append TextureIDL1_array (TexIDSet_Struct TexClass:TexClass TexGroup:TexGroup TexSubgroup:TexSubgroup TexIndex:TexIndex)
  406. )
  407. if x == 2 do(
  408. Layer2Write = 1
  409. append TextureIDL2_array (TexIDSet_Struct TexClass:TexClass TexGroup:TexGroup TexSubgroup:TexSubgroup TexIndex:TexIndex)
  410. )
  411. if x == 3 do(
  412. Layer3Write = 1
  413. append TextureIDL3_array (TexIDSet_Struct TexClass:TexClass TexGroup:TexGroup TexSubgroup:TexSubgroup TexIndex:TexIndex)
  414. )
  415. if x == 4 do(
  416. Layer4Write = 1
  417. append TextureIDL4_array (TexIDSet_Struct TexClass:TexClass TexGroup:TexGroup TexSubgroup:TexSubgroup TexIndex:TexIndex)
  418. )
  419. nothing = readBElong m
  420. nothing = readBElong m
  421. UnkTexC = readbyte m #unsigned
  422. UnkTexD = readbyte m #unsigned
  423. UnkTexE = readbyte m #unsigned
  424. TexFilter = readbyte m #unsigned
  425. UnkTexG = readbyte m #unsigned
  426. UnkTexH = readbyte m #unsigned
  427. UnkTexI = readbyte m #unsigned
  428. UnkTexJ = readbyte m #unsigned
  429. nothing = readBElong m
  430. print ("Class: " + TexClass as string+ ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  431. )
  432.  
  433. headerread = readBElong m
  434. fseek m -0x04 #seek_cur
  435. if headerread != 0 do(do(
  436. headerread = readBElong m
  437. TexPropNameStart = readBElong m
  438. something4 = readBElong m
  439. nothing = readBElong m
  440. TexFloatStart = (ftell m)
  441. TexFloatA = readBEfloat m
  442. TexFloatB = readBEfloat m
  443. TexFloatC = readBEfloat m
  444. TexFloatD = readBEfloat m
  445. fseek m (NameClumpStart + TexPropNameStart) #seek_set
  446. TexPropName = readstring m
  447. fseek m (TexFloatStart + 0x10) #seek_set
  448. if TexPropName != "NU_materialHash" do(print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = " + TexFloatA as string + ", " + TexFloatB as string + ", " + TexFloatC as string + ", " + TexFloatD as string))
  449. if TexPropName == "NU_materialHash" do(
  450. fseek m -0x10 #seek_cur
  451. TexFloatA = readBElong m
  452. TexFloatB = readBElong m
  453. TexFloatC = readBElong m
  454. TexFloatD = readBElong m
  455. print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = 0x" + ((bit.intAsHex(TexFloatA))as string))
  456. )
  457. fseek m (TexFloatStart + headerread - 0x10) #seek_set
  458. ) while headerread != 0
  459. )
  460.  
  461. if TexturePropertiesS2Start_array[z] != 0 do(
  462. fseek m TexturePropertiesS2Start_array[z] #seek_set
  463. print "--------------------"
  464. print ("Polygon group " + z as string + " Set 2 material properties:")
  465.  
  466. UnkTex1 = readbyte m #unsigned
  467. UnkTex2 = readbyte m #unsigned
  468. UnkTex3 = readbyte m #unsigned
  469. UnkTex4 = readbyte m #unsigned
  470. nothing = readBElong m
  471. TexSomethingCount = readBEword m
  472. TexLayerCount = readBEword m
  473. UnkTex5 = readbyte m #unsigned
  474. UnkTex6 = readbyte m #unsigned
  475. UnkTex7 = readbyte m #unsigned
  476. UnkTex8 = readbyte m #unsigned
  477. something = readBElong m
  478. nothing = readBElong m
  479. nothing = readBElong m
  480. nothing = readBElong m
  481. print "Texture information:"
  482.  
  483. for x = 1 to TexLayerCount do(
  484. TexClass = readbyte m #unsigned
  485. TexGroup = readbyte m #unsigned
  486. TexSubgroup = readbyte m #unsigned
  487. TexIndex = readbyte m #unsigned
  488. nothing = readBElong m
  489. nothing = readBElong m
  490. UnkTexC = readbyte m #unsigned
  491. UnkTexD = readbyte m #unsigned
  492. UnkTexE = readbyte m #unsigned
  493. UnkTexF = readbyte m #unsigned
  494. UnkTexG = readbyte m #unsigned
  495. UnkTexH = readbyte m #unsigned
  496. UnkTexI = readbyte m #unsigned
  497. UnkTexJ = readbyte m #unsigned
  498. nothing = readBElong m
  499. print ("Class: " + TexClass as string+ ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  500. )
  501.  
  502. headerread = readBElong m
  503. fseek m -0x04 #seek_cur
  504. if headerread != 0 do(do(
  505. headerread = readBElong m
  506. TexPropNameStart = readBElong m
  507. something4 = readBElong m
  508. nothing = readBElong m
  509. TexFloatStart = (ftell m)
  510. TexFloatA = readBEfloat m
  511. TexFloatB = readBEfloat m
  512. TexFloatC = readBEfloat m
  513. TexFloatD = readBEfloat m
  514. fseek m (NameClumpStart + TexPropNameStart) #seek_set
  515. TexPropName = readstring m
  516. fseek m (TexFloatStart + 0x10) #seek_set
  517. if TexPropName != "NU_materialHash" do(print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = " + TexFloatA as string + ", " + TexFloatB as string + ", " + TexFloatC as string + ", " + TexFloatD as string))
  518. if TexPropName == "NU_materialHash" do(
  519. fseek m -0x10 #seek_cur
  520. TexFloatA = readBElong m
  521. TexFloatB = readBElong m
  522. TexFloatC = readBElong m
  523. TexFloatD = readBElong m
  524. print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = 0x" + ((bit.intAsHex(TexFloatA))as string))
  525. )
  526. fseek m (TexFloatStart + headerread - 0x10) #seek_set
  527. ) while headerread != 0
  528. )
  529.  
  530. )
  531.  
  532. if TexturePropertiesS3Start_array[z] != 0 do(
  533. fseek m TexturePropertiesS3Start_array[z] #seek_set
  534. print "--------------------"
  535. print ("Polygon group " + z as string + " Set 3 material properties:")
  536.  
  537. UnkTex1 = readbyte m #unsigned
  538. UnkTex2 = readbyte m #unsigned
  539. UnkTex3 = readbyte m #unsigned
  540. UnkTex4 = readbyte m #unsigned
  541. nothing = readBElong m
  542. TexSomethingCount = readBEword m
  543. TexLayerCount = readBEword m
  544. UnkTex5 = readbyte m #unsigned
  545. UnkTex6 = readbyte m #unsigned
  546. UnkTex7 = readbyte m #unsigned
  547. UnkTex8 = readbyte m #unsigned
  548. something = readBElong m
  549. nothing = readBElong m
  550. nothing = readBElong m
  551. nothing = readBElong m
  552. print "Texture information:"
  553.  
  554. for x = 1 to TexLayerCount do(
  555. TexClass = readbyte m #unsigned
  556. TexGroup = readbyte m #unsigned
  557. TexSubgroup = readbyte m #unsigned
  558. TexIndex = readbyte m #unsigned
  559. nothing = readBElong m
  560. nothing = readBElong m
  561. UnkTexC = readbyte m #unsigned
  562. UnkTexD = readbyte m #unsigned
  563. UnkTexE = readbyte m #unsigned
  564. UnkTexF = readbyte m #unsigned
  565. UnkTexG = readbyte m #unsigned
  566. UnkTexH = readbyte m #unsigned
  567. UnkTexI = readbyte m #unsigned
  568. UnkTexJ = readbyte m #unsigned
  569. nothing = readBElong m
  570. print ("Class: " + TexClass as string+ ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  571. )
  572.  
  573. headerread = readBElong m
  574. fseek m -0x04 #seek_cur
  575. if headerread != 0 do(do(
  576. headerread = readBElong m
  577. TexPropNameStart = readBElong m
  578. something4 = readBElong m
  579. nothing = readBElong m
  580. TexFloatStart = (ftell m)
  581. TexFloatA = readBEfloat m
  582. TexFloatB = readBEfloat m
  583. TexFloatC = readBEfloat m
  584. TexFloatD = readBEfloat m
  585. fseek m (NameClumpStart + TexPropNameStart) #seek_set
  586. TexPropName = readstring m
  587. fseek m (TexFloatStart + 0x10) #seek_set
  588. if TexPropName != "NU_materialHash" do(print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = " + TexFloatA as string + ", " + TexFloatB as string + ", " + TexFloatC as string + ", " + TexFloatD as string))
  589. if TexPropName == "NU_materialHash" do(
  590. fseek m -0x10 #seek_cur
  591. TexFloatA = readBElong m
  592. TexFloatB = readBElong m
  593. TexFloatC = readBElong m
  594. TexFloatD = readBElong m
  595. print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = 0x" + ((bit.intAsHex(TexFloatA))as string))
  596. )
  597. fseek m (TexFloatStart + headerread - 0x10) #seek_set
  598. ) while headerread != 0
  599. )
  600.  
  601. )
  602.  
  603. if TexturePropertiesS4Start_array[z] != 0 do(
  604. fseek m TexturePropertiesS4Start_array[z] #seek_set
  605. print "--------------------"
  606. print ("Polygon group " + z as string + " Set 4 material properties:")
  607.  
  608. UnkTex1 = readbyte m #unsigned
  609. UnkTex2 = readbyte m #unsigned
  610. UnkTex3 = readbyte m #unsigned
  611. UnkTex4 = readbyte m #unsigned
  612. nothing = readBElong m
  613. TexSomethingCount = readBEword m
  614. TexLayerCount = readBEword m
  615. UnkTex5 = readbyte m #unsigned
  616. UnkTex6 = readbyte m #unsigned
  617. UnkTex7 = readbyte m #unsigned
  618. UnkTex8 = readbyte m #unsigned
  619. something = readBElong m
  620. nothing = readBElong m
  621. nothing = readBElong m
  622. nothing = readBElong m
  623. print "Texture information:"
  624.  
  625. for x = 1 to TexLayerCount do(
  626. TexClass = readbyte m #unsigned
  627. TexGroup = readbyte m #unsigned
  628. TexSubgroup = readbyte m #unsigned
  629. TexIndex = readbyte m #unsigned
  630. nothing = readBElong m
  631. nothing = readBElong m
  632. UnkTexC = readbyte m #unsigned
  633. UnkTexD = readbyte m #unsigned
  634. UnkTexE = readbyte m #unsigned
  635. UnkTexF = readbyte m #unsigned
  636. UnkTexG = readbyte m #unsigned
  637. UnkTexH = readbyte m #unsigned
  638. UnkTexI = readbyte m #unsigned
  639. UnkTexJ = readbyte m #unsigned
  640. nothing = readBElong m
  641. print ("Class: " + TexClass as string+ ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  642. )
  643.  
  644. headerread = readBElong m
  645. fseek m -0x04 #seek_cur
  646. if headerread != 0 do(do(
  647. headerread = readBElong m
  648. TexPropNameStart = readBElong m
  649. something4 = readBElong m
  650. nothing = readBElong m
  651. TexFloatStart = (ftell m)
  652. TexFloatA = readBEfloat m
  653. TexFloatB = readBEfloat m
  654. TexFloatC = readBEfloat m
  655. TexFloatD = readBEfloat m
  656. fseek m (NameClumpStart + TexPropNameStart) #seek_set
  657. TexPropName = readstring m
  658. fseek m (TexFloatStart + 0x10) #seek_set
  659. if TexPropName != "NU_materialHash" do(print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = " + TexFloatA as string + ", " + TexFloatB as string + ", " + TexFloatC as string + ", " + TexFloatD as string))
  660. if TexPropName == "NU_materialHash" do(
  661. fseek m -0x10 #seek_cur
  662. TexFloatA = readBElong m
  663. TexFloatB = readBElong m
  664. TexFloatC = readBElong m
  665. TexFloatD = readBElong m
  666. print ("(0x" + ((bit.intAsHex(TexFloatStart))as string) + ") " + TexPropName as string + " = 0x" + ((bit.intAsHex(TexFloatA))as string))
  667. )
  668. fseek m (TexFloatStart + headerread - 0x10) #seek_set
  669. ) while headerread != 0
  670. )
  671.  
  672. )
  673.  
  674. if TexturePropertiesS2Start_array[z] == 0 and Layer2Write == 0 do(
  675. append TextureIDL2_array (TexIDSet_Struct TexClass:0 TexGroup:0 TexSubgroup:0 TexIndex:0)
  676. )
  677. if TexturePropertiesS3Start_array[z] == 0 and Layer3Write == 0 do(
  678. append TextureIDL3_array (TexIDSet_Struct TexClass:0 TexGroup:0 TexSubgroup:0 TexIndex:0)
  679. )
  680. if TexturePropertiesS4Start_array[z] == 0 and Layer4Write == 0 do(
  681. append TextureIDL4_array (TexIDSet_Struct TexClass:0 TexGroup:0 TexSubgroup:0 TexIndex:0)
  682. )
  683. print ("Polygon group " + z as string + " material properties end at 0x" + (bit.intAsHex(ftell m))as string)
  684. print "--------------------"
  685.  
  686. )
  687. print ("Texture properties end at 0x" + (bit.intAsHex(ftell m))as string)
  688.  
  689. for z = 1 to ObjCount do(
  690. Face_array = #()
  691. Vert_array = #()
  692. Color_array = #()
  693. Alpha_array = #()
  694. Normal_array = #()
  695. UV_array = #()
  696. UV2_array = #()
  697. UV3_array = #()
  698. UV4_array = #()
  699. B1_array = #()
  700. W1_array = #()
  701. Weight_array = #()
  702.  
  703. fseek m VertexStart_array[z] #seek_set
  704.  
  705. case of (
  706. default: (throw ("Unknown vertex type!"))
  707. (VertexType_array[z] == 0x00):(
  708. for x = 1 to VertexAmount_array[z] do(
  709. vx = readBEfloat m
  710. vy = readBEfloat m
  711. vz = readBEfloat m
  712. vq = readBEfloat m
  713. colorr = 127
  714. colorg = 127
  715. colorb = 127
  716. colora = 1
  717. if UVType_array[z] == 0x12 or UVType_array[z] == 0x22 or UVType_array[z] == 0x32 or UVType_array[z] == 0x42 do(
  718. colorr = readbyte m #unsigned
  719. colorg = readbyte m #unsigned
  720. colorb = readbyte m #unsigned
  721. colora = (readbyte m #unsigned) as float / 127
  722. if colora >= 254 do(colora = 255)
  723. )
  724. if UVType_array[z] == 0x14 or UVType_array[z] == 0x24 or UVType_array[z] == 0x34 or UVType_array[z] == 0x44 do(
  725. colorr = (readBEHalfFloat m * 128) - 1
  726. colorg = (readBEHalfFloat m * 128) - 1
  727. colorb = (readBEHalfFloat m * 128) - 1
  728. colora = readBEHalfFloat m
  729. )
  730. if colormult == true do(
  731. colorr = colorr * 2
  732. colorg = colorg * 2
  733. colorb = colorb * 2
  734. if colorr >= 254 do(colorr = 255)
  735. if colorg >= 254 do(colorg = 255)
  736. if colorb >= 254 do(colorb = 255)
  737. )
  738. tu = (readBEHalfFloat m) * 2
  739. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  740. if UVType_array[z] >= 0x20 do(
  741. tu2 = (readBEHalfFloat m) * 2
  742. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  743. append UV2_array[tu2, tv2, 0]
  744. )
  745. if UVType_array[z] >= 0x30 do(
  746. tu3 = (readBEHalfFloat m) * 2
  747. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  748. append UV3_array[tu3, tv3, 0]
  749. )
  750. if UVType_array[z] >= 0x40 do(
  751. tu4 = (readBEHalfFloat m) * 2
  752. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  753. append UV4_array[tu4, tv4, 0]
  754. )
  755. Bone1 = SingleBind_array[z]
  756. Bone2 = 0
  757. Bone3 = 0
  758. Bone4 = 0
  759. Weight1 = 1
  760. Weight2 = 0
  761. Weight3 = 0
  762. Weight4 = 0
  763. append Vert_array[vx, vy, vz]
  764. append Color_Array[colorr,colorg,colorb]
  765. append Alpha_Array colora
  766. append UV_array[tu, tv, 0]
  767. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  768. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  769. )
  770. )
  771. (VertexType_array[z] == 0x01):(
  772. for x = 1 to VertexAmount_array[z] do(
  773. vx = readBEfloat m
  774. vy = readBEfloat m
  775. vz = readBEfloat m
  776. vq = readBEfloat m
  777. nx = readBEfloat m
  778. ny = readBEfloat m
  779. nz = readBEfloat m
  780. nq = readBEfloat m
  781. colorr = 127
  782. colorg = 127
  783. colorb = 127
  784. colora = 1
  785. if UVType_array[z] == 0x12 or UVType_array[z] == 0x22 or UVType_array[z] == 0x32 or UVType_array[z] == 0x42 do(
  786. colorr = readbyte m #unsigned
  787. colorg = readbyte m #unsigned
  788. colorb = readbyte m #unsigned
  789. colora = (readbyte m #unsigned) as float / 127
  790. if colora >= 254 do(colora = 255)
  791. )
  792. if UVType_array[z] == 0x14 or UVType_array[z] == 0x24 or UVType_array[z] == 0x34 or UVType_array[z] == 0x44 do(
  793. colorr = (readBEHalfFloat m * 128) - 1
  794. colorg = (readBEHalfFloat m * 128) - 1
  795. colorb = (readBEHalfFloat m * 128) - 1
  796. colora = readBEHalfFloat m
  797. )
  798. if colormult == true do(
  799. colorr = colorr * 2
  800. colorg = colorg * 2
  801. colorb = colorb * 2
  802. if colorr >= 254 do(colorr = 255)
  803. if colorg >= 254 do(colorg = 255)
  804. if colorb >= 254 do(colorb = 255)
  805. )
  806. tu = (readBEHalfFloat m) * 2
  807. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  808. if UVType_array[z] >= 0x20 do(
  809. tu2 = (readBEHalfFloat m) * 2
  810. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  811. append UV2_array[tu2, tv2, 0]
  812. )
  813. if UVType_array[z] >= 0x30 do(
  814. tu3 = (readBEHalfFloat m) * 2
  815. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  816. append UV3_array[tu3, tv3, 0]
  817. )
  818. if UVType_array[z] >= 0x40 do(
  819. tu4 = (readBEHalfFloat m) * 2
  820. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  821. append UV4_array[tu4, tv4, 0]
  822. )
  823. Bone1 = SingleBind_array[z]
  824. Bone2 = 0
  825. Bone3 = 0
  826. Bone4 = 0
  827. Weight1 = 1
  828. Weight2 = 0
  829. Weight3 = 0
  830. Weight4 = 0
  831. append Vert_array[vx, vy, vz]
  832. append Normal_array[vx, vy, vz]
  833. append Color_Array[colorr,colorg,colorb]
  834. append Alpha_Array colora
  835. append UV_array[tu, tv, 0]
  836. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  837. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  838. )
  839. )
  840. (VertexType_array[z] == 0x06):(
  841. for x = 1 to VertexAmount_array[z] do(
  842. vx = readBEfloat m
  843. vy = readBEfloat m
  844. vz = readBEfloat m
  845. nx = readBEHalfFloat m
  846. ny = readBEHalfFloat m
  847. nz = readBEHalfFloat m
  848. nq = readBEHalfFloat m
  849. colorr = 255
  850. colorg = 255
  851. colorb = 255
  852. colora = 255
  853. if UVType_array[z] == 0x12 or UVType_array[z] == 0x22 or UVType_array[z] == 0x32 or UVType_array[z] == 0x42 do(
  854. colorr = readbyte m #unsigned
  855. colorg = readbyte m #unsigned
  856. colorb = readbyte m #unsigned
  857. colora = (readbyte m #unsigned) as float / 127
  858. if colora >= 254 do(colora = 255)
  859. if colormult == true do(
  860. colorr = colorr * 2
  861. colorg = colorg * 2
  862. colorb = colorb * 2
  863. if colorr >= 254 do(colorr = 255)
  864. if colorg >= 254 do(colorg = 255)
  865. if colorb >= 254 do(colorb = 255)
  866. )
  867. )
  868. if UVType_array[z] == 0x14 or UVType_array[z] == 0x24 or UVType_array[z] == 0x34 or UVType_array[z] == 0x44 do(
  869. colorr = (readBEHalfFloat m * 128) - 1
  870. colorg = (readBEHalfFloat m * 128) - 1
  871. colorb = (readBEHalfFloat m * 128) - 1
  872. colora = readBEHalfFloat m
  873. )
  874. tu = (readBEHalfFloat m) * 2
  875. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  876. if UVType_array[z] >= 0x22 do(
  877. tu2 = (readBEHalfFloat m) * 2
  878. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  879. append UV2_array[tu2, tv2, 0]
  880. )
  881. if UVType_array[z] >= 0x32 do(
  882. tu3 = (readBEHalfFloat m) * 2
  883. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  884. append UV3_array[tu3, tv3, 0]
  885. )
  886. if UVType_array[z] >= 0x42 do(
  887. tu4 = (readBEHalfFloat m) * 2
  888. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  889. append UV4_array[tu4, tv4, 0]
  890. )
  891. Bone1 = SingleBind_array[z]
  892. Bone2 = 0
  893. Bone3 = 0
  894. Bone4 = 0
  895. Weight1 = 1
  896. Weight2 = 0
  897. Weight3 = 0
  898. Weight4 = 0
  899. append Vert_array[vx, vy, vz]
  900. append Normal_array[nx, ny, nz]
  901. append Color_Array[colorr,colorg,colorb]
  902. append Alpha_Array colora
  903. append UV_array[tu, tv, 0]
  904. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  905. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  906. )
  907. )
  908. (VertexType_array[z] == 0x07):(
  909. for x = 1 to VertexAmount_array[z] do(
  910. vx = readBEfloat m
  911. vy = readBEfloat m
  912. vz = readBEfloat m
  913. nx = readBEHalfFloat m
  914. ny = readBEHalfFloat m
  915. nz = readBEHalfFloat m
  916. nq = readBEHalfFloat m
  917. bnx = readBEHalfFloat m
  918. bny = readBEHalfFloat m
  919. bnz = readBEHalfFloat m
  920. bnq = readBEHalfFloat m
  921. tanx = readBEHalfFloat m
  922. tany = readBEHalfFloat m
  923. tanz = readBEHalfFloat m
  924. tanq = readBEHalfFloat m
  925. colorr = 255
  926. colorg = 255
  927. colorb = 255
  928. colora = 255
  929. if UVType_array[z] == 0x12 or UVType_array[z] == 0x22 or UVType_array[z] == 0x32 or UVType_array[z] == 0x42 do(
  930. colorr = readbyte m #unsigned
  931. colorg = readbyte m #unsigned
  932. colorb = readbyte m #unsigned
  933. colora = (readbyte m #unsigned) as float / 127
  934. if colora >= 254 do(colora = 255)
  935. if colormult == true do(
  936. colorr = colorr * 2
  937. colorg = colorg * 2
  938. colorb = colorb * 2
  939. if colorr >= 254 do(colorr = 255)
  940. if colorg >= 254 do(colorg = 255)
  941. if colorb >= 254 do(colorb = 255)
  942. )
  943. )
  944. if UVType_array[z] == 0x14 or UVType_array[z] == 0x24 or UVType_array[z] == 0x34 or UVType_array[z] == 0x44 do(
  945. colorr = (readBEHalfFloat m * 128) - 1
  946. colorg = (readBEHalfFloat m * 128) - 1
  947. colorb = (readBEHalfFloat m * 128) - 1
  948. colora = readBEHalfFloat m
  949. )
  950. tu = (readBEHalfFloat m) * 2
  951. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  952. if UVType_array[z] >= 0x22 do(
  953. tu2 = (readBEHalfFloat m) * 2
  954. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  955. append UV2_array[tu2, tv2, 0]
  956. )
  957. if UVType_array[z] >= 0x32 do(
  958. tu3 = (readBEHalfFloat m) * 2
  959. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  960. append UV3_array[tu3, tv3, 0]
  961. )
  962. if UVType_array[z] >= 0x42 do(
  963. tu4 = (readBEHalfFloat m) * 2
  964. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  965. append UV4_array[tu4, tv4, 0]
  966. )
  967. Bone1 = SingleBind_array[z]
  968. Bone2 = 0
  969. Bone3 = 0
  970. Bone4 = 0
  971. Weight1 = 1
  972. Weight2 = 0
  973. Weight3 = 0
  974. Weight4 = 0
  975. append Vert_array[vx, vy, vz]
  976. append Normal_array[nx, ny, nz]
  977. append Color_Array[colorr,colorg,colorb]
  978. append Alpha_Array colora
  979. append UV_array[tu, tv, 0]
  980. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  981. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  982. )
  983. )
  984. (VertexType_array[z] == 0x08):(
  985. for x = 1 to VertexAmount_array[z] do(
  986. vx = 0
  987. vy = 0
  988. vz = 0
  989. nx = readBEHalfFloat m
  990. ny = readBEHalfFloat m
  991. nz = readBEHalfFloat m
  992. nq = readBEHalfFloat m
  993. unk1 = readBEHalfFloat m
  994. unk2 = readBEHalfFloat m
  995. unk3 = readBEHalfFloat m
  996. unk4 = readBEHalfFloat m
  997. unk5 = readBEHalfFloat m
  998. colorr = 255
  999. colorg = 255
  1000. colorb = 255
  1001. colora = 255
  1002. if UVType_array[z] == 0x12 or UVType_array[z] == 0x22 or UVType_array[z] == 0x32 or UVType_array[z] == 0x42 do(
  1003. colorr = readbyte m #unsigned
  1004. colorg = readbyte m #unsigned
  1005. colorb = readbyte m #unsigned
  1006. colora = (readbyte m #unsigned) as float / 127
  1007. if colora >= 254 do(colora = 255)
  1008. if colormult == true do(
  1009. colorr = colorr * 2
  1010. colorg = colorg * 2
  1011. colorb = colorb * 2
  1012. if colorr >= 254 do(colorr = 255)
  1013. if colorg >= 254 do(colorg = 255)
  1014. if colorb >= 254 do(colorb = 255)
  1015. )
  1016. )
  1017. if UVType_array[z] == 0x14 or UVType_array[z] == 0x24 or UVType_array[z] == 0x34 or UVType_array[z] == 0x44 do(
  1018. colorr = (readBEHalfFloat m * 128) - 1
  1019. colorg = (readBEHalfFloat m * 128) - 1
  1020. colorb = (readBEHalfFloat m * 128) - 1
  1021. colora = readBEHalfFloat m
  1022. )
  1023. tu = (readBEHalfFloat m) * 2
  1024. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1025. if UVType_array[z] >= 0x22 do(
  1026. tu2 = (readBEHalfFloat m) * 2
  1027. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1028. append UV2_array[tu2, tv2, 0]
  1029. )
  1030. if UVType_array[z] >= 0x32 do(
  1031. tu3 = (readBEHalfFloat m) * 2
  1032. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1033. append UV3_array[tu3, tv3, 0]
  1034. )
  1035. if UVType_array[z] >= 0x42 do(
  1036. tu4 = (readBEHalfFloat m) * 2
  1037. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  1038. append UV4_array[tu4, tv4, 0]
  1039. )
  1040. Bone1 = SingleBind_array[z]
  1041. Bone2 = 0
  1042. Bone3 = 0
  1043. Bone4 = 0
  1044. Weight1 = 1
  1045. Weight2 = 0
  1046. Weight3 = 0
  1047. Weight4 = 0
  1048. append Vert_array[vx, vy, vz]
  1049. append Normal_array[nx, ny, nz]
  1050. append Color_Array[colorr,colorg,colorb]
  1051. append Alpha_Array colora
  1052. append UV_array[tu, tv, 0]
  1053. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  1054. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  1055. )
  1056. )
  1057. (VertexType_array[z] == 0x11):(
  1058. if UVType_array[z] == 0x10 do(
  1059. for x = 1 to VertexAmount_array[z] do(
  1060. colorr = 127
  1061. colorg = 127
  1062. colorb = 127
  1063. colora = 1 as float
  1064. if colormult == true do(
  1065. colorr = colorr * 2
  1066. colorg = colorg * 2
  1067. colorb = colorb * 2
  1068. if colorr >= 254 do(colorr = 255)
  1069. if colorg >= 254 do(colorg = 255)
  1070. if colorb >= 254 do(colorb = 255)
  1071. )
  1072. tu = (readBEHalfFloat m) * 2
  1073. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1074. append UV_array[tu, tv, 0]
  1075. append Color_Array[colorr,colorg,colorb]
  1076. append Alpha_Array colora
  1077. )
  1078. )
  1079. if UVType_array[z] == 0x12 do(
  1080. for x = 1 to VertexAmount_array[z] do(
  1081. colorr = readbyte m #unsigned
  1082. colorg = readbyte m #unsigned
  1083. colorb = readbyte m #unsigned
  1084. colora = (readbyte m #unsigned) as float / 127
  1085. if colora >= 254 do(colora = 255)
  1086. if colormult == true do(
  1087. colorr = colorr * 2
  1088. colorg = colorg * 2
  1089. colorb = colorb * 2
  1090. if colorr >= 254 do(colorr = 255)
  1091. if colorg >= 254 do(colorg = 255)
  1092. if colorb >= 254 do(colorb = 255)
  1093. )
  1094. tu = (readBEHalfFloat m) * 2
  1095. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1096. append UV_array[tu, tv, 0]
  1097. append Color_Array[colorr,colorg,colorb]
  1098. append Alpha_Array colora
  1099. )
  1100. )
  1101. if UVType_array[z] == 0x22 do(
  1102. for x = 1 to VertexAmount_array[z] do(
  1103. colorr = readbyte m #unsigned
  1104. colorg = readbyte m #unsigned
  1105. colorb = readbyte m #unsigned
  1106. colora = (readbyte m #unsigned) as float / 127
  1107. if colora >= 254 do(colora = 255)
  1108. if colormult == true do(
  1109. colorr = colorr * 2
  1110. colorg = colorg * 2
  1111. colorb = colorb * 2
  1112. if colorr >= 254 do(colorr = 255)
  1113. if colorg >= 254 do(colorg = 255)
  1114. if colorb >= 254 do(colorb = 255)
  1115. )
  1116. tu = (readBEHalfFloat m) * 2
  1117. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1118. tu2 = (readBEHalfFloat m) * 2
  1119. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1120. append UV_array[tu, tv, 0]
  1121. append UV2_array[tu2, tv2, 0]
  1122. append Color_Array[colorr,colorg,colorb]
  1123. append Alpha_Array colora
  1124. )
  1125. )
  1126. if UVType_array[z] == 0x32 do(
  1127. for x = 1 to VertexAmount_array[z] do(
  1128. colorr = readbyte m #unsigned
  1129. colorg = readbyte m #unsigned
  1130. colorb = readbyte m #unsigned
  1131. colora = (readbyte m #unsigned) as float / 127
  1132. if colora >= 254 do(colora = 255)
  1133. if colormult == true do(
  1134. colorr = colorr * 2
  1135. colorg = colorg * 2
  1136. colorb = colorb * 2
  1137. if colorr >= 254 do(colorr = 255)
  1138. if colorg >= 254 do(colorg = 255)
  1139. if colorb >= 254 do(colorb = 255)
  1140. )
  1141. tu = (readBEHalfFloat m) * 2
  1142. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1143. tu2 = (readBEHalfFloat m) * 2
  1144. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1145. tu3 = (readBEHalfFloat m) * 2
  1146. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1147. append UV_array[tu, tv, 0]
  1148. append UV2_array[tu2, tv2, 0]
  1149. append UV3_array[tu3, tv3, 0]
  1150. append Color_Array[colorr,colorg,colorb]
  1151. append Alpha_Array colora
  1152. )
  1153. )
  1154. if UVType_array[z] == 0x42 do(
  1155. for x = 1 to VertexAmount_array[z] do(
  1156. colorr = readbyte m #unsigned
  1157. colorg = readbyte m #unsigned
  1158. colorb = readbyte m #unsigned
  1159. colora = (readbyte m #unsigned) as float / 127
  1160. if colora >= 254 do(colora = 255)
  1161. if colormult == true do(
  1162. colorr = colorr * 2
  1163. colorg = colorg * 2
  1164. colorb = colorb * 2
  1165. if colorr >= 254 do(colorr = 255)
  1166. if colorg >= 254 do(colorg = 255)
  1167. if colorb >= 254 do(colorb = 255)
  1168. )
  1169. tu = (readBEHalfFloat m) * 2
  1170. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1171. tu2 = (readBEHalfFloat m) * 2
  1172. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1173. tu3 = (readBEHalfFloat m) * 2
  1174. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1175. tu4 = (readBEHalfFloat m) * 2
  1176. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  1177. append UV_array[tu, tv, 0]
  1178. append UV2_array[tu2, tv2, 0]
  1179. append UV3_array[tu3, tv3, 0]
  1180. append UV4_array[tu4, tv4, 0]
  1181. append Color_Array[colorr,colorg,colorb]
  1182. append Alpha_Array colora
  1183. )
  1184. )
  1185.  
  1186. fseek m VertexAddStart_array[z] #seek_set
  1187. for x = 1 to VertexAmount_array[z] do(
  1188. vx = readBEfloat m
  1189. vy = readBEfloat m
  1190. vz = readBEfloat m
  1191. nx = readBEfloat m
  1192. ny = readBEfloat m
  1193. nz = readBEfloat m
  1194. nq = readBEfloat m
  1195. nr = readBEfloat m
  1196. Bone1 = readBElong m + 1
  1197. Bone2 = readBElong m + 1
  1198. Bone3 = readBElong m + 1
  1199. Bone4 = readBElong m + 1
  1200. Weight1 = readBEfloat m
  1201. Weight2 = readBEfloat m
  1202. Weight3 = readBEfloat m
  1203. Weight4 = readBEfloat m
  1204. append Vert_array[vx, vy, vz]
  1205. append Normal_array[nx, ny, nz]
  1206. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  1207. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  1208. )
  1209. )
  1210. (VertexType_array[z] == 0x13):(
  1211. if UVType_array[z] == 0x10 do(
  1212. for x = 1 to VertexAmount_array[z] do(
  1213. colorr = 127
  1214. colorg = 127
  1215. colorb = 127
  1216. colora = 1 as float
  1217. if colormult == true do(
  1218. colorr = colorr * 2
  1219. colorg = colorg * 2
  1220. colorb = colorb * 2
  1221. if colorr >= 254 do(colorr = 255)
  1222. if colorg >= 254 do(colorg = 255)
  1223. if colorb >= 254 do(colorb = 255)
  1224. )
  1225. tu = (readBEHalfFloat m) * 2
  1226. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1227. append UV_array[tu, tv, 0]
  1228. append Color_Array[colorr,colorg,colorb]
  1229. append Alpha_Array colora
  1230. )
  1231. )
  1232. if UVType_array[z] == 0x12 do(
  1233. for x = 1 to VertexAmount_array[z] do(
  1234. colorr = readbyte m #unsigned
  1235. colorg = readbyte m #unsigned
  1236. colorb = readbyte m #unsigned
  1237. colora = (readbyte m #unsigned) as float / 127
  1238. if colora >= 254 do(colora = 255)
  1239. if colormult == true do(
  1240. colorr = colorr * 2
  1241. colorg = colorg * 2
  1242. colorb = colorb * 2
  1243. if colorr >= 254 do(colorr = 255)
  1244. if colorg >= 254 do(colorg = 255)
  1245. if colorb >= 254 do(colorb = 255)
  1246. )
  1247. tu = (readBEHalfFloat m) * 2
  1248. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1249. append UV_array[tu, tv, 0]
  1250. append Color_Array[colorr,colorg,colorb]
  1251. append Alpha_Array colora
  1252. )
  1253. )
  1254. if UVType_array[z] == 0x22 do(
  1255. for x = 1 to VertexAmount_array[z] do(
  1256. colorr = readbyte m #unsigned
  1257. colorg = readbyte m #unsigned
  1258. colorb = readbyte m #unsigned
  1259. colora = (readbyte m #unsigned) as float / 127
  1260. if colora >= 254 do(colora = 255)
  1261. if colormult == true do(
  1262. colorr = colorr * 2
  1263. colorg = colorg * 2
  1264. colorb = colorb * 2
  1265. if colorr >= 254 do(colorr = 255)
  1266. if colorg >= 254 do(colorg = 255)
  1267. if colorb >= 254 do(colorb = 255)
  1268. )
  1269. tu = (readBEHalfFloat m) * 2
  1270. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1271. tu2 = (readBEHalfFloat m) * 2
  1272. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1273. append UV_array[tu, tv, 0]
  1274. append UV2_array[tu2, tv2, 0]
  1275. append Color_Array[colorr,colorg,colorb]
  1276. append Alpha_Array colora
  1277. )
  1278. )
  1279. if UVType_array[z] == 0x32 do(
  1280. for x = 1 to VertexAmount_array[z] do(
  1281. colorr = readbyte m #unsigned
  1282. colorg = readbyte m #unsigned
  1283. colorb = readbyte m #unsigned
  1284. colora = (readbyte m #unsigned) as float / 127
  1285. if colora >= 254 do(colora = 255)
  1286. if colormult == true do(
  1287. colorr = colorr * 2
  1288. colorg = colorg * 2
  1289. colorb = colorb * 2
  1290. if colorr >= 254 do(colorr = 255)
  1291. if colorg >= 254 do(colorg = 255)
  1292. if colorb >= 254 do(colorb = 255)
  1293. )
  1294. tu = (readBEHalfFloat m) * 2
  1295. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1296. tu2 = (readBEHalfFloat m) * 2
  1297. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1298. tu3 = (readBEHalfFloat m) * 2
  1299. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1300. append UV_array[tu, tv, 0]
  1301. append UV2_array[tu2, tv2, 0]
  1302. append UV3_array[tu3, tv3, 0]
  1303. append Color_Array[colorr,colorg,colorb]
  1304. append Alpha_Array colora
  1305. )
  1306. )
  1307. if UVType_array[z] == 0x42 do(
  1308. for x = 1 to VertexAmount_array[z] do(
  1309. colorr = readbyte m #unsigned
  1310. colorg = readbyte m #unsigned
  1311. colorb = readbyte m #unsigned
  1312. colora = (readbyte m #unsigned) as float / 127
  1313. if colora >= 254 do(colora = 255)
  1314. if colormult == true do(
  1315. colorr = colorr * 2
  1316. colorg = colorg * 2
  1317. colorb = colorb * 2
  1318. if colorr >= 254 do(colorr = 255)
  1319. if colorg >= 254 do(colorg = 255)
  1320. if colorb >= 254 do(colorb = 255)
  1321. )
  1322. tu = (readBEHalfFloat m) * 2
  1323. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1324. tu2 = (readBEHalfFloat m) * 2
  1325. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1326. tu3 = (readBEHalfFloat m) * 2
  1327. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1328. tu4 = (readBEHalfFloat m) * 2
  1329. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  1330. append UV_array[tu, tv, 0]
  1331. append UV2_array[tu2, tv2, 0]
  1332. append UV3_array[tu3, tv3, 0]
  1333. append UV4_array[tu4, tv4, 0]
  1334. append Color_Array[colorr,colorg,colorb]
  1335. append Alpha_Array colora
  1336. )
  1337. )
  1338.  
  1339. fseek m VertexAddStart_array[z] #seek_set
  1340. for x = 1 to VertexAmount_array[z] do(
  1341. vx = readBEfloat m
  1342. vy = readBEfloat m
  1343. vz = readBEfloat m
  1344. vq = readBEfloat m
  1345. nx = readBEfloat m
  1346. ny = readBEfloat m
  1347. nz = readBEfloat m
  1348. nq = readBEfloat m
  1349. bnx = readBEfloat m
  1350. bny = readBEfloat m
  1351. bnz = readBEfloat m
  1352. bnq = readBEfloat m
  1353. tanx = readBEfloat m
  1354. tany = readBEfloat m
  1355. tanz = readBEfloat m
  1356. tanq = readBEfloat m
  1357. Bone1 = readBElong m + 1
  1358. Bone2 = readBElong m + 1
  1359. Bone3 = readBElong m + 1
  1360. Bone4 = readBElong m + 1
  1361. Weight1 = readBEfloat m
  1362. Weight2 = readBEfloat m
  1363. Weight3 = readBEfloat m
  1364. Weight4 = readBEfloat m
  1365. append Vert_array[vx, vy, vz]
  1366. append Normal_array[nx, ny, nz]
  1367. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  1368. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  1369. )
  1370. )
  1371. (VertexType_array[z] == 0x16):(
  1372. if UVType_array[z] == 0x10 do(
  1373. for x = 1 to VertexAmount_array[z] do(
  1374. colorr = 127
  1375. colorg = 127
  1376. colorb = 127
  1377. colora = 1 as float
  1378. if colormult == true do(
  1379. colorr = colorr * 2
  1380. colorg = colorg * 2
  1381. colorb = colorb * 2
  1382. if colorr >= 254 do(colorr = 255)
  1383. if colorg >= 254 do(colorg = 255)
  1384. if colorb >= 254 do(colorb = 255)
  1385. )
  1386. tu = (readBEHalfFloat m) * 2
  1387. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1388. append UV_array[tu, tv, 0]
  1389. append Color_Array[colorr,colorg,colorb]
  1390. append Alpha_Array colora
  1391. )
  1392. )
  1393. if UVType_array[z] == 0x12 do(
  1394. for x = 1 to VertexAmount_array[z] do(
  1395. colorr = readbyte m #unsigned
  1396. colorg = readbyte m #unsigned
  1397. colorb = readbyte m #unsigned
  1398. colora = (readbyte m #unsigned) as float / 127
  1399. if colora >= 254 do(colora = 255)
  1400. if colormult == true do(
  1401. colorr = colorr * 2
  1402. colorg = colorg * 2
  1403. colorb = colorb * 2
  1404. if colorr >= 254 do(colorr = 255)
  1405. if colorg >= 254 do(colorg = 255)
  1406. if colorb >= 254 do(colorb = 255)
  1407. )
  1408. tu = (readBEHalfFloat m) * 2
  1409. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1410. append UV_array[tu, tv, 0]
  1411. append Color_Array[colorr,colorg,colorb]
  1412. append Alpha_Array colora
  1413. )
  1414. )
  1415. if UVType_array[z] == 0x22 do(
  1416. for x = 1 to VertexAmount_array[z] do(
  1417. colorr = readbyte m #unsigned
  1418. colorg = readbyte m #unsigned
  1419. colorb = readbyte m #unsigned
  1420. colora = (readbyte m #unsigned) as float / 127
  1421. if colora >= 254 do(colora = 255)
  1422. if colormult == true do(
  1423. colorr = colorr * 2
  1424. colorg = colorg * 2
  1425. colorb = colorb * 2
  1426. if colorr >= 254 do(colorr = 255)
  1427. if colorg >= 254 do(colorg = 255)
  1428. if colorb >= 254 do(colorb = 255)
  1429. )
  1430. tu = (readBEHalfFloat m) * 2
  1431. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1432. tu2 = (readBEHalfFloat m) * 2
  1433. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1434. append UV_array[tu, tv, 0]
  1435. append UV2_array[tu2, tv2, 0]
  1436. append Color_Array[colorr,colorg,colorb]
  1437. append Alpha_Array colora
  1438. )
  1439. )
  1440. if UVType_array[z] == 0x32 do(
  1441. for x = 1 to VertexAmount_array[z] do(
  1442. colorr = readbyte m #unsigned
  1443. colorg = readbyte m #unsigned
  1444. colorb = readbyte m #unsigned
  1445. colora = (readbyte m #unsigned) as float / 127
  1446. if colora >= 254 do(colora = 255)
  1447. if colormult == true do(
  1448. colorr = colorr * 2
  1449. colorg = colorg * 2
  1450. colorb = colorb * 2
  1451. if colorr >= 254 do(colorr = 255)
  1452. if colorg >= 254 do(colorg = 255)
  1453. if colorb >= 254 do(colorb = 255)
  1454. )
  1455. tu = (readBEHalfFloat m) * 2
  1456. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1457. tu2 = (readBEHalfFloat m) * 2
  1458. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1459. tu3 = (readBEHalfFloat m) * 2
  1460. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1461. append UV_array[tu, tv, 0]
  1462. append UV2_array[tu2, tv2, 0]
  1463. append UV3_array[tu3, tv3, 0]
  1464. append Color_Array[colorr,colorg,colorb]
  1465. append Alpha_Array colora
  1466. )
  1467. )
  1468. if UVType_array[z] == 0x42 do(
  1469. for x = 1 to VertexAmount_array[z] do(
  1470. colorr = readbyte m #unsigned
  1471. colorg = readbyte m #unsigned
  1472. colorb = readbyte m #unsigned
  1473. colora = (readbyte m #unsigned) as float / 127
  1474. if colora >= 254 do(colora = 255)
  1475. if colormult == true do(
  1476. colorr = colorr * 2
  1477. colorg = colorg * 2
  1478. colorb = colorb * 2
  1479. if colorr >= 254 do(colorr = 255)
  1480. if colorg >= 254 do(colorg = 255)
  1481. if colorb >= 254 do(colorb = 255)
  1482. )
  1483. tu = (readBEHalfFloat m) * 2
  1484. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1485. tu2 = (readBEHalfFloat m) * 2
  1486. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1487. tu3 = (readBEHalfFloat m) * 2
  1488. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1489. tu4 = (readBEHalfFloat m) * 2
  1490. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  1491. append UV_array[tu, tv, 0]
  1492. append UV2_array[tu2, tv2, 0]
  1493. append UV3_array[tu3, tv3, 0]
  1494. append UV4_array[tu4, tv4, 0]
  1495. append Color_Array[colorr,colorg,colorb]
  1496. append Alpha_Array colora
  1497. )
  1498. )
  1499.  
  1500. fseek m VertexAddStart_array[z] #seek_set
  1501. for x = 1 to VertexAmount_array[z] do(
  1502. vx = readBEfloat m
  1503. vy = readBEfloat m
  1504. vz = readBEfloat m
  1505. nx = readBEhalffloat m
  1506. ny = readBEhalffloat m
  1507. nz = readBEhalffloat m
  1508. nq = readBEhalffloat m
  1509. Bone1 = readBElong m + 1
  1510. Bone2 = readBElong m + 1
  1511. Bone3 = readBElong m + 1
  1512. Bone4 = readBElong m + 1
  1513. Weight1 = readBEfloat m
  1514. Weight2 = readBEfloat m
  1515. Weight3 = readBEfloat m
  1516. Weight4 = readBEfloat m
  1517. append Vert_array[vx, vy, vz]
  1518. append Normal_array[nx, ny, nz]
  1519. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  1520. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  1521. )
  1522. )
  1523. (VertexType_array[z] == 0x17):(
  1524. if UVType_array[z] == 0x10 do(
  1525. for x = 1 to VertexAmount_array[z] do(
  1526. colorr = 127
  1527. colorg = 127
  1528. colorb = 127
  1529. colora = 1 as float
  1530. if colormult == true do(
  1531. colorr = colorr * 2
  1532. colorg = colorg * 2
  1533. colorb = colorb * 2
  1534. if colorr >= 254 do(colorr = 255)
  1535. if colorg >= 254 do(colorg = 255)
  1536. if colorb >= 254 do(colorb = 255)
  1537. )
  1538. tu = (readBEHalfFloat m) * 2
  1539. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1540. append UV_array[tu, tv, 0]
  1541. append Color_Array[colorr,colorg,colorb]
  1542. append Alpha_Array colora
  1543. )
  1544. )
  1545. if UVType_array[z] == 0x12 do(
  1546. for x = 1 to VertexAmount_array[z] do(
  1547. colorr = readbyte m #unsigned
  1548. colorg = readbyte m #unsigned
  1549. colorb = readbyte m #unsigned
  1550. colora = (readbyte m #unsigned) as float / 127
  1551. if colora >= 254 do(colora = 255)
  1552. if colormult == true do(
  1553. colorr = colorr * 2
  1554. colorg = colorg * 2
  1555. colorb = colorb * 2
  1556. if colorr >= 254 do(colorr = 255)
  1557. if colorg >= 254 do(colorg = 255)
  1558. if colorb >= 254 do(colorb = 255)
  1559. )
  1560. tu = (readBEHalfFloat m) * 2
  1561. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1562. append UV_array[tu, tv, 0]
  1563. append Color_Array[colorr,colorg,colorb]
  1564. append Alpha_Array colora
  1565. )
  1566. )
  1567. if UVType_array[z] == 0x22 do(
  1568. for x = 1 to VertexAmount_array[z] do(
  1569. colorr = readbyte m #unsigned
  1570. colorg = readbyte m #unsigned
  1571. colorb = readbyte m #unsigned
  1572. colora = (readbyte m #unsigned) as float / 127
  1573. if colora >= 254 do(colora = 255)
  1574. if colormult == true do(
  1575. colorr = colorr * 2
  1576. colorg = colorg * 2
  1577. colorb = colorb * 2
  1578. if colorr >= 254 do(colorr = 255)
  1579. if colorg >= 254 do(colorg = 255)
  1580. if colorb >= 254 do(colorb = 255)
  1581. )
  1582. tu = (readBEHalfFloat m) * 2
  1583. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1584. tu2 = (readBEHalfFloat m) * 2
  1585. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1586. append UV_array[tu, tv, 0]
  1587. append UV2_array[tu2, tv2, 0]
  1588. append Color_Array[colorr,colorg,colorb]
  1589. append Alpha_Array colora
  1590. )
  1591. )
  1592. if UVType_array[z] == 0x32 do(
  1593. for x = 1 to VertexAmount_array[z] do(
  1594. colorr = readbyte m #unsigned
  1595. colorg = readbyte m #unsigned
  1596. colorb = readbyte m #unsigned
  1597. colora = (readbyte m #unsigned) as float / 127
  1598. if colora >= 254 do(colora = 255)
  1599. if colormult == true do(
  1600. colorr = colorr * 2
  1601. colorg = colorg * 2
  1602. colorb = colorb * 2
  1603. if colorr >= 254 do(colorr = 255)
  1604. if colorg >= 254 do(colorg = 255)
  1605. if colorb >= 254 do(colorb = 255)
  1606. )
  1607. tu = (readBEHalfFloat m) * 2
  1608. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1609. tu2 = (readBEHalfFloat m) * 2
  1610. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1611. tu3 = (readBEHalfFloat m) * 2
  1612. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1613. append UV_array[tu, tv, 0]
  1614. append UV2_array[tu2, tv2, 0]
  1615. append UV3_array[tu3, tv3, 0]
  1616. append Color_Array[colorr,colorg,colorb]
  1617. append Alpha_Array colora
  1618. )
  1619. )
  1620. if UVType_array[z] == 0x42 do(
  1621. for x = 1 to VertexAmount_array[z] do(
  1622. colorr = readbyte m #unsigned
  1623. colorg = readbyte m #unsigned
  1624. colorb = readbyte m #unsigned
  1625. colora = (readbyte m #unsigned) as float / 127
  1626. if colora >= 254 do(colora = 255)
  1627. if colormult == true do(
  1628. colorr = colorr * 2
  1629. colorg = colorg * 2
  1630. colorb = colorb * 2
  1631. if colorr >= 254 do(colorr = 255)
  1632. if colorg >= 254 do(colorg = 255)
  1633. if colorb >= 254 do(colorb = 255)
  1634. )
  1635. tu = (readBEHalfFloat m) * 2
  1636. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1637. tu2 = (readBEHalfFloat m) * 2
  1638. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1639. tu3 = (readBEHalfFloat m) * 2
  1640. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1641. tu4 = (readBEHalfFloat m) * 2
  1642. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  1643. append UV_array[tu, tv, 0]
  1644. append UV2_array[tu2, tv2, 0]
  1645. append UV3_array[tu3, tv3, 0]
  1646. append UV4_array[tu4, tv4, 0]
  1647. append Color_Array[colorr,colorg,colorb]
  1648. append Alpha_Array colora
  1649. )
  1650. )
  1651.  
  1652. fseek m VertexAddStart_array[z] #seek_set
  1653. for x = 1 to VertexAmount_array[z] do(
  1654. vx = readBEfloat m
  1655. vy = readBEfloat m
  1656. vz = readBEfloat m
  1657. nx = readBEhalffloat m
  1658. ny = readBEhalffloat m
  1659. nz = readBEhalffloat m
  1660. nq = readBEhalffloat m
  1661. bnx = readBEhalffloat m
  1662. bny = readBEhalffloat m
  1663. bnz = readBEhalffloat m
  1664. bnq = readBEhalffloat m
  1665. tanx = readBEhalffloat m
  1666. tany = readBEhalffloat m
  1667. tanz = readBEhalffloat m
  1668. tanq = readBEhalffloat m
  1669. Bone1 = readBElong m + 1
  1670. Bone2 = readBElong m + 1
  1671. Bone3 = readBElong m + 1
  1672. Bone4 = readBElong m + 1
  1673. Weight1 = readBEfloat m
  1674. Weight2 = readBEfloat m
  1675. Weight3 = readBEfloat m
  1676. Weight4 = readBEfloat m
  1677. append Vert_array[vx, vy, vz]
  1678. append Normal_array[nx, ny, nz]
  1679. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  1680. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  1681. )
  1682. )
  1683. (VertexType_array[z] == 0x21):(
  1684. if UVType_array[z] == 0x10 do(
  1685. for x = 1 to VertexAmount_array[z] do(
  1686. colorr = 127
  1687. colorg = 127
  1688. colorb = 127
  1689. colora = 1 as float
  1690. if colormult == true do(
  1691. colorr = colorr * 2
  1692. colorg = colorg * 2
  1693. colorb = colorb * 2
  1694. if colorr >= 254 do(colorr = 255)
  1695. if colorg >= 254 do(colorg = 255)
  1696. if colorb >= 254 do(colorb = 255)
  1697. )
  1698. tu = (readBEHalfFloat m) * 2
  1699. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1700. append UV_array[tu, tv, 0]
  1701. append Color_Array[colorr,colorg,colorb]
  1702. append Alpha_Array colora
  1703. )
  1704. )
  1705. if UVType_array[z] == 0x12 do(
  1706. for x = 1 to VertexAmount_array[z] do(
  1707. colorr = readbyte m #unsigned
  1708. colorg = readbyte m #unsigned
  1709. colorb = readbyte m #unsigned
  1710. colora = (readbyte m #unsigned) as float / 127
  1711. if colora >= 254 do(colora = 255)
  1712. if colormult == true do(
  1713. colorr = colorr * 2
  1714. colorg = colorg * 2
  1715. colorb = colorb * 2
  1716. if colorr >= 254 do(colorr = 255)
  1717. if colorg >= 254 do(colorg = 255)
  1718. if colorb >= 254 do(colorb = 255)
  1719. )
  1720. tu = (readBEHalfFloat m) * 2
  1721. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1722. append UV_array[tu, tv, 0]
  1723. append Color_Array[colorr,colorg,colorb]
  1724. append Alpha_Array colora
  1725. )
  1726. )
  1727. if UVType_array[z] == 0x22 do(
  1728. for x = 1 to VertexAmount_array[z] do(
  1729. colorr = readbyte m #unsigned
  1730. colorg = readbyte m #unsigned
  1731. colorb = readbyte m #unsigned
  1732. colora = (readbyte m #unsigned) as float / 127
  1733. if colora >= 254 do(colora = 255)
  1734. if colormult == true do(
  1735. colorr = colorr * 2
  1736. colorg = colorg * 2
  1737. colorb = colorb * 2
  1738. if colorr >= 254 do(colorr = 255)
  1739. if colorg >= 254 do(colorg = 255)
  1740. if colorb >= 254 do(colorb = 255)
  1741. )
  1742. tu = (readBEHalfFloat m) * 2
  1743. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1744. tu2 = (readBEHalfFloat m) * 2
  1745. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1746. append UV_array[tu, tv, 0]
  1747. append UV2_array[tu2, tv2, 0]
  1748. append Color_Array[colorr,colorg,colorb]
  1749. append Alpha_Array colora
  1750. )
  1751. )
  1752. if UVType_array[z] == 0x32 do(
  1753. for x = 1 to VertexAmount_array[z] do(
  1754. colorr = readbyte m #unsigned
  1755. colorg = readbyte m #unsigned
  1756. colorb = readbyte m #unsigned
  1757. colora = (readbyte m #unsigned) as float / 127
  1758. if colora >= 254 do(colora = 255)
  1759. if colormult == true do(
  1760. colorr = colorr * 2
  1761. colorg = colorg * 2
  1762. colorb = colorb * 2
  1763. if colorr >= 254 do(colorr = 255)
  1764. if colorg >= 254 do(colorg = 255)
  1765. if colorb >= 254 do(colorb = 255)
  1766. )
  1767. tu = (readBEHalfFloat m) * 2
  1768. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1769. tu2 = (readBEHalfFloat m) * 2
  1770. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1771. tu3 = (readBEHalfFloat m) * 2
  1772. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1773. append UV_array[tu, tv, 0]
  1774. append UV2_array[tu2, tv2, 0]
  1775. append UV3_array[tu3, tv3, 0]
  1776. append Color_Array[colorr,colorg,colorb]
  1777. append Alpha_Array colora
  1778. )
  1779. )
  1780. if UVType_array[z] == 0x42 do(
  1781. for x = 1 to VertexAmount_array[z] do(
  1782. colorr = readbyte m #unsigned
  1783. colorg = readbyte m #unsigned
  1784. colorb = readbyte m #unsigned
  1785. colora = (readbyte m #unsigned) as float / 127
  1786. if colora >= 254 do(colora = 255)
  1787. if colormult == true do(
  1788. colorr = colorr * 2
  1789. colorg = colorg * 2
  1790. colorb = colorb * 2
  1791. if colorr >= 254 do(colorr = 255)
  1792. if colorg >= 254 do(colorg = 255)
  1793. if colorb >= 254 do(colorb = 255)
  1794. )
  1795. tu = (readBEHalfFloat m) * 2
  1796. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1797. tu2 = (readBEHalfFloat m) * 2
  1798. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1799. tu3 = (readBEHalfFloat m) * 2
  1800. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1801. tu4 = (readBEHalfFloat m) * 2
  1802. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  1803. append UV_array[tu, tv, 0]
  1804. append UV2_array[tu2, tv2, 0]
  1805. append UV3_array[tu3, tv3, 0]
  1806. append UV4_array[tu4, tv4, 0]
  1807. append Color_Array[colorr,colorg,colorb]
  1808. append Alpha_Array colora
  1809. )
  1810. )
  1811.  
  1812. fseek m VertexAddStart_array[z] #seek_set
  1813. for x = 1 to VertexAmount_array[z] do(
  1814. vx = readBEfloat m
  1815. vy = readBEfloat m
  1816. vz = readBEfloat m
  1817. nx = readBEfloat m
  1818. ny = readBEfloat m
  1819. nz = readBEfloat m
  1820. nq = readBEfloat m
  1821. nr = readBEfloat m
  1822. Bone1 = readBEword m + 1
  1823. Bone2 = readBEword m + 1
  1824. Bone3 = readBEword m + 1
  1825. Bone4 = readBEword m + 1
  1826. Weight1 = readBEhalffloat m
  1827. Weight2 = readBEhalffloat m
  1828. Weight3 = readBEhalffloat m
  1829. Weight4 = readBEhalffloat m
  1830. append Vert_array[vx, vy, vz]
  1831. append Normal_array[nx, ny, nz]
  1832. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  1833. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  1834. )
  1835. )
  1836. (VertexType_array[z] == 0x23):(
  1837. if UVType_array[z] == 0x10 do(
  1838. for x = 1 to VertexAmount_array[z] do(
  1839. colorr = 127
  1840. colorg = 127
  1841. colorb = 127
  1842. colora = 1 as float
  1843. if colormult == true do(
  1844. colorr = colorr * 2
  1845. colorg = colorg * 2
  1846. colorb = colorb * 2
  1847. if colorr >= 254 do(colorr = 255)
  1848. if colorg >= 254 do(colorg = 255)
  1849. if colorb >= 254 do(colorb = 255)
  1850. )
  1851. tu = (readBEHalfFloat m) * 2
  1852. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1853. append UV_array[tu, tv, 0]
  1854. append Color_Array[colorr,colorg,colorb]
  1855. append Alpha_Array colora
  1856. )
  1857. )
  1858. if UVType_array[z] == 0x12 do(
  1859. for x = 1 to VertexAmount_array[z] do(
  1860. colorr = readbyte m #unsigned
  1861. colorg = readbyte m #unsigned
  1862. colorb = readbyte m #unsigned
  1863. colora = (readbyte m #unsigned) as float / 127
  1864. if colora >= 254 do(colora = 255)
  1865. if colormult == true do(
  1866. colorr = colorr * 2
  1867. colorg = colorg * 2
  1868. colorb = colorb * 2
  1869. if colorr >= 254 do(colorr = 255)
  1870. if colorg >= 254 do(colorg = 255)
  1871. if colorb >= 254 do(colorb = 255)
  1872. )
  1873. tu = (readBEHalfFloat m) * 2
  1874. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1875. append UV_array[tu, tv, 0]
  1876. append Color_Array[colorr,colorg,colorb]
  1877. append Alpha_Array colora
  1878. )
  1879. )
  1880. if UVType_array[z] == 0x22 do(
  1881. for x = 1 to VertexAmount_array[z] do(
  1882. colorr = readbyte m #unsigned
  1883. colorg = readbyte m #unsigned
  1884. colorb = readbyte m #unsigned
  1885. colora = (readbyte m #unsigned) as float / 127
  1886. if colora >= 254 do(colora = 255)
  1887. if colormult == true do(
  1888. colorr = colorr * 2
  1889. colorg = colorg * 2
  1890. colorb = colorb * 2
  1891. if colorr >= 254 do(colorr = 255)
  1892. if colorg >= 254 do(colorg = 255)
  1893. if colorb >= 254 do(colorb = 255)
  1894. )
  1895. tu = (readBEHalfFloat m) * 2
  1896. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1897. tu2 = (readBEHalfFloat m) * 2
  1898. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1899. append UV_array[tu, tv, 0]
  1900. append UV2_array[tu2, tv2, 0]
  1901. append Color_Array[colorr,colorg,colorb]
  1902. append Alpha_Array colora
  1903. )
  1904. )
  1905. if UVType_array[z] == 0x32 do(
  1906. for x = 1 to VertexAmount_array[z] do(
  1907. colorr = readbyte m #unsigned
  1908. colorg = readbyte m #unsigned
  1909. colorb = readbyte m #unsigned
  1910. colora = (readbyte m #unsigned) as float / 127
  1911. if colora >= 254 do(colora = 255)
  1912. if colormult == true do(
  1913. colorr = colorr * 2
  1914. colorg = colorg * 2
  1915. colorb = colorb * 2
  1916. if colorr >= 254 do(colorr = 255)
  1917. if colorg >= 254 do(colorg = 255)
  1918. if colorb >= 254 do(colorb = 255)
  1919. )
  1920. tu = (readBEHalfFloat m) * 2
  1921. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1922. tu2 = (readBEHalfFloat m) * 2
  1923. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1924. tu3 = (readBEHalfFloat m) * 2
  1925. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1926. append UV_array[tu, tv, 0]
  1927. append UV2_array[tu2, tv2, 0]
  1928. append UV3_array[tu3, tv3, 0]
  1929. append Color_Array[colorr,colorg,colorb]
  1930. append Alpha_Array colora
  1931. )
  1932. )
  1933. if UVType_array[z] == 0x42 do(
  1934. for x = 1 to VertexAmount_array[z] do(
  1935. colorr = readbyte m #unsigned
  1936. colorg = readbyte m #unsigned
  1937. colorb = readbyte m #unsigned
  1938. colora = (readbyte m #unsigned) as float / 127
  1939. if colora >= 254 do(colora = 255)
  1940. if colormult == true do(
  1941. colorr = colorr * 2
  1942. colorg = colorg * 2
  1943. colorb = colorb * 2
  1944. if colorr >= 254 do(colorr = 255)
  1945. if colorg >= 254 do(colorg = 255)
  1946. if colorb >= 254 do(colorb = 255)
  1947. )
  1948. tu = (readBEHalfFloat m) * 2
  1949. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  1950. tu2 = (readBEHalfFloat m) * 2
  1951. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  1952. tu3 = (readBEHalfFloat m) * 2
  1953. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  1954. tu4 = (readBEHalfFloat m) * 2
  1955. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  1956. append UV_array[tu, tv, 0]
  1957. append UV2_array[tu2, tv2, 0]
  1958. append UV3_array[tu3, tv3, 0]
  1959. append UV4_array[tu4, tv4, 0]
  1960. append Color_Array[colorr,colorg,colorb]
  1961. append Alpha_Array colora
  1962. )
  1963. )
  1964.  
  1965. fseek m VertexAddStart_array[z] #seek_set
  1966. for x = 1 to VertexAmount_array[z] do(
  1967. vx = readBEfloat m
  1968. vy = readBEfloat m
  1969. vz = readBEfloat m
  1970. vq = readBEfloat m
  1971. nx = readBEfloat m
  1972. ny = readBEfloat m
  1973. nz = readBEfloat m
  1974. nq = readBEfloat m
  1975. bnx = readBEfloat m
  1976. bny = readBEfloat m
  1977. bnz = readBEfloat m
  1978. bnq = readBEfloat m
  1979. tanx = readBEfloat m
  1980. tany = readBEfloat m
  1981. tanz = readBEfloat m
  1982. tanq = readBEfloat m
  1983. Bone1 = readBEword m + 1
  1984. Bone2 = readBEword m + 1
  1985. Bone3 = readBEword m + 1
  1986. Bone4 = readBEword m + 1
  1987. Weight1 = readBEhalffloat m
  1988. Weight2 = readBEhalffloat m
  1989. Weight3 = readBEhalffloat m
  1990. Weight4 = readBEhalffloat m
  1991. append Vert_array[vx, vy, vz]
  1992. append Normal_array[nx, ny, nz]
  1993. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  1994. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  1995. )
  1996. )
  1997. (VertexType_array[z] == 0x26):(
  1998. if UVType_array[z] == 0x10 do(
  1999. for x = 1 to VertexAmount_array[z] do(
  2000. colorr = 127
  2001. colorg = 127
  2002. colorb = 127
  2003. colora = 1 as float
  2004. if colormult == true do(
  2005. colorr = colorr * 2
  2006. colorg = colorg * 2
  2007. colorb = colorb * 2
  2008. if colorr >= 254 do(colorr = 255)
  2009. if colorg >= 254 do(colorg = 255)
  2010. if colorb >= 254 do(colorb = 255)
  2011. )
  2012. tu = (readBEHalfFloat m) * 2
  2013. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2014. append UV_array[tu, tv, 0]
  2015. append Color_Array[colorr,colorg,colorb]
  2016. append Alpha_Array colora
  2017. )
  2018. )
  2019. if UVType_array[z] == 0x12 do(
  2020. for x = 1 to VertexAmount_array[z] do(
  2021. colorr = readbyte m #unsigned
  2022. colorg = readbyte m #unsigned
  2023. colorb = readbyte m #unsigned
  2024. colora = (readbyte m #unsigned) as float / 127
  2025. if colora >= 254 do(colora = 255)
  2026. if colormult == true do(
  2027. colorr = colorr * 2
  2028. colorg = colorg * 2
  2029. colorb = colorb * 2
  2030. if colorr >= 254 do(colorr = 255)
  2031. if colorg >= 254 do(colorg = 255)
  2032. if colorb >= 254 do(colorb = 255)
  2033. )
  2034. tu = (readBEHalfFloat m) * 2
  2035. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2036. append UV_array[tu, tv, 0]
  2037. append Color_Array[colorr,colorg,colorb]
  2038. append Alpha_Array colora
  2039. )
  2040. )
  2041. if UVType_array[z] == 0x22 do(
  2042. for x = 1 to VertexAmount_array[z] do(
  2043. colorr = readbyte m #unsigned
  2044. colorg = readbyte m #unsigned
  2045. colorb = readbyte m #unsigned
  2046. colora = (readbyte m #unsigned) as float / 127
  2047. if colora >= 254 do(colora = 255)
  2048. if colormult == true do(
  2049. colorr = colorr * 2
  2050. colorg = colorg * 2
  2051. colorb = colorb * 2
  2052. if colorr >= 254 do(colorr = 255)
  2053. if colorg >= 254 do(colorg = 255)
  2054. if colorb >= 254 do(colorb = 255)
  2055. )
  2056. tu = (readBEHalfFloat m) * 2
  2057. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2058. tu2 = (readBEHalfFloat m) * 2
  2059. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2060. append UV_array[tu, tv, 0]
  2061. append UV2_array[tu2, tv2, 0]
  2062. append Color_Array[colorr,colorg,colorb]
  2063. append Alpha_Array colora
  2064. )
  2065. )
  2066. if UVType_array[z] == 0x32 do(
  2067. for x = 1 to VertexAmount_array[z] do(
  2068. colorr = readbyte m #unsigned
  2069. colorg = readbyte m #unsigned
  2070. colorb = readbyte m #unsigned
  2071. colora = (readbyte m #unsigned) as float / 127
  2072. if colora >= 254 do(colora = 255)
  2073. if colormult == true do(
  2074. colorr = colorr * 2
  2075. colorg = colorg * 2
  2076. colorb = colorb * 2
  2077. if colorr >= 254 do(colorr = 255)
  2078. if colorg >= 254 do(colorg = 255)
  2079. if colorb >= 254 do(colorb = 255)
  2080. )
  2081. tu = (readBEHalfFloat m) * 2
  2082. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2083. tu2 = (readBEHalfFloat m) * 2
  2084. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2085. tu3 = (readBEHalfFloat m) * 2
  2086. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2087. append UV_array[tu, tv, 0]
  2088. append UV2_array[tu2, tv2, 0]
  2089. append UV3_array[tu3, tv3, 0]
  2090. append Color_Array[colorr,colorg,colorb]
  2091. append Alpha_Array colora
  2092. )
  2093. )
  2094. if UVType_array[z] == 0x42 do(
  2095. for x = 1 to VertexAmount_array[z] do(
  2096. colorr = readbyte m #unsigned
  2097. colorg = readbyte m #unsigned
  2098. colorb = readbyte m #unsigned
  2099. colora = (readbyte m #unsigned) as float / 127
  2100. if colora >= 254 do(colora = 255)
  2101. if colormult == true do(
  2102. colorr = colorr * 2
  2103. colorg = colorg * 2
  2104. colorb = colorb * 2
  2105. if colorr >= 254 do(colorr = 255)
  2106. if colorg >= 254 do(colorg = 255)
  2107. if colorb >= 254 do(colorb = 255)
  2108. )
  2109. tu = (readBEHalfFloat m) * 2
  2110. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2111. tu2 = (readBEHalfFloat m) * 2
  2112. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2113. tu3 = (readBEHalfFloat m) * 2
  2114. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2115. tu4 = (readBEHalfFloat m) * 2
  2116. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  2117. append UV_array[tu, tv, 0]
  2118. append UV2_array[tu2, tv2, 0]
  2119. append UV3_array[tu3, tv3, 0]
  2120. append UV4_array[tu4, tv4, 0]
  2121. append Color_Array[colorr,colorg,colorb]
  2122. append Alpha_Array colora
  2123. )
  2124. )
  2125.  
  2126. fseek m VertexAddStart_array[z] #seek_set
  2127. for x = 1 to VertexAmount_array[z] do(
  2128. vx = readBEfloat m
  2129. vy = readBEfloat m
  2130. vz = readBEfloat m
  2131. nx = readBEhalffloat m
  2132. ny = readBEhalffloat m
  2133. nz = readBEhalffloat m
  2134. nq = readBEhalffloat m
  2135. Bone1 = readBEword m + 1
  2136. Bone2 = readBEword m + 1
  2137. Bone3 = readBEword m + 1
  2138. Bone4 = readBEword m + 1
  2139. Weight1 = readBEhalffloat m
  2140. Weight2 = readBEhalffloat m
  2141. Weight3 = readBEhalffloat m
  2142. Weight4 = readBEhalffloat m
  2143. append Vert_array[vx, vy, vz]
  2144. append Normal_array[nx, ny, nz]
  2145. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  2146. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  2147. )
  2148. )
  2149. (VertexType_array[z] == 0x27):(
  2150. if UVType_array[z] == 0x10 do(
  2151. for x = 1 to VertexAmount_array[z] do(
  2152. colorr = 127
  2153. colorg = 127
  2154. colorb = 127
  2155. colora = 1 as float
  2156. if colormult == true do(
  2157. colorr = colorr * 2
  2158. colorg = colorg * 2
  2159. colorb = colorb * 2
  2160. if colorr >= 254 do(colorr = 255)
  2161. if colorg >= 254 do(colorg = 255)
  2162. if colorb >= 254 do(colorb = 255)
  2163. )
  2164. tu = (readBEHalfFloat m) * 2
  2165. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2166. append UV_array[tu, tv, 0]
  2167. append Color_Array[colorr,colorg,colorb]
  2168. append Alpha_Array colora
  2169. )
  2170. )
  2171. if UVType_array[z] == 0x12 do(
  2172. for x = 1 to VertexAmount_array[z] do(
  2173. colorr = readbyte m #unsigned
  2174. colorg = readbyte m #unsigned
  2175. colorb = readbyte m #unsigned
  2176. colora = (readbyte m #unsigned) as float / 127
  2177. if colora >= 254 do(colora = 255)
  2178. if colormult == true do(
  2179. colorr = colorr * 2
  2180. colorg = colorg * 2
  2181. colorb = colorb * 2
  2182. if colorr >= 254 do(colorr = 255)
  2183. if colorg >= 254 do(colorg = 255)
  2184. if colorb >= 254 do(colorb = 255)
  2185. )
  2186. tu = (readBEHalfFloat m) * 2
  2187. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2188. append UV_array[tu, tv, 0]
  2189. append Color_Array[colorr,colorg,colorb]
  2190. append Alpha_Array colora
  2191. )
  2192. )
  2193. if UVType_array[z] == 0x22 do(
  2194. for x = 1 to VertexAmount_array[z] do(
  2195. colorr = readbyte m #unsigned
  2196. colorg = readbyte m #unsigned
  2197. colorb = readbyte m #unsigned
  2198. colora = (readbyte m #unsigned) as float / 127
  2199. if colora >= 254 do(colora = 255)
  2200. if colormult == true do(
  2201. colorr = colorr * 2
  2202. colorg = colorg * 2
  2203. colorb = colorb * 2
  2204. if colorr >= 254 do(colorr = 255)
  2205. if colorg >= 254 do(colorg = 255)
  2206. if colorb >= 254 do(colorb = 255)
  2207. )
  2208. tu = (readBEHalfFloat m) * 2
  2209. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2210. tu2 = (readBEHalfFloat m) * 2
  2211. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2212. append UV_array[tu, tv, 0]
  2213. append UV2_array[tu2, tv2, 0]
  2214. append Color_Array[colorr,colorg,colorb]
  2215. append Alpha_Array colora
  2216. )
  2217. )
  2218. if UVType_array[z] == 0x32 do(
  2219. for x = 1 to VertexAmount_array[z] do(
  2220. colorr = readbyte m #unsigned
  2221. colorg = readbyte m #unsigned
  2222. colorb = readbyte m #unsigned
  2223. colora = (readbyte m #unsigned) as float / 127
  2224. if colora >= 254 do(colora = 255)
  2225. if colormult == true do(
  2226. colorr = colorr * 2
  2227. colorg = colorg * 2
  2228. colorb = colorb * 2
  2229. if colorr >= 254 do(colorr = 255)
  2230. if colorg >= 254 do(colorg = 255)
  2231. if colorb >= 254 do(colorb = 255)
  2232. )
  2233. tu = (readBEHalfFloat m) * 2
  2234. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2235. tu2 = (readBEHalfFloat m) * 2
  2236. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2237. tu3 = (readBEHalfFloat m) * 2
  2238. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2239. append UV_array[tu, tv, 0]
  2240. append UV2_array[tu2, tv2, 0]
  2241. append UV3_array[tu3, tv3, 0]
  2242. append Color_Array[colorr,colorg,colorb]
  2243. append Alpha_Array colora
  2244. )
  2245. )
  2246. if UVType_array[z] == 0x42 do(
  2247. for x = 1 to VertexAmount_array[z] do(
  2248. colorr = readbyte m #unsigned
  2249. colorg = readbyte m #unsigned
  2250. colorb = readbyte m #unsigned
  2251. colora = (readbyte m #unsigned) as float / 127
  2252. if colora >= 254 do(colora = 255)
  2253. if colormult == true do(
  2254. colorr = colorr * 2
  2255. colorg = colorg * 2
  2256. colorb = colorb * 2
  2257. if colorr >= 254 do(colorr = 255)
  2258. if colorg >= 254 do(colorg = 255)
  2259. if colorb >= 254 do(colorb = 255)
  2260. )
  2261. tu = (readBEHalfFloat m) * 2
  2262. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2263. tu2 = (readBEHalfFloat m) * 2
  2264. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2265. tu3 = (readBEHalfFloat m) * 2
  2266. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2267. tu4 = (readBEHalfFloat m) * 2
  2268. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  2269. append UV_array[tu, tv, 0]
  2270. append UV2_array[tu2, tv2, 0]
  2271. append UV3_array[tu3, tv3, 0]
  2272. append UV4_array[tu4, tv4, 0]
  2273. append Color_Array[colorr,colorg,colorb]
  2274. append Alpha_Array colora
  2275. )
  2276. )
  2277.  
  2278. fseek m VertexAddStart_array[z] #seek_set
  2279. for x = 1 to VertexAmount_array[z] do(
  2280. vx = readBEfloat m
  2281. vy = readBEfloat m
  2282. vz = readBEfloat m
  2283. nx = readBEhalffloat m
  2284. ny = readBEhalffloat m
  2285. nz = readBEhalffloat m
  2286. nq = readBEhalffloat m
  2287. bnx = readBEhalffloat m
  2288. bny = readBEhalffloat m
  2289. bnz = readBEhalffloat m
  2290. bnq = readBEhalffloat m
  2291. tanx = readBEhalffloat m
  2292. tany = readBEhalffloat m
  2293. tanz = readBEhalffloat m
  2294. tanq = readBEhalffloat m
  2295. Bone1 = readBEword m + 1
  2296. Bone2 = readBEword m + 1
  2297. Bone3 = readBEword m + 1
  2298. Bone4 = readBEword m + 1
  2299. Weight1 = readBEhalffloat m
  2300. Weight2 = readBEhalffloat m
  2301. Weight3 = readBEhalffloat m
  2302. Weight4 = readBEhalffloat m
  2303. append Vert_array[vx, vy, vz]
  2304. append Normal_array[nx, ny, nz]
  2305. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  2306. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  2307. )
  2308. )
  2309. (VertexType_array[z] == 0x40):(
  2310. if UVType_array[z] == 0x12 do(
  2311. for x = 1 to VertexAmount_array[z] do(
  2312. colorr = readbyte m #unsigned
  2313. colorg = readbyte m #unsigned
  2314. colorb = readbyte m #unsigned
  2315. colora = (readbyte m #unsigned) as float / 127
  2316. if colora >= 254 do(colora = 255)
  2317. if colormult == true do(
  2318. colorr = colorr * 2
  2319. colorg = colorg * 2
  2320. colorb = colorb * 2
  2321. if colorr >= 254 do(colorr = 255)
  2322. if colorg >= 254 do(colorg = 255)
  2323. if colorb >= 254 do(colorb = 255)
  2324. )
  2325. tu = (readBEHalfFloat m) * 2
  2326. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2327. append UV_array[tu, tv, 0]
  2328. append Color_Array[colorr,colorg,colorb]
  2329. append Alpha_Array colora
  2330. )
  2331. )
  2332. if UVType_array[z] == 0x22 do(
  2333. for x = 1 to VertexAmount_array[z] do(
  2334. colorr = readbyte m #unsigned
  2335. colorg = readbyte m #unsigned
  2336. colorb = readbyte m #unsigned
  2337. colora = (readbyte m #unsigned) as float / 127
  2338. if colora >= 254 do(colora = 255)
  2339. if colormult == true do(
  2340. colorr = colorr * 2
  2341. colorg = colorg * 2
  2342. colorb = colorb * 2
  2343. if colorr >= 254 do(colorr = 255)
  2344. if colorg >= 254 do(colorg = 255)
  2345. if colorb >= 254 do(colorb = 255)
  2346. )
  2347. tu = (readBEHalfFloat m) * 2
  2348. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2349. tu2 = (readBEHalfFloat m) * 2
  2350. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2351. append UV_array[tu, tv, 0]
  2352. append UV2_array[tu2, tv2, 0]
  2353. append Color_Array[colorr,colorg,colorb]
  2354. append Alpha_Array colora
  2355. )
  2356. )
  2357. if UVType_array[z] == 0x32 do(
  2358. for x = 1 to VertexAmount_array[z] do(
  2359. colorr = readbyte m #unsigned
  2360. colorg = readbyte m #unsigned
  2361. colorb = readbyte m #unsigned
  2362. colora = (readbyte m #unsigned) as float / 127
  2363. if colora >= 254 do(colora = 255)
  2364. if colormult == true do(
  2365. colorr = colorr * 2
  2366. colorg = colorg * 2
  2367. colorb = colorb * 2
  2368. if colorr >= 254 do(colorr = 255)
  2369. if colorg >= 254 do(colorg = 255)
  2370. if colorb >= 254 do(colorb = 255)
  2371. )
  2372. tu = (readBEHalfFloat m) * 2
  2373. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2374. tu2 = (readBEHalfFloat m) * 2
  2375. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2376. tu3 = (readBEHalfFloat m) * 2
  2377. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2378. append UV_array[tu, tv, 0]
  2379. append UV2_array[tu2, tv2, 0]
  2380. append UV3_array[tu3, tv3, 0]
  2381. append Color_Array[colorr,colorg,colorb]
  2382. append Alpha_Array colora
  2383. )
  2384. )
  2385. if UVType_array[z] == 0x42 do(
  2386. for x = 1 to VertexAmount_array[z] do(
  2387. colorr = readbyte m #unsigned
  2388. colorg = readbyte m #unsigned
  2389. colorb = readbyte m #unsigned
  2390. colora = (readbyte m #unsigned) as float / 127
  2391. if colora >= 254 do(colora = 255)
  2392. if colormult == true do(
  2393. colorr = colorr * 2
  2394. colorg = colorg * 2
  2395. colorb = colorb * 2
  2396. if colorr >= 254 do(colorr = 255)
  2397. if colorg >= 254 do(colorg = 255)
  2398. if colorb >= 254 do(colorb = 255)
  2399. )
  2400. tu = (readBEHalfFloat m) * 2
  2401. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2402. tu2 = (readBEHalfFloat m) * 2
  2403. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2404. tu3 = (readBEHalfFloat m) * 2
  2405. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2406. tu4 = (readBEHalfFloat m) * 2
  2407. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  2408. append UV_array[tu, tv, 0]
  2409. append UV2_array[tu2, tv2, 0]
  2410. append UV3_array[tu3, tv3, 0]
  2411. append UV4_array[tu4, tv4, 0]
  2412. append Color_Array[colorr,colorg,colorb]
  2413. append Alpha_Array colora
  2414. )
  2415. )
  2416.  
  2417. fseek m VertexAddStart_array[z] #seek_set
  2418. for x = 1 to VertexAmount_array[z] do(
  2419. vx = readBEfloat m
  2420. vy = readBEfloat m
  2421. vz = readBEfloat m
  2422. floatyval = readBEfloat m
  2423. Bone1 = readbyte m #unsigned + 1
  2424. Bone2 = readbyte m #unsigned + 1
  2425. Bone3 = readbyte m #unsigned + 1
  2426. Bone4 = readbyte m #unsigned + 1
  2427. Weight1 = (readbyte m #unsigned) as float / 255
  2428. Weight2 = (readbyte m #unsigned) as float / 255
  2429. Weight3 = (readbyte m #unsigned) as float / 255
  2430. Weight4 = (readbyte m #unsigned) as float / 255
  2431. append Vert_array[vx, vy, vz]
  2432. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  2433. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  2434. )
  2435. )
  2436. (VertexType_array[z] == 0x46):(
  2437. if UVType_array[z] == 0x10 do(
  2438. for x = 1 to VertexAmount_array[z] do(
  2439. colorr = 127
  2440. colorg = 127
  2441. colorb = 127
  2442. colora = 1 as float
  2443. if colormult == true do(
  2444. colorr = colorr * 2
  2445. colorg = colorg * 2
  2446. colorb = colorb * 2
  2447. if colorr >= 254 do(colorr = 255)
  2448. if colorg >= 254 do(colorg = 255)
  2449. if colorb >= 254 do(colorb = 255)
  2450. )
  2451. tu = (readBEHalfFloat m) * 2
  2452. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2453. append UV_array[tu, tv, 0]
  2454. append Color_Array[colorr,colorg,colorb]
  2455. append Alpha_Array colora
  2456. )
  2457. )
  2458. if UVType_array[z] == 0x12 do(
  2459. for x = 1 to VertexAmount_array[z] do(
  2460. colorr = readbyte m #unsigned
  2461. colorg = readbyte m #unsigned
  2462. colorb = readbyte m #unsigned
  2463. colora = (readbyte m #unsigned) as float / 127
  2464. if colora >= 254 do(colora = 255)
  2465. if colormult == true do(
  2466. colorr = colorr * 2
  2467. colorg = colorg * 2
  2468. colorb = colorb * 2
  2469. if colorr >= 254 do(colorr = 255)
  2470. if colorg >= 254 do(colorg = 255)
  2471. if colorb >= 254 do(colorb = 255)
  2472. )
  2473. tu = (readBEHalfFloat m) * 2
  2474. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2475. append UV_array[tu, tv, 0]
  2476. append Color_Array[colorr,colorg,colorb]
  2477. append Alpha_Array colora
  2478. )
  2479. )
  2480. if UVType_array[z] == 0x22 do(
  2481. for x = 1 to VertexAmount_array[z] do(
  2482. colorr = readbyte m #unsigned
  2483. colorg = readbyte m #unsigned
  2484. colorb = readbyte m #unsigned
  2485. colora = (readbyte m #unsigned) as float / 127
  2486. if colora >= 254 do(colora = 255)
  2487. if colormult == true do(
  2488. colorr = colorr * 2
  2489. colorg = colorg * 2
  2490. colorb = colorb * 2
  2491. if colorr >= 254 do(colorr = 255)
  2492. if colorg >= 254 do(colorg = 255)
  2493. if colorb >= 254 do(colorb = 255)
  2494. )
  2495. tu = (readBEHalfFloat m) * 2
  2496. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2497. tu2 = (readBEHalfFloat m) * 2
  2498. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2499. append UV_array[tu, tv, 0]
  2500. append UV2_array[tu2, tv2, 0]
  2501. append Color_Array[colorr,colorg,colorb]
  2502. append Alpha_Array colora
  2503. )
  2504. )
  2505. if UVType_array[z] == 0x32 do(
  2506. for x = 1 to VertexAmount_array[z] do(
  2507. colorr = readbyte m #unsigned
  2508. colorg = readbyte m #unsigned
  2509. colorb = readbyte m #unsigned
  2510. colora = (readbyte m #unsigned) as float / 127
  2511. if colora >= 254 do(colora = 255)
  2512. if colormult == true do(
  2513. colorr = colorr * 2
  2514. colorg = colorg * 2
  2515. colorb = colorb * 2
  2516. if colorr >= 254 do(colorr = 255)
  2517. if colorg >= 254 do(colorg = 255)
  2518. if colorb >= 254 do(colorb = 255)
  2519. )
  2520. tu = (readBEHalfFloat m) * 2
  2521. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2522. tu2 = (readBEHalfFloat m) * 2
  2523. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2524. tu3 = (readBEHalfFloat m) * 2
  2525. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2526. append UV_array[tu, tv, 0]
  2527. append UV2_array[tu2, tv2, 0]
  2528. append UV3_array[tu3, tv3, 0]
  2529. append Color_Array[colorr,colorg,colorb]
  2530. append Alpha_Array colora
  2531. )
  2532. )
  2533. if UVType_array[z] == 0x42 do(
  2534. for x = 1 to VertexAmount_array[z] do(
  2535. colorr = readbyte m #unsigned
  2536. colorg = readbyte m #unsigned
  2537. colorb = readbyte m #unsigned
  2538. colora = (readbyte m #unsigned) as float / 127
  2539. if colora >= 254 do(colora = 255)
  2540. if colormult == true do(
  2541. colorr = colorr * 2
  2542. colorg = colorg * 2
  2543. colorb = colorb * 2
  2544. if colorr >= 254 do(colorr = 255)
  2545. if colorg >= 254 do(colorg = 255)
  2546. if colorb >= 254 do(colorb = 255)
  2547. )
  2548. tu = (readBEHalfFloat m) * 2
  2549. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2550. tu2 = (readBEHalfFloat m) * 2
  2551. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2552. tu3 = (readBEHalfFloat m) * 2
  2553. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2554. tu4 = (readBEHalfFloat m) * 2
  2555. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  2556. append UV_array[tu, tv, 0]
  2557. append UV2_array[tu2, tv2, 0]
  2558. append UV3_array[tu3, tv3, 0]
  2559. append UV4_array[tu4, tv4, 0]
  2560. append Color_Array[colorr,colorg,colorb]
  2561. append Alpha_Array colora
  2562. )
  2563. )
  2564.  
  2565. fseek m VertexAddStart_array[z] #seek_set
  2566. for x = 1 to VertexAmount_array[z] do(
  2567. vx = readBEfloat m
  2568. vy = readBEfloat m
  2569. vz = readBEfloat m
  2570. nx = readBEHalfFloat m
  2571. ny = readBEHalfFloat m
  2572. nz = readBEHalfFloat m
  2573. nq = readBEHalfFloat m
  2574. Bone1 = readbyte m #unsigned + 1
  2575. Bone2 = readbyte m #unsigned + 1
  2576. Bone3 = readbyte m #unsigned + 1
  2577. Bone4 = readbyte m #unsigned + 1
  2578. Weight1 = (readbyte m #unsigned) as float / 255
  2579. Weight2 = (readbyte m #unsigned) as float / 255
  2580. Weight3 = (readbyte m #unsigned) as float / 255
  2581. Weight4 = (readbyte m #unsigned) as float / 255
  2582. append Vert_array[vx, vy, vz]
  2583. append Normal_array[nx, ny, nz]
  2584. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  2585. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  2586. )
  2587. )
  2588. (VertexType_array[z] == 0x47):(
  2589. if UVType_array[z] == 0x10 do(
  2590. for x = 1 to VertexAmount_array[z] do(
  2591. colorr = 127
  2592. colorg = 127
  2593. colorb = 127
  2594. colora = 1 as float
  2595. if colormult == true do(
  2596. colorr = colorr * 2
  2597. colorg = colorg * 2
  2598. colorb = colorb * 2
  2599. if colorr >= 254 do(colorr = 255)
  2600. if colorg >= 254 do(colorg = 255)
  2601. if colorb >= 254 do(colorb = 255)
  2602. )
  2603. tu = (readBEHalfFloat m) * 2
  2604. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2605. append UV_array[tu, tv, 0]
  2606. append Color_Array[colorr,colorg,colorb]
  2607. append Alpha_Array colora
  2608. )
  2609. )
  2610. if UVType_array[z] == 0x12 do(
  2611. for x = 1 to VertexAmount_array[z] do(
  2612. colorr = readbyte m #unsigned
  2613. colorg = readbyte m #unsigned
  2614. colorb = readbyte m #unsigned
  2615. colora = (readbyte m #unsigned) as float / 127
  2616. if colora >= 254 do(colora = 255)
  2617. if colormult == true do(
  2618. colorr = colorr * 2
  2619. colorg = colorg * 2
  2620. colorb = colorb * 2
  2621. if colorr >= 254 do(colorr = 255)
  2622. if colorg >= 254 do(colorg = 255)
  2623. if colorb >= 254 do(colorb = 255)
  2624. )
  2625. tu = (readBEHalfFloat m) * 2
  2626. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2627. append UV_array[tu, tv, 0]
  2628. append Color_Array[colorr,colorg,colorb]
  2629. append Alpha_Array colora
  2630. )
  2631. )
  2632. if UVType_array[z] == 0x22 do(
  2633. for x = 1 to VertexAmount_array[z] do(
  2634. colorr = readbyte m #unsigned
  2635. colorg = readbyte m #unsigned
  2636. colorb = readbyte m #unsigned
  2637. colora = (readbyte m #unsigned) as float / 127
  2638. if colora >= 254 do(colora = 255)
  2639. if colormult == true do(
  2640. colorr = colorr * 2
  2641. colorg = colorg * 2
  2642. colorb = colorb * 2
  2643. if colorr >= 254 do(colorr = 255)
  2644. if colorg >= 254 do(colorg = 255)
  2645. if colorb >= 254 do(colorb = 255)
  2646. )
  2647. tu = (readBEHalfFloat m) * 2
  2648. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2649. tu2 = (readBEHalfFloat m) * 2
  2650. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2651. append UV_array[tu, tv, 0]
  2652. append UV2_array[tu2, tv2, 0]
  2653. append Color_Array[colorr,colorg,colorb]
  2654. append Alpha_Array colora
  2655. )
  2656. )
  2657. if UVType_array[z] == 0x32 do(
  2658. for x = 1 to VertexAmount_array[z] do(
  2659. colorr = readbyte m #unsigned
  2660. colorg = readbyte m #unsigned
  2661. colorb = readbyte m #unsigned
  2662. colora = (readbyte m #unsigned) as float / 127
  2663. if colora >= 254 do(colora = 255)
  2664. if colormult == true do(
  2665. colorr = colorr * 2
  2666. colorg = colorg * 2
  2667. colorb = colorb * 2
  2668. if colorr >= 254 do(colorr = 255)
  2669. if colorg >= 254 do(colorg = 255)
  2670. if colorb >= 254 do(colorb = 255)
  2671. )
  2672. tu = (readBEHalfFloat m) * 2
  2673. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2674. tu2 = (readBEHalfFloat m) * 2
  2675. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2676. tu3 = (readBEHalfFloat m) * 2
  2677. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2678. append UV_array[tu, tv, 0]
  2679. append UV2_array[tu2, tv2, 0]
  2680. append UV3_array[tu3, tv3, 0]
  2681. append Color_Array[colorr,colorg,colorb]
  2682. append Alpha_Array colora
  2683. )
  2684. )
  2685. if UVType_array[z] == 0x42 do(
  2686. for x = 1 to VertexAmount_array[z] do(
  2687. colorr = readbyte m #unsigned
  2688. colorg = readbyte m #unsigned
  2689. colorb = readbyte m #unsigned
  2690. colora = (readbyte m #unsigned) as float / 127
  2691. if colora >= 254 do(colora = 255)
  2692. if colormult == true do(
  2693. colorr = colorr * 2
  2694. colorg = colorg * 2
  2695. colorb = colorb * 2
  2696. if colorr >= 254 do(colorr = 255)
  2697. if colorg >= 254 do(colorg = 255)
  2698. if colorb >= 254 do(colorb = 255)
  2699. )
  2700. tu = (readBEHalfFloat m) * 2
  2701. tv = (((readBEHalfFloat m) * 2) * -1) + 1
  2702. tu2 = (readBEHalfFloat m) * 2
  2703. tv2 = (((readBEHalfFloat m) * 2) * -1) + 1
  2704. tu3 = (readBEHalfFloat m) * 2
  2705. tv3 = (((readBEHalfFloat m) * 2) * -1) + 1
  2706. tu4 = (readBEHalfFloat m) * 2
  2707. tv4 = (((readBEHalfFloat m) * 2) * -1) + 1
  2708. append UV_array[tu, tv, 0]
  2709. append UV2_array[tu2, tv2, 0]
  2710. append UV3_array[tu3, tv3, 0]
  2711. append UV4_array[tu4, tv4, 0]
  2712. append Color_Array[colorr,colorg,colorb]
  2713. append Alpha_Array colora
  2714. )
  2715. )
  2716.  
  2717. fseek m VertexAddStart_array[z] #seek_set
  2718. for x = 1 to VertexAmount_array[z] do(
  2719. vx = readBEfloat m
  2720. vy = readBEfloat m
  2721. vz = readBEfloat m
  2722. nx = readBEHalfFloat m
  2723. ny = readBEHalfFloat m
  2724. nz = readBEHalfFloat m
  2725. nq = readBEHalfFloat m
  2726. bnx = readBEHalfFloat m
  2727. bny = readBEHalfFloat m
  2728. bnz = readBEHalfFloat m
  2729. bnq = readBEHalfFloat m
  2730. tanx = readBEHalfFloat m
  2731. tany = readBEHalfFloat m
  2732. tanz = readBEHalfFloat m
  2733. tanq = readBEHalfFloat m
  2734. Bone1 = readbyte m #unsigned + 1
  2735. Bone2 = readbyte m #unsigned + 1
  2736. Bone3 = readbyte m #unsigned + 1
  2737. Bone4 = readbyte m #unsigned + 1
  2738. Weight1 = (readbyte m #unsigned) as float / 255
  2739. Weight2 = (readbyte m #unsigned) as float / 255
  2740. Weight3 = (readbyte m #unsigned) as float / 255
  2741. Weight4 = (readbyte m #unsigned) as float / 255
  2742. append Vert_array[vx, vy, vz]
  2743. append Normal_array[nx, ny, nz]
  2744. append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
  2745. append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
  2746. )
  2747. )
  2748. )
  2749.  
  2750. fseek m PolyStart_array[z] #seek_set
  2751. case of (
  2752. default: (throw("Unknown polygon type!"))
  2753. (PolyType_array[z] == 0x00):(
  2754. FaceCount = PolyAmount_array[z]
  2755. FaceStart = ftell m
  2756. VerStart = (FaceCount * 2) + FaceStart
  2757.  
  2758. StartDirection = 1
  2759. f1 = (ReadBEword m) + 1
  2760. f2 = (ReadBEword m) + 1
  2761. FaceDirection = StartDirection
  2762. Do (
  2763. f3 = (ReadBEword m)
  2764. if (f3==0xFFFF) then (
  2765. f1 = (ReadBEword m) + 1
  2766. f2 = (ReadBEword m) + 1
  2767. FaceDirection = StartDirection
  2768. ) else (
  2769. f3 += 1
  2770. FaceDirection *= -1
  2771. if (f1!=f2)AND(f2!=f3)AND(f3!=f1) then (
  2772. if FaceDirection > 0 then append Face_array [f3,f2,f1]
  2773. else append Face_array [f2,f3,f1]
  2774. )
  2775. f1 = f2
  2776. f2 = f3
  2777. )
  2778. ) while ((ftell m) != (VerStart))
  2779. )
  2780. (PolyType_array[z] == 0x40):(
  2781. for x = 1 to (PolyAmount_array[z] / 3) do(
  2782. fa = readBEword m + 1
  2783. fb = readBEword m + 1
  2784. fc = readBEword m + 1
  2785. append Face_array[fa, fb, fc]
  2786. )
  2787. )
  2788. )
  2789.  
  2790. for b = 1 to W1_array.count Do (
  2791. w = (weight_data boneids:#() weights:#())
  2792. maxweight = 0
  2793.  
  2794. if(W1_array[b].Weight1 != 0) then
  2795. maxweight = maxweight + W1_array[b].Weight1
  2796. if(W1_array[b].Weight2 != 0) then
  2797. maxweight = maxweight + W1_array[b].Weight2
  2798. if(W1_array[b].Weight3 != 0) then
  2799. maxweight = maxweight + W1_array[b].Weight3
  2800. if(W1_array[b].Weight4 != 0) then
  2801. maxweight = maxweight + W1_array[b].Weight4
  2802.  
  2803. if(maxweight != 0) then
  2804. (
  2805. if(W1_array[b].Weight1 != 0) then
  2806. (
  2807. w1 = W1_array[b].Weight1 as float
  2808. append w.boneids (B1_array[b].Bone1)
  2809. append w.weights (w1)
  2810. )
  2811. if(W1_array[b].Weight2 != 0) then
  2812. (
  2813. w2 = W1_array[b].Weight2 as float
  2814. append w.boneids (B1_array[b].Bone2)
  2815. append w.weights (w2)
  2816. )
  2817. if(W1_array[b].Weight3 != 0) then
  2818. (
  2819. w3 = W1_array[b].Weight3 as float
  2820. append w.boneids (B1_array[b].Bone3)
  2821. append w.weights (w3)
  2822. )
  2823. if(W1_array[b].Weight4 != 0) then
  2824. (
  2825. w4 = W1_array[b].Weight4 as float
  2826. append w.boneids (B1_array[b].Bone4)
  2827. append w.weights (w4)
  2828. )
  2829. )
  2830. append Weight_array w
  2831. )
  2832.  
  2833. mat = standardMaterial()
  2834. mat.name = (TextureIDL1_array[z].TexClass as string + "_" + TextureIDL1_array[z].TexGroup as string + "_" + TextureIDL1_array[z].TexSubgroup as string + "_" + TextureIDL1_array[z].TexIndex as string)
  2835. mat.showinviewport = true
  2836. mat.twosided = false
  2837. if PNGTex == false then (tm = Bitmaptexture filename:(p + "model_" + TextureIDL1_array[z].TexClass as string + "_" + TextureIDL1_array[z].TexGroup as string + "_" + TextureIDL1_array[z].TexSubgroup as string + "_" + TextureIDL1_array[z].TexIndex as string + ".dds")) else (tm = Bitmaptexture filename:(p + "model_" + TextureIDL1_array[z].TexClass as string + "_" + TextureIDL1_array[z].TexGroup as string + "_" + TextureIDL1_array[z].TexSubgroup as string + "_" + TextureIDL1_array[z].TexIndex as string + ".png"))
  2838. tm.alphasource = 0
  2839. mat.diffuseMap = tm
  2840. mat.opacityMap = tm
  2841. mat.opacityMap.monoOutput = 1
  2842.  
  2843. msh = mesh vertices:Vert_array faces:Face_array
  2844. msh.numTVerts = Vert_array.count
  2845. if ColorDisable == false then (
  2846. setNumCPVVerts msh msh.numTVerts
  2847. setCVertMode msh true
  2848. setShadeCVerts msh true
  2849. )
  2850. defaultVCFaces msh
  2851. buildTVFaces msh
  2852. fseek m (NameClumpStart + PolyName_array[z]) #seek_set
  2853. PolyName = readstring m
  2854. msh.name = (PolyName + "_")
  2855. msh.material = mat
  2856.  
  2857. for j = 1 to Color_array.count do setvertcolor msh j Color_array[j]
  2858. for j = 1 to Alpha_array.count do(meshop.setVertAlpha msh -2 j Alpha_array[j])
  2859. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  2860. for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
  2861. for j = 1 to msh.numfaces do setFaceSmoothGroup msh j 1
  2862. max modify mode
  2863. select msh
  2864.  
  2865. addmodifier msh (Edit_Normals ()) ui:off
  2866. msh.Edit_Normals.MakeExplicit selection:#{1..Normal_array.count}
  2867. EN_convertVS = msh.Edit_Normals.ConvertVertexSelection
  2868. EN_setNormal = msh.Edit_Normals.SetNormal
  2869. normID = #{}
  2870. for v = 1 to Normal_array.count do
  2871. (
  2872. free normID
  2873. EN_convertVS #{v} &normID
  2874. for id in normID do EN_setNormal id Normal_array[v]
  2875. )
  2876.  
  2877. if BoneArray.count > 0 do(
  2878. skinMod = skin ()
  2879. boneIDMap = #()
  2880. addModifier msh skinMod
  2881. for i = 1 to BoneCount do
  2882. (
  2883. maxbone = getnodebyname BoneArray[i].name
  2884. if i != BoneCount then
  2885. skinOps.addBone skinMod maxbone 0
  2886. else
  2887. skinOps.addBone skinMod maxbone 1
  2888.  
  2889. )
  2890. local numSkinBones = skinOps.GetNumberBones skinMod
  2891. for i = 1 to numSkinBones do
  2892. (
  2893. local boneName = skinOps.GetBoneName skinMod i 0
  2894. for j = 1 to BoneCount do
  2895. (
  2896. if boneName == BoneArray[j].Name then
  2897. (
  2898. boneIDMap[j] = i
  2899. j = BoneCount + 1
  2900. )
  2901. )
  2902. ) -- This fixes bone ordering in 3DS Max 2012. Thanks to sunnydavis for the fix!
  2903.  
  2904. modPanel.setCurrentObject skinMod
  2905.  
  2906. for i = 1 to Vert_array.count do(
  2907. skinOps.SetVertexWeights skinMod i 1 1
  2908. skinOps.unnormalizeVertex skinMod i true
  2909. skinOps.SetVertexWeights skinMod i 1 0
  2910. )
  2911. skinOps.RemoveZeroWeights skinMod
  2912. for i = 1 to Vert_array.count do(
  2913. skinOps.unnormalizeVertex skinMod i false
  2914. ) -- These fix broken rigging for 3DS Max 2015 and above.
  2915.  
  2916. for i = 1 to Weight_array.count do (
  2917. w = Weight_array[i]
  2918. bi = #()
  2919. wv = #()
  2920.  
  2921. for j = 1 to w.boneids.count do
  2922. (
  2923. boneid = w.boneids[j]
  2924. weight = w.weights[j]
  2925. append bi boneIDMap[boneid]
  2926. append wv weight
  2927. )
  2928. skinOps.ReplaceVertexWeights skinMod i bi wv
  2929. )
  2930.  
  2931. )
  2932.  
  2933. if UV2_array.count > 0 do(
  2934. mat = standardMaterial()
  2935. mat.name = (TextureIDL2_array[z].TexClass as string + "_" + TextureIDL2_array[z].TexGroup as string + "_" + TextureIDL2_array[z].TexSubgroup as string + "_" + TextureIDL2_array[z].TexIndex as string)
  2936. mat.showinviewport = true
  2937. mat.twosided = false
  2938. if PNGTex == false then (tm = Bitmaptexture filename:(p + "model_" + TextureIDL2_array[z].TexClass as string + "_" + TextureIDL2_array[z].TexGroup as string + "_" + TextureIDL2_array[z].TexSubgroup as string + "_" + TextureIDL2_array[z].TexIndex as string + ".dds")) else (tm = Bitmaptexture filename:(p + "model_" + TextureIDL2_array[z].TexClass as string + "_" + TextureIDL2_array[z].TexGroup as string + "_" + TextureIDL2_array[z].TexSubgroup as string + "_" + TextureIDL2_array[z].TexIndex as string + ".png"))
  2939. tm.alphasource = 0
  2940. mat.diffuseMap = tm
  2941. mat.opacityMap = tm
  2942. mat.opacityMap.monoOutput = 1
  2943.  
  2944. msh = mesh vertices:Vert_array faces:Face_array
  2945. msh.numTVerts = Vert_array.count
  2946. if ColorDisable == false then (
  2947. setNumCPVVerts msh msh.numTVerts
  2948. setCVertMode msh true
  2949. setShadeCVerts msh true
  2950. )
  2951. defaultVCFaces msh
  2952. buildTVFaces msh
  2953. fseek m (NameClumpStart + PolyName_array[z]) #seek_set
  2954. PolyName = readstring m
  2955. msh.name = (PolyName + "_ Layer 2")
  2956. msh.material = mat
  2957.  
  2958. for j = 1 to Color_array.count do setvertcolor msh j Color_array[j]
  2959. for j = 1 to Alpha_array.count do(meshop.setVertAlpha msh -2 j Alpha_array[j])
  2960. for j = 1 to UV2_array.count do setTVert msh j UV2_array[j]
  2961. for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
  2962. for j = 1 to msh.numfaces do setFaceSmoothGroup msh j 1
  2963. max modify mode
  2964. select msh
  2965.  
  2966. addmodifier msh (Edit_Normals ()) ui:off
  2967. msh.Edit_Normals.MakeExplicit selection:#{1..Normal_array.count}
  2968. EN_convertVS = msh.Edit_Normals.ConvertVertexSelection
  2969. EN_setNormal = msh.Edit_Normals.SetNormal
  2970. normID = #{}
  2971. for v = 1 to Normal_array.count do
  2972. (
  2973. free normID
  2974. EN_convertVS #{v} &normID
  2975. for id in normID do EN_setNormal id Normal_array[v]
  2976. )
  2977.  
  2978. if BoneArray.count > 0 do(
  2979. skinMod = skin ()
  2980. boneIDMap = #()
  2981. addModifier msh skinMod
  2982. for i = 1 to BoneCount do
  2983. (
  2984. maxbone = getnodebyname BoneArray[i].name
  2985. if i != BoneCount then
  2986. skinOps.addBone skinMod maxbone 0
  2987. else
  2988. skinOps.addBone skinMod maxbone 1
  2989.  
  2990. )
  2991. local numSkinBones = skinOps.GetNumberBones skinMod
  2992. for i = 1 to numSkinBones do
  2993. (
  2994. local boneName = skinOps.GetBoneName skinMod i 0
  2995. for j = 1 to BoneCount do
  2996. (
  2997. if boneName == BoneArray[j].Name then
  2998. (
  2999. boneIDMap[j] = i
  3000. j = BoneCount + 1
  3001. )
  3002. )
  3003. ) -- This fixes bone ordering in 3DS Max 2012. Thanks to sunnydavis for the fix!
  3004.  
  3005. modPanel.setCurrentObject skinMod
  3006.  
  3007. for i = 1 to Vert_array.count do(
  3008. skinOps.SetVertexWeights skinMod i 1 1
  3009. skinOps.unnormalizeVertex skinMod i true
  3010. skinOps.SetVertexWeights skinMod i 1 0
  3011. )
  3012. skinOps.RemoveZeroWeights skinMod
  3013. for i = 1 to Vert_array.count do(
  3014. skinOps.unnormalizeVertex skinMod i false
  3015. ) -- These fix broken rigging for 3DS Max 2015 and above.
  3016.  
  3017. for i = 1 to Weight_array.count do (
  3018. w = Weight_array[i]
  3019. bi = #()
  3020. wv = #()
  3021.  
  3022. for j = 1 to w.boneids.count do
  3023. (
  3024. boneid = w.boneids[j]
  3025. weight = w.weights[j]
  3026. append bi boneIDMap[boneid]
  3027. append wv weight
  3028. )
  3029. skinOps.ReplaceVertexWeights skinMod i bi wv
  3030. )
  3031.  
  3032. )
  3033. )
  3034.  
  3035. if UV3_array.count > 0 do(
  3036. mat = standardMaterial()
  3037. mat.name = (TextureIDL3_array[z].TexClass as string + "_" + TextureIDL3_array[z].TexGroup as string + "_" + TextureIDL3_array[z].TexSubgroup as string + "_" + TextureIDL3_array[z].TexIndex as string)
  3038. mat.showinviewport = true
  3039. mat.twosided = false
  3040. if PNGTex == false then (tm = Bitmaptexture filename:(p + "model_" + TextureIDL3_array[z].TexClass as string + "_" + TextureIDL3_array[z].TexGroup as string + "_" + TextureIDL3_array[z].TexSubgroup as string + "_" + TextureIDL3_array[z].TexIndex as string + ".dds")) else (tm = Bitmaptexture filename:(p + "model_" + TextureIDL3_array[z].TexClass as string + "_" + TextureIDL3_array[z].TexGroup as string + "_" + TextureIDL3_array[z].TexSubgroup as string + "_" + TextureIDL3_array[z].TexIndex as string + ".png"))
  3041. tm.alphasource = 0
  3042. mat.diffuseMap = tm
  3043. mat.opacityMap = tm
  3044. mat.opacityMap.monoOutput = 1
  3045.  
  3046. msh = mesh vertices:Vert_array faces:Face_array
  3047. msh.numTVerts = Vert_array.count
  3048. if ColorDisable == false then (
  3049. setNumCPVVerts msh msh.numTVerts
  3050. setCVertMode msh true
  3051. setShadeCVerts msh true
  3052. )
  3053. defaultVCFaces msh
  3054. buildTVFaces msh
  3055. fseek m (NameClumpStart + PolyName_array[z]) #seek_set
  3056. PolyName = readstring m
  3057. msh.name = (PolyName + "_ Layer 3")
  3058. msh.material = mat
  3059.  
  3060. for j = 1 to Color_array.count do setvertcolor msh j Color_array[j]
  3061. for j = 1 to Alpha_array.count do(meshop.setVertAlpha msh -2 j Alpha_array[j])
  3062. for j = 1 to UV3_array.count do setTVert msh j UV3_array[j]
  3063. for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
  3064. for j = 1 to msh.numfaces do setFaceSmoothGroup msh j 1
  3065. max modify mode
  3066. select msh
  3067.  
  3068. addmodifier msh (Edit_Normals ()) ui:off
  3069. msh.Edit_Normals.MakeExplicit selection:#{1..Normal_array.count}
  3070. EN_convertVS = msh.Edit_Normals.ConvertVertexSelection
  3071. EN_setNormal = msh.Edit_Normals.SetNormal
  3072. normID = #{}
  3073. for v = 1 to Normal_array.count do
  3074. (
  3075. free normID
  3076. EN_convertVS #{v} &normID
  3077. for id in normID do EN_setNormal id Normal_array[v]
  3078. )
  3079.  
  3080. if BoneArray.count > 0 do(
  3081. skinMod = skin ()
  3082. boneIDMap = #()
  3083. addModifier msh skinMod
  3084. for i = 1 to BoneCount do
  3085. (
  3086. maxbone = getnodebyname BoneArray[i].name
  3087. if i != BoneCount then
  3088. skinOps.addBone skinMod maxbone 0
  3089. else
  3090. skinOps.addBone skinMod maxbone 1
  3091.  
  3092. )
  3093. local numSkinBones = skinOps.GetNumberBones skinMod
  3094. for i = 1 to numSkinBones do
  3095. (
  3096. local boneName = skinOps.GetBoneName skinMod i 0
  3097. for j = 1 to BoneCount do
  3098. (
  3099. if boneName == BoneArray[j].Name then
  3100. (
  3101. boneIDMap[j] = i
  3102. j = BoneCount + 1
  3103. )
  3104. )
  3105. ) -- This fixes bone ordering in 3DS Max 2012. Thanks to sunnydavis for the fix!
  3106.  
  3107. modPanel.setCurrentObject skinMod
  3108.  
  3109. for i = 1 to Vert_array.count do(
  3110. skinOps.SetVertexWeights skinMod i 1 1
  3111. skinOps.unnormalizeVertex skinMod i true
  3112. skinOps.SetVertexWeights skinMod i 1 0
  3113. )
  3114. skinOps.RemoveZeroWeights skinMod
  3115. for i = 1 to Vert_array.count do(
  3116. skinOps.unnormalizeVertex skinMod i false
  3117. ) -- These fix broken rigging for 3DS Max 2015 and above.
  3118.  
  3119. for i = 1 to Weight_array.count do (
  3120. w = Weight_array[i]
  3121. bi = #()
  3122. wv = #()
  3123.  
  3124. for j = 1 to w.boneids.count do
  3125. (
  3126. boneid = w.boneids[j]
  3127. weight = w.weights[j]
  3128. append bi boneIDMap[boneid]
  3129. append wv weight
  3130. )
  3131. skinOps.ReplaceVertexWeights skinMod i bi wv
  3132. )
  3133.  
  3134. )
  3135. )
  3136.  
  3137. if UV4_array.count > 0 do(
  3138. mat = standardMaterial()
  3139. mat.name = (TextureIDL4_array[z].TexClass as string + "_" + TextureIDL4_array[z].TexGroup as string + "_" + TextureIDL4_array[z].TexSubgroup as string + "_" + TextureIDL4_array[z].TexIndex as string)
  3140. mat.showinviewport = true
  3141. mat.twosided = false
  3142. if PNGTex == false then (tm = Bitmaptexture filename:(p + "model_" + TextureIDL4_array[z].TexClass as string + "_" + TextureIDL4_array[z].TexGroup as string + "_" + TextureIDL4_array[z].TexSubgroup as string + "_" + TextureIDL4_array[z].TexIndex as string + ".dds")) else (tm = Bitmaptexture filename:(p + "model_" + TextureIDL4_array[z].TexClass as string + "_" + TextureIDL4_array[z].TexGroup as string + "_" + TextureIDL4_array[z].TexSubgroup as string + "_" + TextureIDL4_array[z].TexIndex as string + ".png"))
  3143. tm.alphasource = 0
  3144. mat.diffuseMap = tm
  3145. mat.opacityMap = tm
  3146. mat.opacityMap.monoOutput = 1
  3147.  
  3148. msh = mesh vertices:Vert_array faces:Face_array
  3149. msh.numTVerts = Vert_array.count
  3150. if ColorDisable == false then (
  3151. setNumCPVVerts msh msh.numTVerts
  3152. setCVertMode msh true
  3153. setShadeCVerts msh true
  3154. )
  3155. defaultVCFaces msh
  3156. buildTVFaces msh
  3157. fseek m (NameClumpStart + PolyName_array[z]) #seek_set
  3158. PolyName = readstring m
  3159. msh.name = (PolyName + "_ Layer 4")
  3160. msh.material = mat
  3161.  
  3162. for j = 1 to Color_array.count do setvertcolor msh j Color_array[j]
  3163. for j = 1 to Alpha_array.count do(meshop.setVertAlpha msh -2 j Alpha_array[j])
  3164. for j = 1 to UV4_array.count do setTVert msh j UV4_array[j]
  3165. for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
  3166. for j = 1 to msh.numfaces do setFaceSmoothGroup msh j 1
  3167. max modify mode
  3168. select msh
  3169.  
  3170. addmodifier msh (Edit_Normals ()) ui:off
  3171. msh.Edit_Normals.MakeExplicit selection:#{1..Normal_array.count}
  3172. EN_convertVS = msh.Edit_Normals.ConvertVertexSelection
  3173. EN_setNormal = msh.Edit_Normals.SetNormal
  3174. normID = #{}
  3175. for v = 1 to Normal_array.count do
  3176. (
  3177. free normID
  3178. EN_convertVS #{v} &normID
  3179. for id in normID do EN_setNormal id Normal_array[v]
  3180. )
  3181.  
  3182. if BoneArray.count > 0 do(
  3183. skinMod = skin ()
  3184. boneIDMap = #()
  3185. addModifier msh skinMod
  3186. for i = 1 to BoneCount do
  3187. (
  3188. maxbone = getnodebyname BoneArray[i].name
  3189. if i != BoneCount then
  3190. skinOps.addBone skinMod maxbone 0
  3191. else
  3192. skinOps.addBone skinMod maxbone 1
  3193.  
  3194. )
  3195. local numSkinBones = skinOps.GetNumberBones skinMod
  3196. for i = 1 to numSkinBones do
  3197. (
  3198. local boneName = skinOps.GetBoneName skinMod i 0
  3199. for j = 1 to BoneCount do
  3200. (
  3201. if boneName == BoneArray[j].Name then
  3202. (
  3203. boneIDMap[j] = i
  3204. j = BoneCount + 1
  3205. )
  3206. )
  3207. ) -- This fixes bone ordering in 3DS Max 2012. Thanks to sunnydavis for the fix!
  3208.  
  3209. modPanel.setCurrentObject skinMod
  3210.  
  3211. for i = 1 to Vert_array.count do(
  3212. skinOps.SetVertexWeights skinMod i 1 1
  3213. skinOps.unnormalizeVertex skinMod i true
  3214. skinOps.SetVertexWeights skinMod i 1 0
  3215. )
  3216. skinOps.RemoveZeroWeights skinMod
  3217. for i = 1 to Vert_array.count do(
  3218. skinOps.unnormalizeVertex skinMod i false
  3219. ) -- These fix broken rigging for 3DS Max 2015 and above.
  3220.  
  3221. for i = 1 to Weight_array.count do (
  3222. w = Weight_array[i]
  3223. bi = #()
  3224. wv = #()
  3225.  
  3226. for j = 1 to w.boneids.count do
  3227. (
  3228. boneid = w.boneids[j]
  3229. weight = w.weights[j]
  3230. append bi boneIDMap[boneid]
  3231. append wv weight
  3232. )
  3233. skinOps.ReplaceVertexWeights skinMod i bi wv
  3234. )
  3235.  
  3236. )
  3237. )
  3238.  
  3239. )
  3240.  
  3241. )
  3242.  
  3243. gc()
  3244. fclose m
  3245. fclose q
  3246. )
  3247.  
  3248. on btnIDFixNUD pressed do(
  3249. local TexIDChangeA = boxTexIDChangeA.value
  3250. local TexIDChangeB = boxTexIDChangeB.value
  3251. local TexIDChangeC = boxTexIDChangeC.value
  3252. local TexIDChangeD = tglTexIDChangeD.state
  3253. clearlistener()
  3254.  
  3255. if TexIDChangeA == 16 do(print "Class 16 is reserved for system textures and can't be used!")
  3256.  
  3257. if TexIDChangeA != 16 do(
  3258. fname = getOpenFileName \
  3259. caption:"Super Smash Bros. for Wii U / Taiko model file" \
  3260. types:"SSB4U/TnTU model(*.nud)|*.nud" \
  3261. historyCategory:"SSB4U"
  3262.  
  3263. if fname != undefined do (
  3264. m = fopen fname "r+"
  3265. p = getFilenamePath fname
  3266.  
  3267. TexturePropertiesS1Start_array = #()
  3268. TexturePropertiesS2Start_array = #()
  3269. TexturePropertiesS3Start_array = #()
  3270. TexturePropertiesS4Start_array = #()
  3271.  
  3272. fseek m 0x00 #seek_set
  3273. fseek m 0x0A #seek_cur
  3274. polysets = readBEword m
  3275. fseek m 0x24 #seek_cur
  3276.  
  3277. ObjCount = 0
  3278. for z = 1 to polysets do(
  3279. fseek m 0x2A #seek_cur
  3280. polyamount = readBEword m
  3281. ObjPropStart = readBElong m
  3282. ObjCount = (ObjCount + polyamount)
  3283. )
  3284.  
  3285. for z = 1 to ObjCount do(
  3286. fseek m 0x10 #seek_cur
  3287. TextureSet1Properties = readBElong m
  3288. TextureSet2Properties = readBElong m
  3289. TextureSet3Properties = readBElong m
  3290. TextureSet4Properties = readBElong m
  3291. fseek m 0x10 #seek_cur
  3292. append TexturePropertiesS1Start_array TextureSet1Properties
  3293. append TexturePropertiesS2Start_array TextureSet2Properties
  3294. append TexturePropertiesS3Start_array TextureSet3Properties
  3295. append TexturePropertiesS4Start_array TextureSet4Properties
  3296. )
  3297.  
  3298. for z = 1 to ObjCount do(
  3299. fseek m TexturePropertiesS1Start_array[z] #seek_set
  3300. print ("Polygon group " + z as string + " material properties start at 0x" + (bit.intAsHex(ftell m))as string)
  3301. fseek m 0x0A #seek_cur
  3302. TexLayerCount = readBEword m
  3303. fseek m 0x14 #seek_cur
  3304. print "Texture information:"
  3305.  
  3306. for x = 1 to TexLayerCount do(
  3307. TexClass = readbyte m #unsigned
  3308. TexGroup = readbyte m #unsigned
  3309. TexSubgroup = readbyte m #unsigned
  3310. TexIndex = readbyte m #unsigned
  3311. print "BEFORE:"
  3312. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3313.  
  3314. fseek m -0x04 #seek_cur
  3315. if TexClass != 16 then(
  3316. TexClass = writebyte m TexIDChangeA
  3317. TexGroup = writebyte m TexIDChangeB
  3318. TexSubgroup = writebyte m TexIDChangeC
  3319.  
  3320. if TexIDChangeD == 1 do(
  3321. fseek m 0x01 #seek_cur
  3322. )
  3323.  
  3324. if TexIDChangeD == 2 and TexIndex > 127 then(
  3325. TexIndexNew = TexIndex - 128
  3326. TexIndex = writebyte m TexIndexNew
  3327. ) else (if TexIDChangeD == 2 and TexIndex < 128 do(
  3328. fseek m 0x01 #seek_cur
  3329. ))
  3330.  
  3331. if TexIDChangeD == 3 and TexIndex < 128 then(
  3332. TexIndexNew = TexIndex + 128
  3333. TexIndex = writebyte m TexIndexNew
  3334. ) else (if TexIDChangeD == 3 and TexIndex > 127 do(
  3335. fseek m 0x01 #seek_cur
  3336. ))
  3337.  
  3338. fseek m -0x04 #seek_cur
  3339. TexClass = readbyte m #unsigned
  3340. TexGroup = readbyte m #unsigned
  3341. TexSubgroup = readbyte m #unsigned
  3342. TexIndex = readbyte m #unsigned
  3343. ) else (fseek m 0x04 #seek_cur)
  3344. fseek m 0x14 #seek_cur
  3345. print "AFTER:"
  3346. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3347. )
  3348.  
  3349. if TexturePropertiesS2Start_array[z] != 0 do(
  3350. fseek m TexturePropertiesS2Start_array[z] #seek_set
  3351. print "--------------------"
  3352. print ("Polygon group " + z as string + " Set 2 material properties:")
  3353. fseek m 0x0A #seek_cur
  3354. TexLayerCount = readBEword m
  3355. fseek m 0x14 #seek_cur
  3356. print "Texture information:"
  3357.  
  3358. for x = 1 to TexLayerCount do(
  3359. TexClass = readbyte m #unsigned
  3360. TexGroup = readbyte m #unsigned
  3361. TexSubgroup = readbyte m #unsigned
  3362. TexIndex = readbyte m #unsigned
  3363. print "BEFORE:"
  3364. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3365.  
  3366. fseek m -0x04 #seek_cur
  3367. if TexClass != 16 then(
  3368. TexClass = writebyte m TexIDChangeA
  3369. TexGroup = writebyte m TexIDChangeB
  3370. TexSubgroup = writebyte m TexIDChangeC
  3371.  
  3372. if TexIDChangeD == 1 do(
  3373. fseek m 0x01 #seek_cur
  3374. )
  3375.  
  3376. if TexIDChangeD == 2 and TexIndex > 127 then(
  3377. TexIndexNew = TexIndex - 128
  3378. TexIndex = writebyte m TexIndexNew
  3379. ) else (if TexIDChangeD == 2 and TexIndex < 128 do(
  3380. fseek m 0x01 #seek_cur
  3381. ))
  3382.  
  3383. if TexIDChangeD == 3 and TexIndex < 128 then(
  3384. TexIndexNew = TexIndex + 128
  3385. TexIndex = writebyte m TexIndexNew
  3386. ) else (if TexIDChangeD == 3 and TexIndex > 127 do(
  3387. fseek m 0x01 #seek_cur
  3388. ))
  3389.  
  3390. fseek m -0x04 #seek_cur
  3391. TexClass = readbyte m #unsigned
  3392. TexGroup = readbyte m #unsigned
  3393. TexSubgroup = readbyte m #unsigned
  3394. TexIndex = readbyte m #unsigned
  3395. ) else (fseek m 0x04 #seek_cur)
  3396. fseek m 0x14 #seek_cur
  3397. print "AFTER:"
  3398. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3399. )
  3400.  
  3401. )
  3402.  
  3403. if TexturePropertiesS3Start_array[z] != 0 do(
  3404. fseek m TexturePropertiesS3Start_array[z] #seek_set
  3405. print "--------------------"
  3406. print ("Polygon group " + z as string + " Set 3 material properties:")
  3407. fseek m 0x0A #seek_cur
  3408. TexLayerCount = readBEword m
  3409. fseek m 0x14 #seek_cur
  3410. print "Texture information:"
  3411.  
  3412. for x = 1 to TexLayerCount do(
  3413. TexClass = readbyte m #unsigned
  3414. TexGroup = readbyte m #unsigned
  3415. TexSubgroup = readbyte m #unsigned
  3416. TexIndex = readbyte m #unsigned
  3417. print "BEFORE:"
  3418. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3419.  
  3420. fseek m -0x04 #seek_cur
  3421. if TexClass != 16 then(
  3422. TexClass = writebyte m TexIDChangeA
  3423. TexGroup = writebyte m TexIDChangeB
  3424. TexSubgroup = writebyte m TexIDChangeC
  3425.  
  3426. if TexIDChangeD == 1 do(
  3427. fseek m 0x01 #seek_cur
  3428. )
  3429.  
  3430. if TexIDChangeD == 2 and TexIndex > 127 then(
  3431. TexIndexNew = TexIndex - 128
  3432. TexIndex = writebyte m TexIndexNew
  3433. ) else (if TexIDChangeD == 2 and TexIndex < 128 do(
  3434. fseek m 0x01 #seek_cur
  3435. ))
  3436.  
  3437. if TexIDChangeD == 3 and TexIndex < 128 then(
  3438. TexIndexNew = TexIndex + 128
  3439. TexIndex = writebyte m TexIndexNew
  3440. ) else (if TexIDChangeD == 3 and TexIndex > 127 do(
  3441. fseek m 0x01 #seek_cur
  3442. ))
  3443.  
  3444. fseek m -0x04 #seek_cur
  3445. TexClass = readbyte m #unsigned
  3446. TexGroup = readbyte m #unsigned
  3447. TexSubgroup = readbyte m #unsigned
  3448. TexIndex = readbyte m #unsigned
  3449. ) else (fseek m 0x04 #seek_cur)
  3450. fseek m 0x14 #seek_cur
  3451. print "AFTER:"
  3452. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3453. )
  3454.  
  3455. )
  3456.  
  3457. if TexturePropertiesS4Start_array[z] != 0 do(
  3458. fseek m TexturePropertiesS4Start_array[z] #seek_set
  3459. print "--------------------"
  3460. print ("Polygon group " + z as string + " Set 4 material properties:")
  3461. fseek m 0x0A #seek_cur
  3462. TexLayerCount = readBEword m
  3463. fseek m 0x14 #seek_cur
  3464. print "Texture information:"
  3465.  
  3466. for x = 1 to TexLayerCount do(
  3467. TexClass = readbyte m #unsigned
  3468. TexGroup = readbyte m #unsigned
  3469. TexSubgroup = readbyte m #unsigned
  3470. TexIndex = readbyte m #unsigned
  3471. print "BEFORE:"
  3472. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3473.  
  3474. fseek m -0x04 #seek_cur
  3475. if TexClass != 16 then(
  3476. TexClass = writebyte m TexIDChangeA
  3477. TexGroup = writebyte m TexIDChangeB
  3478. TexSubgroup = writebyte m TexIDChangeC
  3479.  
  3480. if TexIDChangeD == 1 do(
  3481. fseek m 0x01 #seek_cur
  3482. )
  3483.  
  3484. if TexIDChangeD == 2 and TexIndex > 127 then(
  3485. TexIndexNew = TexIndex - 128
  3486. TexIndex = writebyte m TexIndexNew
  3487. ) else (if TexIDChangeD == 2 and TexIndex < 128 do(
  3488. fseek m 0x01 #seek_cur
  3489. ))
  3490.  
  3491. if TexIDChangeD == 3 and TexIndex < 128 then(
  3492. TexIndexNew = TexIndex + 128
  3493. TexIndex = writebyte m TexIndexNew
  3494. ) else (if TexIDChangeD == 3 and TexIndex > 127 do(
  3495. fseek m 0x01 #seek_cur
  3496. ))
  3497.  
  3498. fseek m -0x04 #seek_cur
  3499. TexClass = readbyte m #unsigned
  3500. TexGroup = readbyte m #unsigned
  3501. TexSubgroup = readbyte m #unsigned
  3502. TexIndex = readbyte m #unsigned
  3503. ) else (fseek m 0x04 #seek_cur)
  3504. fseek m 0x14 #seek_cur
  3505. print "AFTER:"
  3506. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3507. )
  3508.  
  3509. )
  3510.  
  3511. print ("Polygon group " + z as string + " material properties end at 0x" + (bit.intAsHex(ftell m))as string)
  3512. print "--------------------"
  3513.  
  3514. )
  3515. print ("Texture properties end at 0x" + (bit.intAsHex(ftell m))as string)
  3516.  
  3517. print "Done!"
  3518. fclose m
  3519. )
  3520. )
  3521. )
  3522.  
  3523. on btnIDFixNUT pressed do(
  3524. local TexIDChangeA = boxTexIDChangeA.value
  3525. local TexIDChangeB = boxTexIDChangeB.value
  3526. local TexIDChangeC = boxTexIDChangeC.value
  3527. local TexIDChangeD = tglTexIDChangeD.state
  3528. clearlistener()
  3529.  
  3530. if TexIDChangeA == 16 do(print "Class 16 is reserved for system textures and can't be used!")
  3531.  
  3532. if TexIDChangeA != 16 do(
  3533. fname = getOpenFileName \
  3534. caption:"Super Smash Bros. for Wii U / Taiko model file" \
  3535. types:"SSB4U/TnTU model(*.nut)|*.nut" \
  3536. historyCategory:"SSB4U"
  3537.  
  3538. if fname != undefined do (
  3539. m = fopen fname "r+"
  3540. p = getFilenamePath fname
  3541.  
  3542. fseek m 0x00 #seek_set
  3543. fseek m 0x06 #seek_cur
  3544. FileTotal = readBEword m
  3545. fseek m 0x08 #seek_cur
  3546.  
  3547. for x = 1 to FileTotal do(
  3548. fseek m 0x0C #seek_cur
  3549. HeaderSize = readBEword m
  3550. fseek m 0x02 #seek_cur
  3551. fseek m (HeaderSize - 0x20) #seek_cur
  3552. fseek m 0x08 #seek_cur
  3553.  
  3554. TexClass = readbyte m #unsigned
  3555. TexGroup = readbyte m #unsigned
  3556. TexSubgroup = readbyte m #unsigned
  3557. TexIndex = readbyte m #unsigned
  3558. print "BEFORE:"
  3559. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3560.  
  3561. fseek m -0x04 #seek_cur
  3562. if TexClass != 16 then(
  3563. TexClass = writebyte m TexIDChangeA
  3564. TexGroup = writebyte m TexIDChangeB
  3565. TexSubgroup = writebyte m TexIDChangeC
  3566.  
  3567. if TexIDChangeD == 1 do(
  3568. fseek m 0x01 #seek_cur
  3569. )
  3570.  
  3571. if TexIDChangeD == 2 and TexIndex > 127 then(
  3572. TexIndexNew = TexIndex - 128
  3573. TexIndex = writebyte m TexIndexNew
  3574. ) else (if TexIDChangeD == 2 and TexIndex < 128 do(
  3575. fseek m 0x01 #seek_cur
  3576. ))
  3577.  
  3578. if TexIDChangeD == 3 and TexIndex < 128 then(
  3579. TexIndexNew = TexIndex + 128
  3580. TexIndex = writebyte m TexIndexNew
  3581. ) else (if TexIDChangeD == 3 and TexIndex > 127 do(
  3582. fseek m 0x01 #seek_cur
  3583. ))
  3584.  
  3585. fseek m -0x04 #seek_cur
  3586. TexClass = readbyte m #unsigned
  3587. TexGroup = readbyte m #unsigned
  3588. TexSubgroup = readbyte m #unsigned
  3589. TexIndex = readbyte m #unsigned
  3590. ) else (fseek m 0x04 #seek_cur)
  3591. print "AFTER:"
  3592. print ("Class: " + TexClass as string + ", Group: " + TexGroup as string + ", Subgroup " + TexSubgroup as string + ", Index " + TexIndex as string)
  3593. fseek m 0x04 #seek_cur
  3594.  
  3595. )
  3596.  
  3597. print "Done!"
  3598. fclose m
  3599.  
  3600. )
  3601.  
  3602. )
  3603.  
  3604. )
  3605.  
  3606. )
  3607. CreateDialog SSB4UImporter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement