def HandleAssertionError(err): Message = err.args[0] filelogger.AddLog(globalvars.LogFileStream, Message, filelogger.ELogMessageType.Log_Error) filelogger.CloseLogFileStream(globalvars.LogFileStream, filelogger.LogStreamEndReason.ProgramError) exit()
def HandleStructUnpackError(err): Message = "Struct Unpack Error" filelogger.AddLog(globalvars.LogFileStream, Message, filelogger.ELogMessageType.Log_Error) filelogger.CloseLogFileStream(globalvars.LogFileStream, filelogger.LogStreamEndReason.ProgramError) exit()
def LoadInfo(self, Node, FileStream, Offset): try: Node.LocalMatrix = datatypes.FMatrix( binaryreader.ReadFloat(FileStream, 16)) Node.BaseVisibility = binaryreader.ReadFloat(FileStream, 1)[0] Node.dwFlag = binaryreader.ReadUInt(FileStream, 1)[0] try: Node.MeshAlign = datatypes.RMeshAlign( binaryreader.ReadInt(FileStream, 1)[0]) except ValueError as er: Message = "Node.MeshAlign value is out of allowed range." filelogger.AddLog(globalvars.LogFileStream, Message, filelogger.LogType.LogType_Warning) Node.LODProjectIndex = binaryreader.ReadInt(FileStream, 1)[0] except struct.error as err: errorhandling.HandleStructUnpackError(err)
def LoadInfo(self, Node, FileStream, Offset): try: Node.dwFlag = binaryreader.ReadUInt(FileStream, 1)[0] try: Node.MeshAlign = datatypes.RMeshAlign( binaryreader.ReadInt(FileStream, 1)[0]) except ValueError as er: Message = "Node.MeshAlign value is out of allowed range." filelogger.AddLog(globalvars.LogFileStream, Message, filelogger.LogType.LogType_Warning) if globalvars.CurrentEluFileVersion < raidflags.EXPORTER_MESH_VER11: # Unused data AniPartsType = binaryreader.ReadInt(FileStream, 1)[0] PartsPosInfoType = binaryreader.ReadInt(FileStream, 1)[0] PartsType = binaryreader.ReadInt(FileStream, 1)[0] Node.LocalMatrix = datatypes.FMatrix( binaryreader.ReadFloat(FileStream, 16)) if globalvars.CurrentEluFileVersion >= raidflags.EXPORTER_MESH_VER11: Node.BaseVisibility = binaryreader.ReadInt(FileStream, 1)[0] except struct.error as err: errorhandling.HandleStructUnpackError(err)
def LoadBoneAni(self, Node, FileStream, Offset=None): try: Node.Name = binaryreader.ReadWord(FileStream) Node.BaseTranslation = datatypes.FVector( binaryreader.ReadFloat(FileStream, 3)) Node.BaseRotation = datatypes.FQuaternion( binaryreader.ReadFloat(FileStream, 4)) Node.BaseScale = datatypes.FVector( binaryreader.ReadInt(FileStream, 3)) AnimType_1 = datatypes.FAnimType( binaryreader.ReadInt(FileStream, 3)) if AnimType_1.Count > 0: Node.PositionKeyTrack.Count = AnimType_1.Count + 1 if AnimType_1.CountType == 10: for i in range(AnimType_1.Count): Frame = binaryreader.ReadInt(FileStream, 1)[0] ShortTuple = binaryreader.ReadUShort(FileStream, 3) FloatTuple = datatypes.ConvertShortToFloat(ShortTuple) PosKey = datatypes.FVecKey() PosKey.Frame = Frame PosKey.Vector = datatypes.FVector(FloatTuple) Node.PositionKeyTrack.Data.append(PosKey) LastPosKey = Node.PositionKeyTrack.Data[AnimType_1.Count - 1] Node.PositionKeyTrack.Data.append(LastPosKey) elif AnimType_1.CountType == 16: for i in range(AnimType_1.Count): PosKey = datatypes.FVecKey() PosKey.Vector = datatypes.FVector( binaryreader.ReadFloat(FileStream, 3)) PosKey.Frame = binaryreader.ReadInt(FileStream, 1)[0] Node.PositionKeyTrack.Data.append(PosKey) LastPosKey = Node.PositionKeyTrack.Data[AnimType_1.Count - 1] Node.PositionKeyTrack.Data.append(LastPosKey) else: Message = "{0} node error: RAnimType_1.CountType is incorrect.".format( Node.Name) filelogger.AddLog(globalvars.LogFileStream, Message, filelogger.ELogMessageType.Log_Error) return AnimType_2 = datatypes.FAnimType( binaryreader.ReadInt(FileStream, 3)) if AnimType_2.Count > 0: Node.RotationKeyTrack.Count = AnimType_2.Count + 1 if AnimType_2.CountType == 10: for i in range(AnimType_2.Count): Frame = binaryreader.ReadInt(FileStream, 1)[0] ShortTuple = binaryreader.ReadUShort(FileStream, 3) X, Y, Z = datatypes.ConvertShortToFloat(ShortTuple) W = 0 FTol = X * X + Y * Y + Z * Z if FTol <= 1.0: Sub1 = 1.0 - FTol FSqrt = math.sqrt(Sub1) W = FSqrt QuatKey = datatypes.FQuatKey() QuatKey.Frame = Frame QuatKey.Quat = datatypes.FQuaternion((X, Y, Z, W)) Node.RotationKeyTrack.Data.append(QuatKey) LastQuatKey = Node.RotationKeyTrack.Data[AnimType_2.Count - 1] Node.RotationKeyTrack.Data.append(LastQuatKey) elif AnimType_2.CountType == 16: for i in range(AnimType_2.Count): Frame = binaryreader.ReadInt(FileStream, 1)[0] X, Y, Z = binaryreader.ReadFloat(FileStream, 3) W = 0 FTol = X * X + Y * Y + Z * Z if FTol <= 1.0: Sub1 = 1.0 - FTol FSqrt = math.sqrt(Sub1) W = FSqrt QuatKey = datatypes.FQuatKey() QuatKey.Frame = Frame QuatKey.Quat = datatypes.FQuaternion((X, Y, Z, W)) Node.RotationKeyTrack.Data.append(QuatKey) LastQuatKey = Node.RotationKeyTrack.Data[AnimType_2.Count - 1] Node.RotationKeyTrack.Data.append(LastQuatKey) elif AnimType_2.CountType == 20: for i in range(AnimType_2.Count): QuatKey = datatypes.FQuatKey() QuatKey.Quat = datatypes.FQuaternion( binaryreader.ReadFloat(FileStream, 4)) QuatKey.Frame = binaryreader.ReadInt(FileStream, 1)[0] Node.RotationKeyTrack.Data.append(QuatKey) LastQuatKey = Node.RotationKeyTrack.Data[AnimType_2.Count - 1] Node.RotationKeyTrack.Data.append(LastQuatKey) else: Message = "{0} node error: RAnimType_2.CountType is incorrect.".format( Node.Name) filelogger.AddLog(globalvars.LogFileStream, Message, filelogger.ELogMessageType.Log_Error) return AnimType_3 = datatypes.FAnimType( binaryreader.ReadInt(FileStream, 3)) if AnimType_3.Count > 0: Node.ScaleKeyTrack.Count = AnimType_3.Count for i in range(AnimType_3.Count): ScaleKey = datatypes.FVecKey() ScaleKey.Vector = datatypes.FVector( binaryreader.ReadFloat(FileStream, 3)) ScaleKey.Frame = binaryreader.ReadInt(FileStream, 1)[0] Node.ScaleKeyTrack.Data.append(ScaleKey) except struct.error as err: errorhandling.HandleStructUnpackError(err)