home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 6921 / Script.7z / Warframe_Bones.ms next >
Encoding:
Text File  |  2014-01-01  |  4.4 KB  |  166 lines

  1. if (heapSize < 20000000) then
  2.     heapSize = 200000000
  3. gname = getOpenFileName \
  4. caption:"Open .fbx from Bones folder" \
  5. types:"Warframe_Bones (*.fbx)|*.fbx" \
  6. historyCategory:"WarframeObjectPresets"
  7. g = fopen gname "rb"
  8. fname = getOpenFileName \
  9. caption:"Open .fbx from Mesh folder" \
  10. types:"Warframe (*.fbx)|*.fbx" \
  11. historyCategory:"WarframeObjectPresets"
  12. f = fopen fname "rb"
  13.  
  14.  
  15.  
  16. fn readHalfFloat fstream = (
  17.     hf=readshort fstream #unsigned
  18.     sign = bit.get hf 16
  19.     exponent = (bit.shift (bit.and hf (bit.hexasint "7C00")) -10) as integer - 16
  20.     fraction = bit.and hf (bit.hexasint "03FF")
  21.     if sign==true then sign = 1 else sign = 0
  22.     exponentF = exponent + 127
  23.     outputAsFloat = bit.or (bit.or (bit.shift fraction 13) \
  24.     (bit.shift exponentF 23)) (bit.shift sign 31)
  25.     return bit.intasfloat outputasfloat*2
  26.     )
  27.  
  28. fn ReadFixedString bstream fixedLen =
  29. (
  30.     local str = ""
  31.     for i = 1 to fixedLen do
  32.     (
  33.         str += bit.intAsChar (ReadByte bstream #unsigned)
  34.     )
  35.     str
  36. )    
  37.  
  38. clearlistener()
  39.  
  40. struct weight_data
  41. (
  42.    boneids,weights
  43. )
  44. struct face_info_struct
  45. (
  46. FacePos,FaceCount
  47. )
  48. clearlistener()
  49.  
  50. BoneNamesArray = #()
  51. BoneNamesArray1 = #()
  52. boneparent_array = #()
  53. UsedBoneCountArray = #()
  54. FaceArray = #()
  55. BNArr = #()
  56.  
  57.  
  58. fseek g 0x10 #seek_set
  59. skelCount = readlong g
  60. modelPathS = readlong g
  61. modelPath = ReadFixedString g modelPathS
  62. materialS = readlong g
  63. materialname = ReadFixedString g materialS
  64. fseek g 0x6f #seek_cur
  65. BoneCount = readlong g
  66. for a = 1 to BoneCount do (
  67. BoneNameSize = readlong g    
  68. BoneName = ReadFixedString g BoneNameSize    
  69. append BoneNamesArray BoneName
  70. )    
  71. TotalFaces = readlong g    
  72. UsedBones = readlong g
  73. NumVert = readlong g    
  74. NumMorph = readlong g    
  75. fseek g 0x4 #seek_cur
  76. parse = readlong g
  77. if parse!=2 then fseek g 0x3D #seek_cur
  78. if parse==2 then fseek g 0x5D #seek_cur
  79. BoneCount1 = readlong g
  80. for a = 1 to BoneCount1 do (
  81. BoneNameSize1 = readlong g    
  82. BoneName1 = ReadFixedString g BoneNameSize1
  83. append BoneNamesArray1 BoneName1
  84. boneparent=readshort g
  85. boneId=readshort g
  86. append boneparent_array boneparent
  87. )    
  88.  
  89. fseek g 0xA2 #seek_cur
  90. MeshCount=readlong g    
  91. for a = 1 to MeshCount do (    
  92. fseek g 0x20 #seek_cur    
  93. NameSize=readlong g
  94. meshname = ReadFixedString g NameSize
  95. FacePos=readlong g
  96. Lod_1=readlong g
  97. Lod_2=readlong g    
  98. Lod_3=readlong g
  99. Lod_4=readlong g    
  100. FaceCount=readlong g    
  101. Lod_1_Count=readlong g    
  102. Lod_2_Count=readlong g
  103. Lod_3_Count=readlong g    
  104. Lod_4_Count=readlong g    
  105. fseek g 0x34 #seek_cur
  106. append FaceArray (face_info_struct FacePos:FacePos FaceCount:FaceCount)        
  107. )
  108.  
  109. print FaceArray
  110.  
  111. Print ("Last Read @ 0x"+((bit.intAsHex(ftell g))as string))
  112.  
  113.  
  114. BNArr = #()
  115. fseek f 0x2 #seek_set
  116. for a = 1 to BoneCount do (
  117. b11 = Readfloat f; b12 = Readfloat f; b13 = Readfloat f; b14 = Readfloat f
  118. b21 = Readfloat f; b22 = Readfloat f; b23 = Readfloat f; b24 = Readfloat f
  119. b31 = Readfloat f; b32 = Readfloat f; b33 = Readfloat f; b34 = Readfloat f
  120. b41 = Readfloat f; b42 = Readfloat f; b43 = Readfloat f; b44 = Readfloat f
  121. )    
  122.  
  123. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  124.     
  125. BNArr1 = #()
  126. for a = 1 to BoneCount1 do ( --second bones section
  127. c11 = Readfloat f; c12 = Readfloat f; c13 = Readfloat f; c14 = Readfloat f*-1
  128. c21 = Readfloat f; c22 = Readfloat f; c23 = Readfloat f; c24 = Readfloat f
  129. c31 = Readfloat f; c32 = Readfloat f; c33 = Readfloat f; c34 = Readfloat f
  130. c41 = Readfloat f; c42 = Readfloat f; c43 = Readfloat f; c44 = Readfloat f
  131.  
  132. tfm2 = (quat c11 c12 c13 c14) as matrix3
  133. tfm2.row4 = ([c21,c22,c23]*100)
  134. print tfm2    
  135. if (boneparent_array[a] != 0) do (
  136. tfm2 = tfm2 * BNArr1[(boneparent_array[a] +1)].objecttransform    
  137. )    
  138.  
  139. if (getNodeByName BoneNamesArray1[a]) != undefined do (
  140. append BNArr1 (getNodeByName BoneNamesArray1[a])
  141. )
  142. if (getNodeByName BoneNamesArray1[a]) == undefined do (
  143.  
  144.     newBone2 = bonesys.createbone    \
  145.                   tfm2.row4    \
  146.                   (tfm2.row4 + 0.01 * (normalize tfm2.row1)) \
  147.                   (normalize tfm2.row3)
  148.             newBone2.name = BoneNamesArray1[a]
  149.             newBone2.width  = 0.01
  150.             newBone2.height = 0.01
  151.             newBone2.transform = tfm2          
  152.             newBone2.setBoneEnable false 0
  153.             newBone2.wirecolor = white
  154.             newbone2.showlinks = true
  155.             newBone2.pos.controller      = TCB_position ()
  156.             newBone2.rotation.controller = TCB_rotation ()        
  157. if (boneparent_array[a] != -1) then
  158.  newBone2.parent = BNArr1[(boneparent_array[a] + 1)]                      
  159. append BNArr1 newBone2
  160. )    
  161. )
  162.  
  163. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  164.     
  165. fclose g    
  166. fclose f