Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn ReadFixedString bstream fixedLen = (
- local str = ""
- for i = 1 to fixedLen do
- (
- str += bit.intAsChar (ReadByte bstream #unsigned)
- )
- str
- )
- fn getID bstream offset = (
- id = 0
- backjump = ftell bstream
- fseek bstream offset #seek_set
- if offset > 0 then (
- id = (readbelong bstream)+1
- )
- fseek bstream backjump #seek_set
- return id
- )
- fn getOffset bstream offset = (
- backjump = ftell bstream
- fseek bstream offset #seek_set
- fseek bstream 0x8 #seek_cur
- theOffset = readbelong f
- null = readlong f
- fseek bstream backjump #seek_set
- return theOffset
- )
- -- fname = GetOpenFileName caption:"" types:"(.)|*."
- fname = @"C:\Users\Xavier\Desktop\BCTSH000.AMO"
- If (fname!=undefined) and ((DoesFileExist fname)==true) then (
- f = fopen fname "rb" --open file in read only format
- FileExtension = getFileNameType fname
- FileName = getFileNameFile fname
- clearlistener()
- Global fscale=5
- delete $*
- Print "===================================="
- print (FileName + FileExtension) as string
- Print "===================================="
- --)
- amo = ReadFixedString f 4
- fseek f 0xc #seek_cur
- boneCount = readbelong f
- fseek f 0x10 #seek_cur
- nameOffset = readbelong f
- fseek f 0x18 #seek_cur
- boneTable=#()
- tableOffset=#()
- tableOffset2=#()
- tableOffset3=#()
- parentID=#()
- boneOffset=#()
- -- table info --
- for x=1 to boneCount do (
- boneID = readbelong f
- boneTable[x] = readbelong f
- tableOffset[x] = readbelong f
- tableOffset2[x] = readbelong f
- tableOffset3[x] = readbelong f
- fseek f 0xc #seek_cur
- parentID[x] = getiD f tableOffset3[x]
- boneOffset[x] = getOffset f boneTable[x]
- -- print (bit.intashex(boneTable[x]))
- )
- -- name info --
- fseek f nameOffset #seek_set
- boneName=#()
- for x=1 to boneCount do (
- boneName[x] = ReadFixedString f 0x20
- )
- BNArr=#()
- for x=1 to boneCount do (
- fseek f boneOffset[x] #seek_set
- c11 = readbefloat f; c12 = readbefloat f; c13 = readbefloat f; c14 = readbefloat f
- c21 = readbefloat f; c22 = readbefloat f; c23 = readbefloat f; c24 = readbefloat f
- c31 = readbefloat f; c32 = readbefloat f; c33 = readbefloat f; c34 = readbefloat f
- tfm = (quat c11 c12 c13 c14) as matrix3
- tfm.row4 = ([c21,c22,c23])
- fseek f 0x20 #seek_cur
- -- if (parentID[x]+1 != 0) do (
- -- tfm = tfm * BNArr[(parentID[x]+1)].objecttransform
- -- )
- --
- if (parentID[x] != 0) then(
- tfm = tfm * BNArr[(parentID[x])].objecttransform
- )
- -- print x
- -- print parentID[x]+1
- -- format "\n"
- -- print BNArr[(parentID[x])].objecttransform
- newBone = bonesys.createbone \
- tfm.row4 \
- (tfm.row4 + 0.01 * (normalize tfm.row1)) \
- (normalize tfm.row3)
- newBone.width = 0.01
- newBone.height = 0.01
- newBone.transform = tfm
- newBone.setBoneEnable false 0
- newBone.wirecolor = white
- newbone.showlinks = true
- newbone.name = boneName[x]
- newBone.pos.controller = TCB_position ()
- newBone.rotation.controller = TCB_rotation ()
- -- print parentID[x]
- --
- if (parentID[x] != 0) then(
- newBone.parent = BNArr[(parentID[x])]
- )
- append BNArr newBone
- )
- rootRT = dummy name:"Main_Root" boxsize:[.1,.1,.1]
- for b in BNArr where b.parent==undefined do b.parent = rootRT
- rootRT.transform = (matrix3 [-1,0,0] [0,0,1] [0,-1,0] [0,0,0])
- Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
- )
- gc()
- fclose f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement