Advertisement
Guest User

Untitled

a guest
Aug 13th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1.  
  2. fn ReadFixedString bstream fixedLen = (
  3. local str = ""
  4. for i = 1 to fixedLen do
  5. (
  6. str += bit.intAsChar (ReadByte bstream #unsigned)
  7. )
  8. str
  9. )
  10. fn getID bstream offset = (
  11. id = 0
  12.  
  13. backjump = ftell bstream
  14. fseek bstream offset #seek_set
  15. if offset > 0 then (
  16. id = (readbelong bstream)+1
  17. )
  18. fseek bstream backjump #seek_set
  19. return id
  20. )
  21. fn getOffset bstream offset = (
  22. backjump = ftell bstream
  23. fseek bstream offset #seek_set
  24. fseek bstream 0x8 #seek_cur
  25. theOffset = readbelong f
  26. null = readlong f
  27. fseek bstream backjump #seek_set
  28. return theOffset
  29. )
  30.  
  31. -- fname = GetOpenFileName caption:"" types:"(.)|*."
  32. fname = @"C:\Users\Xavier\Desktop\BCTSH000.AMO"
  33. If (fname!=undefined) and ((DoesFileExist fname)==true) then (
  34. f = fopen fname "rb" --open file in read only format
  35. FileExtension = getFileNameType fname
  36. FileName = getFileNameFile fname
  37. clearlistener()
  38. Global fscale=5
  39. delete $*
  40. Print "===================================="
  41. print (FileName + FileExtension) as string
  42. Print "===================================="
  43. --)
  44.  
  45. amo = ReadFixedString f 4
  46. fseek f 0xc #seek_cur
  47. boneCount = readbelong f
  48. fseek f 0x10 #seek_cur
  49. nameOffset = readbelong f
  50. fseek f 0x18 #seek_cur
  51.  
  52. boneTable=#()
  53. tableOffset=#()
  54. tableOffset2=#()
  55. tableOffset3=#()
  56. parentID=#()
  57. boneOffset=#()
  58.  
  59. -- table info --
  60. for x=1 to boneCount do (
  61. boneID = readbelong f
  62. boneTable[x] = readbelong f
  63. tableOffset[x] = readbelong f
  64. tableOffset2[x] = readbelong f
  65. tableOffset3[x] = readbelong f
  66. fseek f 0xc #seek_cur
  67.  
  68. parentID[x] = getiD f tableOffset3[x]
  69. boneOffset[x] = getOffset f boneTable[x]
  70.  
  71.  
  72. -- print (bit.intashex(boneTable[x]))
  73. )
  74.  
  75. -- name info --
  76. fseek f nameOffset #seek_set
  77. boneName=#()
  78. for x=1 to boneCount do (
  79. boneName[x] = ReadFixedString f 0x20
  80. )
  81.  
  82. BNArr=#()
  83. for x=1 to boneCount do (
  84. fseek f boneOffset[x] #seek_set
  85.  
  86. c11 = readbefloat f; c12 = readbefloat f; c13 = readbefloat f; c14 = readbefloat f
  87. c21 = readbefloat f; c22 = readbefloat f; c23 = readbefloat f; c24 = readbefloat f
  88. c31 = readbefloat f; c32 = readbefloat f; c33 = readbefloat f; c34 = readbefloat f
  89. tfm = (quat c11 c12 c13 c14) as matrix3
  90. tfm.row4 = ([c21,c22,c23])
  91. fseek f 0x20 #seek_cur
  92.  
  93. -- if (parentID[x]+1 != 0) do (
  94. -- tfm = tfm * BNArr[(parentID[x]+1)].objecttransform
  95. -- )
  96. --
  97. if (parentID[x] != 0) then(
  98. tfm = tfm * BNArr[(parentID[x])].objecttransform
  99. )
  100.  
  101. -- print x
  102. -- print parentID[x]+1
  103. -- format "\n"
  104. -- print BNArr[(parentID[x])].objecttransform
  105.  
  106. newBone = bonesys.createbone \
  107. tfm.row4 \
  108. (tfm.row4 + 0.01 * (normalize tfm.row1)) \
  109. (normalize tfm.row3)
  110. newBone.width = 0.01
  111. newBone.height = 0.01
  112. newBone.transform = tfm
  113. newBone.setBoneEnable false 0
  114. newBone.wirecolor = white
  115. newbone.showlinks = true
  116. newbone.name = boneName[x]
  117. newBone.pos.controller = TCB_position ()
  118. newBone.rotation.controller = TCB_rotation ()
  119.  
  120. -- print parentID[x]
  121. --
  122. if (parentID[x] != 0) then(
  123.  
  124. newBone.parent = BNArr[(parentID[x])]
  125. )
  126.  
  127. append BNArr newBone
  128. )
  129.  
  130. rootRT = dummy name:"Main_Root" boxsize:[.1,.1,.1]
  131. for b in BNArr where b.parent==undefined do b.parent = rootRT
  132. rootRT.transform = (matrix3 [-1,0,0] [0,0,1] [0,-1,0] [0,0,0])
  133.  
  134.  
  135.  
  136. Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
  137. )
  138. gc()
  139. fclose f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement