home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 7132 / SWTOR.7z / SWTOR_BONES.ms next >
Encoding:
Text File  |  2014-03-18  |  2.6 KB  |  88 lines

  1. if (heapSize < 20000000) then
  2.     heapSize = 200000000
  3. fname = getOpenFileName \
  4. caption:"Open .gr2 from Skeleton folder" \
  5. types:"SWTOR_SKEL (*_skeleton.gr2)|*_skeleton.gr2" \
  6. historyCategory:"SWTOR_SKELObjectPresets"
  7. f = fopen fname "rb"
  8.  
  9.  
  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. (
  24.     local str = ""
  25.     for i = 1 to fixedLen do
  26.     (
  27.         str += bit.intAsChar (ReadByte bstream #unsigned)
  28.     )
  29.     str
  30. )    
  31.  
  32. clearlistener()
  33.  
  34. BNArr = #()   
  35. BoneNamesArray=#()    
  36. fseek f 0x1C #seek_set
  37. BCount=readlong f
  38. print BCount
  39.  
  40. fseek f 0x70 #seek_set
  41. for a = 1 to BCount do (
  42. getPos = ftell f + 136    
  43. BoneNameOffset = readlong f
  44. fseek f getPos #seek_set    
  45. Pos=ftell f    
  46. fseek f BoneNameOffset #seek_set    
  47. BoneName= readstring f
  48. fseek f Pos #seek_set    
  49. append BoneNamesArray BoneName    
  50. )    
  51.  
  52. fseek f 0x70 #seek_set
  53. for a = 1 to BCount do (
  54. BoneNameOffset = readlong f #unsigned
  55. BoneParent    = readlong f 
  56. a11 = Readfloat f; a12 = Readfloat f; a13 = Readfloat f; a14 = Readfloat f
  57. a21 = Readfloat f; a22 = Readfloat f; a23 = Readfloat f; a24 = Readfloat f
  58. a31 = Readfloat f; a32 = Readfloat f; a33 = Readfloat f; a34 = Readfloat f    
  59. a41 = Readfloat f; a42 = Readfloat f; a43 = Readfloat f; a44 = Readfloat f
  60.     
  61. c11 = Readfloat f; c12 = Readfloat f; c13 = Readfloat f; c14 = Readfloat f
  62. c21 = Readfloat f; c22 = Readfloat f; c23 = Readfloat f; c24 = Readfloat f
  63. c31 = Readfloat f; c32 = Readfloat f; c33 = Readfloat f; c34 = Readfloat f    
  64. c41 = Readfloat f; c42 = Readfloat f; c43 = Readfloat f; c44 = Readfloat f    
  65.     
  66. tfm = matrix3 [c11,c13,c12] [c21,c23,c22] [c31,c33,c32] ([c41,c43,c42]*1000)
  67.     
  68.     newBone = bonesys.createbone    \
  69.                   tfm.row4    \
  70.                   (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  71.                   (normalize tfm.row3)
  72.             newBone.name = BoneNamesArray[a]
  73.             newBone.width  = 0.01
  74.             newBone.height = 0.01
  75.             newBone.transform =  inverse tfm          
  76.             newBone.setBoneEnable false 0
  77.             newBone.wirecolor = white
  78.             newbone.showlinks = true
  79.             newBone.pos.controller      = TCB_position ()
  80.             newBone.rotation.controller = TCB_rotation ()
  81. if (boneparent != -1) then
  82.  newBone.parent = BNArr[(boneparent + 1)]                              
  83. append BNArr newBone
  84. )    
  85.  
  86. Print ("Bones Sec End @ 0x"+((bit.intAsHex(ftell f))as string))    
  87.  
  88. fclose f