home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 7756 / SwordsMan_Script.7z / SwordsMan_Model.ms < prev   
Encoding:
Text File  |  2014-08-27  |  17.2 KB  |  735 lines

  1. if (heapSize < 200000) then
  2.         heapSize = 2000000 -- allow ~ 40 MB instead of just 7.5 MB. Prevents "Runtime Error: Out of scripter memory"
  3. fname = getOpenFileName \
  4. caption:"Open .ski from Mesh folder" \
  5. types:"SKI Mesh (*.ski)|*.ski" \
  6. historyCategory:"SKIObjectPresets"
  7. f = fopen fname "rb"
  8.  
  9. clearlistener()
  10. fn readHalfFloat fstream = (
  11.     hf=readshort fstream #unsigned
  12.     sign = bit.get hf 16
  13.     exponent = (bit.shift (bit.and hf (bit.hexasint "7C00")) -10) as integer - 16
  14.     fraction = bit.and hf (bit.hexasint "03FF")
  15.     if sign==true then sign = 1 else sign = 0
  16.     exponentF = exponent + 127
  17.     outputAsFloat = bit.or (bit.or (bit.shift fraction 13) \
  18.     (bit.shift exponentF 23)) (bit.shift sign 31)
  19.     return bit.intasfloat outputasfloat*2
  20.     )
  21.     
  22. fn readFixedString bstream fixedLen = (
  23. local str = ""
  24. for i = 1 to fixedLen do (
  25. str += bit.intAsChar (ReadByte bstream #unsigned))
  26. str
  27. )    
  28.  
  29. struct weight_data
  30. (
  31.     boneids,weights
  32. )
  33.  
  34. clearlistener()
  35.     
  36. BoneNamesArray = #()    
  37. fseek f 0x0 #seek_set
  38. MOXBIKSA=readFixedString f 8
  39. Version = ReadLong f
  40. numSkinObjext = ReadLong f
  41. numStaticObject = ReadLong f
  42. Unk1 = ReadLong f
  43. Unk2 = ReadLong f
  44. numTexture = ReadLong f
  45. numMaterial = ReadLong f
  46. numUsedBones = ReadLong f
  47. Unk3 = ReadLong f
  48. numSkeletonBones = ReadLong f
  49. fseek f 0x3C #seek_cur
  50. if Version==8 then fseek f 0x0 #seek_cur    
  51. if Version!=8 then    
  52. for a = 1 to numUsedBones Do (
  53. BoneNameSize = ReadLong f
  54. BName = readFixedString f BoneNameSize
  55. append BoneNamesArray BName    
  56. )
  57.  
  58.     for i = 1 to numTexture do (
  59.         texture_name_size = (readlong f)
  60.         texture_name = readFixedString f texture_name_size
  61.         )
  62.         
  63. if     numMaterial==1 then 
  64. if Version==9 then    
  65. (    
  66. Pos=ftell f        
  67. Check=readlong f
  68. if Check<100 then
  69. (
  70. fseek f Pos #seek_set    
  71. fseek f 0x63 #seek_cur    
  72. )
  73. if Check>100 then
  74. (    
  75. fseek f Pos #seek_set        
  76. (
  77.         MtlName = readFixedString f 11
  78.         fseek f 0x45 #seek_cur
  79. )
  80. )
  81. )
  82.  
  83. if     numMaterial==1 then
  84. if Version==10 then 
  85. (        
  86. MatId = readlong f    
  87. if MatId ==3 then
  88. (        fseek f 0x5F #seek_cur
  89. )        
  90. if MatId ==7 then
  91. (    
  92.         fseek f 0x67 #seek_cur
  93.         TexPathSize=readlong f
  94.         TexPath = readFixedString f TexPathSize
  95.         FF=readlong f
  96.         NSize = readlong f
  97.         Nname = readFixedString f NSize    
  98.         fseek f 0x4 #seek_cur
  99.         TexPathSize=readlong f
  100.         TexPath = readFixedString f TexPathSize
  101.         fseek f 0x8 #seek_cur    
  102. )
  103. if MatId ==8 then
  104. (    
  105.         fseek f 0x67 #seek_cur
  106.         TexPathSize=readlong f
  107.         TexPath = readFixedString f TexPathSize
  108.         FF=readlong f
  109.         NSize = readlong f
  110.         Nname = readFixedString f NSize    
  111.         fseek f 0x4 #seek_cur
  112.         TexPathSize=readlong f
  113.         TexPath = readFixedString f TexPathSize
  114.         fseek f 0x9 #seek_cur    
  115. )
  116. if MatId ==12 then
  117. (
  118.         fseek f 0x67 #seek_cur
  119.         TexPathSize=readlong f
  120.         TexPath = readFixedString f TexPathSize
  121.         FF=readlong f
  122.         NSize = readlong f
  123.         Nname = readFixedString f NSize    
  124.         fseek f 0x2A #seek_cur
  125.         TexPathSize=readlong f
  126.         TexPath = readFixedString f TexPathSize
  127.          fseek f 0x3D #seek_cur    
  128. )
  129. if MatId ==14 then
  130. (
  131.         fseek f 0x67 #seek_cur
  132.         TexPathSize=readlong f
  133.         TexPath = readFixedString f TexPathSize
  134.         if TexPathSize!=0 then (            
  135.         FF=readlong f
  136.         NSize = readlong f
  137.         Nname = readFixedString f NSize    
  138.         fseek f 0x2A #seek_cur
  139.         TexPathSize2=readlong f
  140.         TexPath = readFixedString f TexPathSize2
  141.         if TexPathSize2==0 then             
  142.         (
  143.          fseek f 0x46 #seek_cur            
  144.         TexPathSize3=readlong f
  145.         TexPath = readFixedString f TexPathSize3        
  146.         )    
  147.         if TexPathSize2!=0 then fseek f 0x4A #seek_cur
  148.         )
  149.         if TexPathSize==0 then (            
  150.         FF=readlong f
  151.         NSize = readlong f
  152.         Nname = readFixedString f NSize    
  153.         fseek f 0x2A #seek_cur
  154.         TexPathSize2=readlong f
  155.         TexPath = readFixedString f TexPathSize2
  156.         fseek f 0x39 #seek_cur    
  157.         TexPathSize3=readlong f
  158.         TexPath = readFixedString f TexPathSize3
  159.         fseek f 0xD #seek_cur            
  160. )
  161. )
  162. if MatId ==15 then
  163. (
  164.         fseek f 0x67 #seek_cur
  165.         TexPathSize=readlong f
  166.         TexPath = readFixedString f TexPathSize
  167.         if TexPathSize!=0 then (            
  168.         FF=readlong f
  169.         NSize = readlong f
  170.         Nname = readFixedString f NSize    
  171.         fseek f 0x2A #seek_cur
  172.         TexPathSize2=readlong f
  173.         TexPath = readFixedString f TexPathSize2
  174.         if TexPathSize2==0 then             
  175.         (
  176.          fseek f 0x46 #seek_cur            
  177.         TexPathSize3=readlong f
  178.         TexPath = readFixedString f TexPathSize3
  179.         fseek f 0x4 #seek_cur            
  180.         )    
  181.         if TexPathSize2!=0 then fseek f 0x4E #seek_cur
  182.         )
  183.         if TexPathSize==0 then (            
  184.         FF=readlong f
  185.         NSize = readlong f
  186.         Nname = readFixedString f NSize    
  187.         fseek f 0x2A #seek_cur
  188.         TexPathSize2=readlong f
  189.         TexPath = readFixedString f TexPathSize2
  190.         fseek f 0x39 #seek_cur    
  191.         TexPathSize3=readlong f
  192.         TexPath = readFixedString f TexPathSize3
  193.         fseek f 0x11 #seek_cur            
  194. )
  195. )
  196. if MatId ==16 then
  197. (
  198.         fseek f 0x67 #seek_cur
  199.         TexPathSize=readlong f
  200.         TexPath = readFixedString f TexPathSize
  201.         if TexPathSize==0 then (            
  202.         FF=readlong f
  203.         NSize = readlong f
  204.         Nname = readFixedString f NSize    
  205.         fseek f 0x2A #seek_cur
  206.         TexPathSize2=readlong f
  207.         TexPath = readFixedString f TexPathSize2
  208.         fseek f 0x39 #seek_cur    
  209.         TexPathSize3=readlong f
  210.         TexPath = readFixedString f TexPathSize3
  211.         fseek f 0x21 #seek_cur            
  212. )
  213.        if TexPathSize!=0 then (        
  214.         FF=readlong f
  215.         NSize = readlong f
  216.         Nname = readFixedString f NSize    
  217.         if NSize==0 then 
  218.         (
  219.         fseek f 0x4 #seek_cur
  220.         TexPathSize=readlong f
  221.         TexPath = readFixedString f TexPathSize
  222.         fseek f 0x22 #seek_cur    
  223.         TexPathSize3=readlong f    
  224.         TexPath = readFixedString f TexPathSize3
  225.         if TexPathSize3==0 then 
  226.         (
  227.         fseek f 0x46 #seek_cur    
  228.         TexPathSize4=readlong f    
  229.         TexPath = readFixedString f TexPathSize4    
  230.         fseek f 0x14 #seek_cur                        
  231.         )    
  232.         if TexPathSize3!=0 then  fseek f 0x5E #seek_cur        
  233.         )    
  234. )
  235. )
  236. if MatId ==19 then
  237. (
  238.         fseek f 0x7E #seek_cur
  239.         TexPathSize=readlong f
  240.         TexPath = readFixedString f TexPathSize
  241.         FF=readlong f
  242.         NSize = readlong f
  243.         Nname = readFixedString f NSize    
  244.         fseek f 0x2A #seek_cur
  245.         TexPathSize=readlong f
  246.         TexPath = readFixedString f TexPathSize
  247.          fseek f 0x37 #seek_cur    
  248. )
  249. )
  250.  
  251. if     numMaterial!=1 then
  252. if Version==10 then        
  253. for i = 1 to numMaterial do (
  254. MatId = readlong f
  255. if MatId ==3 then
  256. (        fseek f 0x5F #seek_cur
  257. )    
  258. if MatId ==7 then
  259. (    
  260.         fseek f 0x67 #seek_cur
  261.         TexPathSize=readlong f
  262.         TexPath = readFixedString f TexPathSize
  263.         FF=readlong f
  264.         NSize = readlong f
  265.         Nname = readFixedString f NSize    
  266.         fseek f 0x4 #seek_cur
  267.         TexPathSize=readlong f
  268.         TexPath = readFixedString f TexPathSize
  269.         fseek f 0x8 #seek_cur    
  270. )
  271. if MatId ==8 then
  272. (    
  273.         fseek f 0x67 #seek_cur
  274.         TexPathSize=readlong f
  275.         TexPath = readFixedString f TexPathSize
  276.         FF=readlong f
  277.         NSize = readlong f
  278.         Nname = readFixedString f NSize    
  279.         fseek f 0x4 #seek_cur
  280.         TexPathSize=readlong f
  281.         TexPath = readFixedString f TexPathSize
  282.         fseek f 0x9 #seek_cur    
  283. )
  284. if MatId ==12 then
  285. (
  286.         fseek f 0x67 #seek_cur
  287.         TexPathSize=readlong f
  288.         TexPath = readFixedString f TexPathSize
  289.         FF=readlong f
  290.         NSize = readlong f
  291.         Nname = readFixedString f NSize    
  292.         fseek f 0x2A #seek_cur
  293.         TexPathSize=readlong f
  294.         TexPath = readFixedString f TexPathSize
  295.          fseek f 0x3D #seek_cur    
  296. )
  297. if MatId ==14 then
  298. (
  299.         fseek f 0x67 #seek_cur
  300.         TexPathSize=readlong f
  301.         TexPath = readFixedString f TexPathSize
  302.         if TexPathSize!=0 then (            
  303.         FF=readlong f
  304.         NSize = readlong f
  305.         Nname = readFixedString f NSize    
  306.         fseek f 0x2A #seek_cur
  307.         TexPathSize2=readlong f
  308.         TexPath = readFixedString f TexPathSize2
  309.         if TexPathSize2==0 then             
  310.         (
  311.          fseek f 0x46 #seek_cur            
  312.         TexPathSize3=readlong f
  313.         TexPath = readFixedString f TexPathSize3        
  314.         )    
  315.         if TexPathSize2!=0 then fseek f 0x4A #seek_cur
  316.         )
  317.         if TexPathSize==0 then (            
  318.         FF=readlong f
  319.         NSize = readlong f
  320.         Nname = readFixedString f NSize    
  321.         fseek f 0x2A #seek_cur
  322.         TexPathSize2=readlong f
  323.         TexPath = readFixedString f TexPathSize2
  324.         fseek f 0x39 #seek_cur    
  325.         TexPathSize3=readlong f
  326.         TexPath = readFixedString f TexPathSize3
  327.         fseek f 0xD #seek_cur            
  328. )
  329. )
  330. if MatId ==15 then
  331. (
  332.         fseek f 0x67 #seek_cur
  333.         TexPathSize=readlong f
  334.         TexPath = readFixedString f TexPathSize
  335.         if TexPathSize!=0 then (            
  336.         FF=readlong f
  337.         NSize = readlong f
  338.         Nname = readFixedString f NSize    
  339.         fseek f 0x2A #seek_cur
  340.         TexPathSize2=readlong f
  341.         TexPath = readFixedString f TexPathSize2
  342.         if TexPathSize2==0 then     (
  343.          fseek f 0x46 #seek_cur            
  344.         TexPathSize3=readlong f
  345.         TexPath = readFixedString f TexPathSize3
  346.         fseek f 0x4 #seek_cur            
  347.         )    
  348.         if TexPathSize2!=0 then fseek f 0x4E #seek_cur
  349.         )
  350.         if TexPathSize==0 then (            
  351.         FF=readlong f
  352.         NSize = readlong f
  353.         Nname = readFixedString f NSize    
  354.         fseek f 0x2A #seek_cur
  355.         TexPathSize2=readlong f
  356.         TexPath = readFixedString f TexPathSize2
  357.         fseek f 0x39 #seek_cur    
  358.         TexPathSize3=readlong f
  359.         TexPath = readFixedString f TexPathSize3
  360.         fseek f 0x11 #seek_cur            
  361. )
  362. )
  363. if MatId ==16 then
  364. (
  365.         fseek f 0x67 #seek_cur
  366.         TexPathSize=readlong f
  367.         TexPath = readFixedString f TexPathSize
  368.         if TexPathSize==0 then (            
  369.         FF=readlong f
  370.         NSize = readlong f
  371.         Nname = readFixedString f NSize    
  372.         fseek f 0x2A #seek_cur
  373.         TexPathSize2=readlong f
  374.         TexPath = readFixedString f TexPathSize2
  375.         fseek f 0x39 #seek_cur    
  376.         TexPathSize3=readlong f
  377.         TexPath = readFixedString f TexPathSize3
  378.         fseek f 0x21 #seek_cur            
  379. )
  380.        if TexPathSize!=0 then (        
  381.         FF=readlong f
  382.         NSize = readlong f
  383.         Nname = readFixedString f NSize    
  384.         if NSize==0 then 
  385.         (
  386.         fseek f 0x4 #seek_cur
  387.         TexPathSize=readlong f
  388.         TexPath = readFixedString f TexPathSize
  389.         fseek f 0x22 #seek_cur    
  390.         TexPathSize3=readlong f    
  391.         TexPath = readFixedString f TexPathSize3
  392.         if TexPathSize3==0 then 
  393.         (
  394.         fseek f 0x46 #seek_cur    
  395.         TexPathSize4=readlong f    
  396.         TexPath = readFixedString f TexPathSize4    
  397.         fseek f 0x14 #seek_cur                        
  398.         )    
  399.         if TexPathSize3!=0 then  fseek f 0x5E #seek_cur        
  400.         )    
  401. )
  402. )
  403. if MatId ==19 then
  404. (
  405.         fseek f 0x7E #seek_cur
  406.         TexPathSize=readlong f
  407.         TexPath = readFixedString f TexPathSize
  408.         FF=readlong f
  409.         NSize = readlong f
  410.         Nname = readFixedString f NSize    
  411.         fseek f 0x2A #seek_cur
  412.         TexPathSize=readlong f
  413.         TexPath = readFixedString f TexPathSize
  414.          fseek f 0x37 #seek_cur    
  415. )
  416. )
  417.         
  418. Print ("Mat End @ 0x"+((bit.intAsHex(ftell f))as string))    
  419.  
  420.         
  421. for a = 1 to numSkinObjext Do (
  422.     
  423. ModelNameSize = ReadLong f
  424. ModelName = readFixedString f ModelNameSize
  425. TextureID = ReadLong f
  426. MatlID = ReadLong f
  427. numVerts = ReadLong f
  428. numFaces = ReadLong f
  429.     
  430. vertArray = #()
  431. Facearray = #()    
  432. UV_array = #()
  433. Weight_array =#()
  434.     
  435. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))        
  436.     
  437. if Version==9 then        
  438. for x = 1 to numVerts Do (
  439. vx = Readfloat f
  440. vy = Readfloat f
  441. vz = Readfloat f
  442.     
  443. weight1 = Readfloat f
  444. weight2 = Readfloat f
  445. weight3 = Readfloat f
  446. weight4 = 0
  447.     
  448. bone1 = readbyte f #unsigned    
  449. bone2 = readbyte f #unsigned    
  450. bone3 = readbyte f #unsigned    
  451. bone4 = readbyte f #unsigned    
  452.     
  453. n1= Readfloat f
  454. n2 = Readfloat f
  455. n3 = Readfloat f    
  456.     
  457. tu=ReadFloat f    
  458. tv=ReadFloat f*-1
  459.  
  460. w = (weight_data boneids:#() weights:#())
  461. maxweight = 0
  462. if(weight1 != 0) then
  463.    maxweight = maxweight + weight1
  464. if(weight2 != 0) then
  465.    maxweight = maxweight + weight2
  466. if(weight3 != 0) then
  467.    maxweight = maxweight + weight3
  468. if(weight4 != 0) then
  469.    maxweight = maxweight + weight4
  470.  
  471.  
  472. if(maxweight != 0) then (
  473.       if(weight1 != 0) then (
  474.          w1 = weight1 as float
  475.          append w.boneids (bone1 + 1)
  476.          append w.weights (w1)
  477.       )
  478.       if(weight2 != 0) then (
  479.          w2 = weight2 as float
  480.          append w.boneids (bone2 + 1)
  481.          append w.weights (w2)
  482.       )
  483.       if(weight3 != 0) then (
  484.          w3 = weight3 as float
  485.          append w.boneids (bone3 + 1)
  486.          append w.weights (w3)
  487.       )
  488.       if(weight4 != 0) then (
  489.          w4 = weight4 as float
  490.          append w.boneids (bone4 + 1)
  491.         append w.weights (w4)
  492.       )      
  493.    )
  494. append Weight_array w               
  495. append vertArray ([-vx,-vz,vy]*100)
  496. append UV_array [tu,tv,0]     
  497. )        
  498.     
  499. if Version==10 then        
  500. for x = 1 to numVerts Do (
  501. vx = Readfloat f
  502. vy = Readfloat f
  503. vz = Readfloat f
  504.     
  505. weight1 = Readfloat f
  506. weight2 = Readfloat f
  507. weight3 = Readfloat f
  508. weight4 = 0
  509.     
  510. bone1 = readbyte f #unsigned    
  511. bone2 = readbyte f #unsigned    
  512. bone3 = readbyte f #unsigned    
  513. bone4 = readbyte f #unsigned    
  514.     
  515. n1= Readfloat f
  516. n2 = Readfloat f
  517. n3 = Readfloat f    
  518.     
  519. tu=ReadFloat f    
  520. tv=ReadFloat f*-1
  521.  
  522. Unk1 = Readfloat f    
  523.  
  524. w = (weight_data boneids:#() weights:#())
  525. maxweight = 0
  526. if(weight1 != 0) then
  527.    maxweight = maxweight + weight1
  528. if(weight2 != 0) then
  529.    maxweight = maxweight + weight2
  530. if(weight3 != 0) then
  531.    maxweight = maxweight + weight3
  532. if(weight4 != 0) then
  533.    maxweight = maxweight + weight4
  534.  
  535.  
  536. if(maxweight != 0) then (
  537.       if(weight1 != 0) then (
  538.          w1 = weight1 as float
  539.          append w.boneids (bone1 + 1)
  540.          append w.weights (w1)
  541.       )
  542.       if(weight2 != 0) then (
  543.          w2 = weight2 as float
  544.          append w.boneids (bone2 + 1)
  545.          append w.weights (w2)
  546.       )
  547.       if(weight3 != 0) then (
  548.          w3 = weight3 as float
  549.          append w.boneids (bone3 + 1)
  550.          append w.weights (w3)
  551.       )
  552.       if(weight4 != 0) then (
  553.          w4 = weight4 as float
  554.          append w.boneids (bone4 + 1)
  555.         append w.weights (w4)
  556.       )      
  557.    )
  558. append Weight_array w               
  559. append vertArray ([-vx,-vz,vy]*100)
  560. append UV_array [tu,tv,0]     
  561. )    
  562.  
  563. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  564.  
  565. for x = 1 to (numFaces/3) do 
  566. (
  567. f1 = (Readshort f #unsigned + 1) 
  568. f2 = (Readshort f #unsigned + 1) 
  569. f3 = (Readshort f #unsigned + 1) 
  570. append Facearray [f3,f2,f1]
  571. )
  572.  
  573. Print ("Model End @ 0x"+((bit.intAsHex(ftell f))as string))    
  574.  
  575. msh = mesh vertices:vertArray faces:faceArray
  576. msh.numTVerts = UV_array.count
  577. msh.name=ModelName
  578. buildTVFaces msh
  579. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  580. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  581. msh.displayByLayer = false
  582. msh.backfacecull = true
  583. msh.wirecolor = (color 230 200 210)
  584.  
  585. if Version==8 then
  586. (                
  587. try(
  588. max modify mode
  589. select msh
  590. skinMod = skin ()
  591. addModifier msh skinMod
  592. for i = 1 to BNArr.count do
  593. (
  594.     maxbone = BNArr[i] 
  595.     if i != BNArr.count then 
  596.         skinOps.addBone skinMod maxbone 0
  597.     else
  598.         skinOps.addBone skinMod maxbone 1
  599. )
  600. modPanel.setCurrentObject skinMod
  601. for i = 1 to (numVerts) do (
  602.    w = Weight_array[i]
  603.    bi = #() --bone index array
  604.    wv = #() --weight value array
  605.    
  606.    for j = 1 to w.boneids.count do
  607.    (
  608.       boneid = w.boneids[j]
  609.       weight = w.weights[j]
  610.       append bi boneid
  611.       append wv weight
  612.    )   
  613.    
  614.    skinOps.ReplaceVertexWeights skinMod i bi wv
  615.    
  616. )
  617. )catch(format "Failed - New VertType!!!\n")
  618. )
  619.  
  620. if Version!=8 then
  621. (    
  622. try(
  623. max modify mode
  624. select msh
  625. skinMod = skin ()
  626. addModifier msh skinMod    
  627. for i = 1 to numUsedBones do
  628. (
  629.     maxbone = getnodebyname BoneNamesArray[i] 
  630.     if i != numUsedBones then 
  631.         skinOps.addBone skinMod maxbone 0
  632.     else
  633.         skinOps.addBone skinMod maxbone 1
  634. )
  635. modPanel.setCurrentObject skinMod
  636. for i = 1 to (numVerts) do (
  637.    w = Weight_array[i]
  638.    bi = #() --bone index array
  639.    wv = #() --weight value array
  640.    
  641.    for j = 1 to w.boneids.count do
  642.    (
  643.       boneid = w.boneids[j]
  644.       weight = w.weights[j]
  645.       append bi boneid
  646.       append wv weight
  647.    )   
  648.    
  649.    skinOps.ReplaceVertexWeights skinMod i bi wv
  650.    
  651. )
  652. )catch(format "Failed - New VertType!!!\n")
  653. )
  654. )
  655.   
  656. for a = 1 to numStaticObject Do (
  657.     
  658. ModelNameSize = ReadLong f
  659. ModelName = readFixedString f ModelNameSize
  660. Unk1 = ReadLong f    
  661. TextureID = ReadLong f
  662. MatlID = ReadLong f
  663. numVerts = ReadLong f
  664. numFaces = ReadLong f
  665.     
  666. vertArray = #()
  667. Facearray = #()    
  668. UV_array = #()
  669.     
  670. Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  671.  
  672. if Version==9 then    
  673. for x = 1 to numVerts Do (
  674.     
  675. vx = Readfloat f
  676. vy = Readfloat f
  677. vz = Readfloat f
  678.     
  679. n1= Readfloat f
  680. n2 = Readfloat f
  681. n3 = Readfloat f    
  682.  
  683. tu=ReadFloat f    
  684. tv=ReadFloat f*-1    
  685.     
  686. append vertArray ([-vx,-vz,vy]*100)
  687. append UV_array [tu,tv,0]     
  688. )    
  689.     
  690. if Version==10 then    
  691. for x = 1 to numVerts Do (
  692.     
  693. vx = Readfloat f
  694. vy = Readfloat f
  695. vz = Readfloat f
  696.     
  697. n1= Readfloat f
  698. n2 = Readfloat f
  699. n3 = Readfloat f    
  700.  
  701. tu=ReadFloat f    
  702. tv=ReadFloat f*-1    
  703.     
  704. Unk1=ReadFloat f        
  705.     
  706. append vertArray ([-vx,-vz,vy]*100)
  707. append UV_array [tu,tv,0]     
  708. )    
  709.  
  710. Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))    
  711.  
  712. for x = 1 to (numFaces/3) do 
  713. (
  714. f1 = (Readshort f #unsigned + 1) 
  715. f2 = (Readshort f #unsigned + 1) 
  716. f3 = (Readshort f #unsigned + 1) 
  717. append Facearray [f3,f2,f1]
  718. )
  719.  
  720. try(
  721. msh = mesh vertices:vertArray faces:faceArray
  722. msh.numTVerts = UV_array.count
  723. msh.name=ModelName    
  724. buildTVFaces msh
  725. for j = 1 to UV_array.count do setTVert msh j UV_array[j]
  726. for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
  727. msh.displayByLayer = false
  728. msh.backfacecull = true
  729. msh.wirecolor = (color 230 200 210)
  730.  
  731. )catch(format "Failed - Static Mesh Error!!!\n")
  732. )
  733.  
  734. fclose f
  735.