Esempio n. 1
0
 def __init__(self, f, start):
     self.version = readU32(f)  #uint
     self.ID = f.read(4).decode("utf-8-sig")  #readU32(f) # char
     self.ukn00 = readU32(f)  # uint32
     self.uknOffs = readU32(f)  #uint32
     self.offsToBoneHdrOffs = readU64(f)  #uint64     #BoneBaseDataPointer
     self.boneClipHdrOffs = readU64(
         f)  #uint64 FSkip(16) = readU32(f)   #BoneDataPointer
     f.seek(16, 1)
     self.clipFileOffset = readU64(f)  #uint64
     self.Offs1 = readU64(f)  # uint64
     f.seek(8, 1)
     self.Offs2 = readU64(f)  #uint64
     self.namesOffs = readU64(f)  #uint64           #namePointer
     self.frameCount = readFloat(f)  #frameCount
     self.blending = readFloat(f)
     self.uknFloat = readFloat(f)
     self.uknFloat = readFloat(f)
     self.boneCount = readUShort(f)  #ushort
     self.boneClipCount = readUShort(f)  #ushort
     self.uknPointer2Count = readUByte(f)  #ubyte
     self.uknPointer3Count = readUByte(f)  # ubyte
     self.FrameRate = readUShort(f)
     self.uknPointerCount = readUShort(f)
     self.uknShort = readUShort(f)
     f.seek(self.namesOffs + start)
     self.MOT_NAME = read_wstring(f)
Esempio n. 2
0
    def __init__(self, f, start, version):

        if version == 14:
            ## ZOOM START
            a1 = readU32(f)
            b1 = readU32(f)

            ## ZOOM
            self.zoomHdr = TrackHeader(f)
        else:
            s = readUShort(f)
            s = readUShort(f)
            i = readU32(f)
            ukn = readU32(f)
            ukn2 = readU32(f)
            offsetStart = readU64(f)
            self.zoomHdr = TrackHeaderRE2(f)

        ## ZOOM Framelist
        if (self.zoomHdr.framesOffset > 0):
            f.seek(self.zoomHdr.framesOffset + start)
            self.ZOOM_TIMES = [
                readUByte(f) for _ in range(self.zoomHdr.numFrames)
            ]

        ## ZOOM DATA
        f.seek(self.zoomHdr.dataOffset + start)
        self.ZOOM_DATA = [Vector3(f) for _ in range(self.zoomHdr.numFrames)]
Esempio n. 3
0
    def __init__(self, f, start, version):
        ## ROTATE AND TRANSLATE START
        if version == 14:
            a1 = readU32(f)
            b1 = readU32(f)
            self.translateHdr = TrackHeader(f)
            self.rotateHdr = TrackHeader(f)
        else:
            s = readUShort(f)
            s = readUShort(f)
            i = readU32(f)
            ukn = readU32(f)
            ukn2 = readU32(f)
            offsetStart = readU64(f)
            self.translateHdr = TrackHeaderRE2(f)
            self.rotateHdr = TrackHeaderRE2(f)

        ## TRANSLATE Framelist
        if (self.translateHdr.framesOffset > 0):
            f.seek(self.translateHdr.framesOffset + start)
            self.TRANSLATE_TIMES = [
                readUByte(f) for _ in range(self.translateHdr.numFrames)
            ]

        ## TRANSLATE DATA
        f.seek(self.translateHdr.dataOffset + start)
        self.TRANSLATE_DATA = [
            Vector3(f) for _ in range(self.translateHdr.numFrames)
        ]

        ## ROTATE Framelist
        if (self.rotateHdr.framesOffset > 0):
            f.seek(self.rotateHdr.framesOffset + start)
            self.ROTATE_TIMES = [
                readUByte(f) for _ in range(self.rotateHdr.numFrames)
            ]

        ## ROTATE DATA
        f.seek(self.rotateHdr.dataOffset + start)
        self.ROTATE_DATA = [Quat(f) for _ in range(self.rotateHdr.numFrames)]
Esempio n. 4
0
 def __init__(self, f, keyCount, flags, frameDataOffs
              ):  #uint32 keyCount, uint32 flags, uint64 frameDataOffs
     self.frameIndex = []
     if flags >> 20 == 2:
         for i in range(0, keyCount):
             self.frameIndex.append(readUByte(f))
         #ubyte frameIndex[keyCount]
     elif flags >> 20 == 4:
         for i in range(0, keyCount):
             self.frameIndex.append(readInt16(f))
         #int16 frameIndex[keyCount]
     elif flags >> 20 == 5:
         for i in range(0, keyCount):
             self.frameIndex.append(readI32(f))
Esempio n. 5
0
    def __init__(self, f, MOT, keyCount, flags, frame, framedatarot,
                 CUR_BONE_NAME):  #uint32 keyCount, uint32 flags
        start = MOT.start
        self.RotationTypeString = get_rotation_type(flags, MOT)
        self.CUR_BONE_NAME = CUR_BONE_NAME
        if hasattr(framedatarot, 'unpackData'):
            MinUnpackX = framedatarot.unpackData[4]
            MinUnpackY = framedatarot.unpackData[5]
            MinUnpackZ = framedatarot.unpackData[6]
            MinUnpackW = framedatarot.unpackData[7]

            MaxUnpackX = framedatarot.unpackData[0]
            MaxUnpackY = framedatarot.unpackData[1]
            MaxUnpackZ = framedatarot.unpackData[2]
            MaxUnpackW = framedatarot.unpackData[3]

        else:
            pass
            #print("find unpack? should be LoadVector3sFull")

        MOT_HEADER = MOT.MOT_HEADER
        ##unpackData = framedatarot.unpackData
        if hasattr(framedatarot, 'KEYS'):
            self.inverse = False
            self.Time = framedatarot.KEYS.frameIndex[frame]
            flagsEval = flags & 0xFF000

            if (flagsEval == 0x00000):  #//LoadQuaternionsFull
                self.RotationX = readFloat(f)
                self.RotationY = readFloat(f)
                self.RotationZ = readFloat(f)
                self.RotationW = readFloat(f)
                return

            # case 0x00000:
            #     float RotationX, RotationY, RotationZ, RotationW;
            #     break;

            if (flagsEval == 0xB0000 or flagsEval
                    == 0xC0000):  #          //LoadQuaternions3Component
                self.RotationX = readFloat(f)
                self.RotationY = readFloat(f)
                self.RotationZ = readFloat(f)
                #if (SKIP) break;
                self.RotationW = wRot(self)
                # local float
                return

            if (flagsEval == 0x20000):  #          //LoadQuaternions5Bit RE3
                RotationData = readUShort(f)  #ushort  #if (SKIP) return;
                self.RotationX = (MaxUnpackX * ((RotationData >> 00) & 0x1F) *
                                  (1.0 / 0x1F)) + MinUnpackX
                self.RotationY = (MaxUnpackY * ((RotationData >> 05) & 0x1F) *
                                  (1.0 / 0x1F)) + MinUnpackY
                self.RotationZ = (MaxUnpackZ * ((RotationData >> 10) & 0x1F) *
                                  (1.0 / 0x1F)) + MinUnpackZ
                self.RotationW = wRot(self)
                return

            #BiLinearSCQuat3_16bitController in revilmax
            if (
                    flagsEval == 0x21000
            ):  #          //LoadQuaternionsXAxis16Bit ##static constexpr uint32 ID1 = 0x21112; Revilmax
                #RotationData = readUShort(f)#ushort #if (SKIP) return;
                RotationData = readUShort(f)  #ushort #if (SKIP) return;
                self.RotationX = MaxUnpackX * (RotationData /
                                               65535.0) + MaxUnpackY
                ##CHANGED LOOK INTO
                self.RotationY = 0.0
                self.RotationZ = 0.0
                self.RotationW = wRot(self)

                # check = 1.0 - (self.RotationX * self.RotationX + self.RotationY * self.RotationY + self.RotationZ * self.RotationZ)
                # if check < 0:
                #     self.inverse = True
                #     self.RotationW = 2.0
                return

            if (flagsEval == 0x22000):  #          //LoadQuaternionsYAxis16Bit
                RotationData = readUShort(f)  #ushort #if (SKIP) return;
                self.RotationX = 0.0
                self.RotationY = MaxUnpackX * (RotationData /
                                               65535.0) + MaxUnpackY
                ##CHANGED LOOK INTO
                self.RotationZ = 0.0
                self.RotationW = wRot(self)
                return

            if (flagsEval == 0x23000):  #          //LoadQuaternionsZAxis16Bit
                RotationData = readUShort(f)  #ushort #if (SKIP) return;
                self.RotationX = 0.0
                self.RotationY = 0.0
                self.RotationZ = MaxUnpackX * (RotationData /
                                               65535.0) + MaxUnpackY
                ##CHANGED LOOK INTO
                self.RotationW = wRot(self)
                return

            if (flagsEval == 0x30000):  #          //LoadQuaternions10Bit RE2
                if (MOT_HEADER.version == 78):  #/LoadQuaternions8Bit RE3
                    RotationDataX = readUByte(
                        f
                    )  #ubyte RotationDataX, RotationDataY, RotationDataZ; #if (SKIP) return;
                    RotationDataY = readUByte(f)
                    RotationDataZ = readUByte(f)
                    componentMultiplier = 1.0 / 0xff
                    self.RotationX = (
                        (RotationDataX * componentMultiplier) * MaxUnpackX
                    ) + MinUnpackX  #(MaxUnpackX * (RotationDataX * 0.000015259022)) + MinUnpackX;
                    self.RotationY = (
                        (RotationDataY * componentMultiplier) * MaxUnpackY
                    ) + MinUnpackY  #(MaxUnpackY * (RotationDataY * 0.000015259022)) + MinUnpackY;
                    self.RotationZ = (
                        (RotationDataZ * componentMultiplier) * MaxUnpackZ
                    ) + MinUnpackZ  #(MaxUnpackZ * (RotationDataZ * 0.000015259022)) + MinUnpackZ;
                    self.RotationX = self.RotationX * 1.0
                    self.RotationY = self.RotationY * 1.0
                    self.RotationZ = self.RotationZ * 1.0
                    self.RotationW = wRot(self)
                    return
            if (flagsEval == 0x40000
                    or (MOT_HEADER.version == 65 and flagsEval == 0x30000)
                ):  #          //LoadQuaternions10Bit RE3 #TEETH ROT
                RotationData = readU32(f)  #uint32  #if (SKIP) return;
                componentMultiplier = 1.0 / 0x3FF
                self.RotationX = (MaxUnpackX * (
                    (RotationData >> 00) & 0x3FF) / 1023.0) + MinUnpackX
                self.RotationY = (MaxUnpackY * (
                    (RotationData >> 10) & 0x3FF) / 1023.0) + MinUnpackY
                self.RotationZ = (MaxUnpackZ * (
                    (RotationData >> 20) & 0x3FF) / 1023.0) + MinUnpackZ
                self.RotationW = wRot(self)
                return

            if (flagsEval == 0x31000 or flagsEval
                    == 0x41000):  #          //LoadQuaternionsXAxis
                self.RotationX = readFloat(f)  #float
                self.RotationY = 0.0
                self.RotationZ = 0.0
                #if (SKIP) return;
                self.RotationW = wRot(self)
                return

            if (flagsEval == 0x32000 or flagsEval
                    == 0x42000):  #          //LoadQuaternionsYAxis
                self.RotationX = 0.0
                self.RotationY = readFloat(f)
                self.RotationZ = 0.0
                #if (SKIP) return;
                self.RotationW = wRot(self)
                return

            if (flagsEval == 0x33000 or flagsEval
                    == 0x43000):  #          //LoadQuaternionsZAxis
                self.RotationX = 0.0
                self.RotationY = 0.0
                self.RotationZ = readFloat(f)
                #if (SKIP) return;
                self.RotationW = wRot(self)
                return

            if (flagsEval == 0x50000):  #          //LoadQuaternions16Bit RE2
                if (MOT_HEADER.version == 78):  #//LoadQuaternions13Bit RE3
                    #uint64 RotationData : 40;
                    # RotationData = readU64(f)
                    # f.seek(-3, 1); #if (SKIP) return;

                    rd = f.read(5)
                    RotationData = (
                        (ord(rd[0]) | 0x0000000000000000) << 32) | (
                            (ord(rd[1]) | 0x0000000000000000) << 24) | (
                                (ord(rd[2]) | 0x0000000000000000) << 16) | (
                                    (ord(rd[3]) | 0x0000000000000000) << 8) | (
                                        (ord(rd[4]) | 0x0000000000000000) << 0)

                    self.RotationX = ((MaxUnpackX * (
                        (RotationData >> 00) & 0x1FFF) * 0.00012208521) +
                                      MinUnpackX)
                    self.RotationY = ((MaxUnpackY * (
                        (RotationData >> 13) & 0x1FFF) * 0.00012208521) +
                                      MinUnpackY)
                    self.RotationZ = ((MaxUnpackZ * (
                        (RotationData >> 26) & 0x1FFF) * 0.00012208521) +
                                      MinUnpackZ)
                    self.RotationW = wRot(self)
                    return
            if (flagsEval == 0x60000
                    or (MOT_HEADER.version == 65 and flagsEval
                        == 0x50000)):  #          //LoadQuaternions16Bit RE3
                #ushort RotationDataX, RotationDataY, RotationDataZ; #if (SKIP) return;
                RotationDataX = readUShort(f)
                RotationDataY = readUShort(f)
                RotationDataZ = readUShort(f)
                self.RotationX = (MaxUnpackX * (RotationDataX / 65535.0) +
                                  MinUnpackX)
                self.RotationY = (MaxUnpackY * (RotationDataY / 65535.0) +
                                  MinUnpackY)
                self.RotationZ = (MaxUnpackZ * (RotationDataZ / 65535.0) +
                                  MinUnpackZ)
                self.RotationW = wRot(self)
                return

            if (flagsEval == 0x70000):  #          //LoadQuaternions21Bit RE2
                if (MOT_HEADER.version == 78):  #//LoadQuaternions18Bit RE3
                    #uint64 RotationData : 56;
                    # RotationData = readU64(f)
                    # f.skip(-1,1)#FSkip(-1); #if (SKIP) return;
                    rd = f.read(7)
                    RotationData = (
                        (ord(rd[0]) | 0x0000000000000000) << 48
                    ) | ((ord(rd[1]) | 0x0000000000000000) << 40) | (
                        (ord(rd[2]) | 0x0000000000000000) << 32) | (
                            (ord(rd[3]) | 0x0000000000000000) << 24) | (
                                (ord(rd[4]) | 0x0000000000000000) << 16) | (
                                    (ord(rd[5]) | 0x0000000000000000) << 8) | (
                                        (ord(rd[6]) | 0x0000000000000000) << 0)

                    self.RotationX = (MaxUnpackX *
                                      ((RotationData >> 00) & 0x1FFF) *
                                      0.00012208521) + MinUnpackX
                    self.RotationY = (MaxUnpackY *
                                      ((RotationData >> 13) & 0x1FFF) *
                                      0.00012208521) + MinUnpackY
                    self.RotationZ = (MaxUnpackZ *
                                      ((RotationData >> 26) & 0x1FFF) *
                                      0.00012208521) + MinUnpackZ
                    self.RotationW = wRot(self)
                    return
            if (flagsEval == 0x80000
                    or (MOT_HEADER.version == 65 and flagsEval
                        == 0x70000)):  #          //LoadQuaternions21Bit RE3
                RotationData = readU64(f)
                #uint64 #if (SKIP) return;
                self.RotationX = (MaxUnpackX * (
                    (RotationData >> 00) & 0x1FFFFF) / 2097151.0) + MinUnpackX
                self.RotationY = (MaxUnpackY * (
                    (RotationData >> 21) & 0x1FFFFF) / 2097151.0) + MinUnpackY
                self.RotationZ = (MaxUnpackZ * (
                    (RotationData >> 42) & 0x1FFFFF) / 2097151.0) + MinUnpackZ
                self.RotationW = wRot(self)
                return

            print("uh oh")