def LoadFace(self, Node, FileStream, Offset): try: Node.FaceCount = binaryreader.ReadInt(FileStream, 1)[0] if (Node.FaceCount): Node.TotalDegrees = binaryreader.ReadInt(FileStream, 1)[0] Node.TotalTriangles = binaryreader.ReadInt(FileStream, 1)[0] for i in range(Node.FaceCount): MeshPolygonData = datatypes.FMeshPolygonData() MeshPolygonData.Vertices = binaryreader.ReadInt( FileStream, 1)[0] for j in range(MeshPolygonData.Vertices): UnsignedShorts = binaryreader.ReadUShort(FileStream, 6) FaceSubData = datatypes.FFaceSubData() FaceSubData.p = UnsignedShorts[0] FaceSubData.uv = UnsignedShorts[1] FaceSubData.uv2 = UnsignedShorts[2] FaceSubData.n = UnsignedShorts[3] FaceSubData.n_tan = UnsignedShorts[4] FaceSubData.n_bin = UnsignedShorts[5] MeshPolygonData.FaceSubDatas.append(FaceSubData) MeshPolygonData.MaterialID = binaryreader.ReadShort( FileStream, 1)[0] Node.PolygonTable.append(MeshPolygonData) try: assert Node.TotalDegrees == sum(len(MeshPolygonData.FaceSubDatas) \ for MeshPolygonData in Node.PolygonTable), \ "Assertion Failed: TotalDegrees value does not match expected value for node - {}".format(Node.NodeName) except AssertionError as err: errorhandling.HandleAssertionError(err) except struct.error as err: errorhandling.HandleStructUnpackError(err)
def __init__(self, FilePath): self.EluHeader = FEluHeader() self.EluMeshNodes = [] self.FilePath = FilePath self.SourceDir = os.path.dirname(FilePath) self.SourceFile = os.path.basename(FilePath) try: commonfunctions.GetFileExtension(self.FilePath) == '.elu'\ "Assertion Failed: File extension is not .elu, FilePath: {0}".format(FilePath) except AssertionError as err: errorhandling.HandleAssertionError(err) self.EluFileStream = open(FilePath, 'rb') self.LoadAndParseEluFile()
def __init__(self, FilePath): self.AniHeader = FAniHeader() self.AniMeshNodes = [] self.AniRootNode = None self.FilePath = FilePath self.SourceDir = os.path.dirname(FilePath) self.SourceFile = os.path.basename(FilePath) try: assert commonfunctions.GetFileExtension(self.FilePath) == '.ani', \ "Assertion Failed: File extension is not .ani, FilePath: {0}".format(FilePath) except AssertionError as err: errorhandling.HandleAssertionError(err) self.AniFileStream = open(FilePath, 'rb') self.LoadAndParseAniFile()
def LoadVertexInfo(self, Node, FileStream, Offset): try: Node.PointColorCount = binaryreader.ReadInt(FileStream, 1)[0] for i in range(Node.PointColorCount): Vec = datatypes.FVector(binaryreader.ReadFloat(FileStream, 3)) Node.PointColorTable.append(Vec) if Node.PointsCount == 0 or Node.FaceCount == 0: Node.AddFlag(raidflags.RM_FLAG_DUMMY_MESH) Node.MaterialID = binaryreader.ReadInt(FileStream, 1)[0] Node.PhysiqueCount = binaryreader.ReadInt(FileStream, 1)[0] if Node.PhysiqueCount: try: assert Node.PointsCount == Node.PhysiqueCount, \ "Assertion Failed: Points Count is not same as Physique Count - {0}".format(Node.NodeName) except AssertionError as err: errorhandling.HandleAssertionError(err) for i in range(Node.PhysiqueCount): Size = binaryreader.ReadInt(FileStream, 1)[0] PhysiqueInfo = datatypes.FPhysiqueInfo() for j in range(Size): PhysiqueSubData = datatypes.FPhysiqueSubData() PhysiqueSubData.cid = binaryreader.ReadUShort( FileStream, 1)[0] PhysiqueSubData.pid = binaryreader.ReadUShort( FileStream, 1)[0] PhysiqueSubData.weight = binaryreader.ReadFloat( FileStream, 1)[0] PhysiqueInfo.PhysiqueSubDatas.append(PhysiqueSubData) PhysiqueInfo.Num = len(PhysiqueInfo.PhysiqueSubDatas) Node.PhysiqueTable.append(PhysiqueInfo) if Size > raidflags.PHYSIQUE_MAX_WEIGHT: for m in range(Size): for n in range(m + 1, Size): if PhysiqueInfo.PhysiqueSubDatas[ m].weight < PhysiqueInfo.PhysiqueSubDatas[ n].weight: Temp = datatypes.FPhysiqueSubData() Temp = PhysiqueInfo.PhysiqueSubDatas[m] PhysiqueInfo.PhysiqueSubDatas[ m] = PhysiqueInfo.PhysiqueSubDatas[n] PhysiqueInfo.PhysiqueSubDatas[n] = Temp fSum3 = sum(PhysiqueSubData.weight for PhysiqueSubData in PhysiqueInfo.PhysiqueSubDatas) PhysiqueInfo.PhysiqueSubDatas[ 0].weight = PhysiqueInfo.PhysiqueSubDatas[ 0].weight / fSum3 PhysiqueInfo.PhysiqueSubDatas[ 1].weight = PhysiqueInfo.PhysiqueSubDatas[ 1].weight / fSum3 PhysiqueInfo.PhysiqueSubDatas[ 2].weight = PhysiqueInfo.PhysiqueSubDatas[ 2].weight / fSum3 PhysiqueInfo.Num = 3 except struct.error as err: errorhandling.HandleStructUnpackError(err)