def read_bit_mask(self, filereader: BinaryFileReader): """Reads the bitmask for each color channel. May be stored outside of the header in Version 0 files""" #bit depth information self.bitDepthRed = filereader.read_uint32() self.bitDepthGreen = filereader.read_uint32() self.bitDepthBlue = filereader.read_uint32() self.bitDepthAlpha = filereader.read_uint32()
def read(self, filereader: BinaryFileReader): super().read(filereader) self.FileID: int = filereader.read_uint32() self.AmbientLightColor: List[float] = filereader.read_vec_f(4) self.unknown5: int = filereader.read_uint32() self.lightCount: int = filereader.read_uint32()
def read(self, filereader: BinaryFileReader): super().read(filereader) self.parent_room_string: SizedCString = SizedCString(filereader) self.name_string: SizedCString = SizedCString(filereader) if self.name_string.string == "Version": self.version_string: SizedCString = self.name_string self.versionNumber: int = filereader.read_uint32() self.name_string = SizedCString(filereader) self.unknown6: int = filereader.read_bytes(1)[0] self.lightType: int = filereader.read_uint32() self.direction: List[float] = filereader.read_vec_f(3) self.position: List[float] = filereader.read_vec_f(3) self.falloff: float = filereader.read_float() self.unknown2: List[float] = filereader.read_vec_f(2) self.unknown3: List[float] = filereader.read_vec_f(3) self.energy: float = filereader.read_float() self.diffuseColor: List[float] = filereader.read_vec_f(4) self.specularColor: List[float] = filereader.read_vec_f(4) self.ambientColor: List[float] = filereader.read_vec_f(4) self.constantAttenuation: float = filereader.read_float() self.linearAttenuation: float = filereader.read_float() self.quadraticAttenuation: float = filereader.read_float() self.spotlightConeAngle: float = filereader.read_float() self.type: int = filereader.read_bytes(1)[0]
def read(self, filereader: BinaryFileReader): super().read(filereader) self.vertexCount = filereader.read_uint32() self.vertices = [] for _ in range(self.vertexCount): self.vertices.append(filereader.read_vec_f(3)) self.normalCount = filereader.read_uint32() self.normals = [] self.faceDistancesFromOrigin = [] for _ in range(self.normalCount): self.normals.append(filereader.read_vec_f(3)) self.faceDistancesFromOrigin.append(filereader.read_float()) self.faceCount = filereader.read_uint32() self.faces = [] for _ in range(self.faceCount): faceObject = RSMAPCollisionFaceInformation() faceObject.read(filereader) self.faces.append(faceObject) self.collisionMeshDefinitionsCount = filereader.read_uint32() self.collisionMeshDefinitions = [] for _ in range(self.collisionMeshDefinitionsCount): dataObject = RSMAPCollisionMesh() dataObject.read(filereader) self.collisionMeshDefinitions.append(dataObject)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.unknown6 = filereader.read_uint32() #read header self.name_string = SizedCString(filereader) #read vertices self.numVertexIndices = filereader.read_uint32() self.vertexIndices = filereader.read_vec_uint32(self.numVertexIndices) #read faces self.numFaceIndices = filereader.read_uint32() self.faceIndices = filereader.read_vec_uint32(self.numFaceIndices) #read geometryFlags self.geometryFlags = filereader.read_uint32() self.geometryFlagsEvaluated = RSEGeometryFlags.EvaluateFlags( self.geometryFlags) #read unknown8 self.unknown_8_string = SizedCString(filereader) #read unknown9 self.unknown9 = filereader.read_uint32()
def read(self, filereader: BinaryFileReader): super().read(filereader) self.geometryListSize: int = filereader.read_uint32() self.id: int = filereader.read_uint32() self.geometry_list_string: SizedCString = SizedCString(filereader) self.count: int = filereader.read_uint32()
def read(self, filereader: BinaryFileReader): super().read(filereader) self.id: int = filereader.read_uint32() self.version_string: SizedCString = SizedCString(filereader) self.versionNumber: int = filereader.read_uint32() self.name_string: SizedCString = SizedCString(filereader) self.unknown1: int = filereader.read_bytes(1)[0] #A self.unknown2: int = filereader.read_bytes(1)[0] #B self.unknown3: int = filereader.read_bytes(1)[0] #C if self.unknown1 == 0: self.unknown4: int = filereader.read_bytes(1)[0] #D if self.unknown3 == 1: self.unknown5: List[float] = filereader.read_vec_f(6) if self.unknown1 == 0 and self.unknown4 == 1: self.unknown6: List[float] = filereader.read_vec_f(6) self.shermanLevelCount: int = filereader.read_uint32() self.shermanLevels: List[RSMAPShermanLevelDefinition] = [] for _ in range(self.shermanLevelCount): newObject = RSMAPShermanLevelDefinition() newObject.read(filereader) self.shermanLevels.append(newObject) self.unknown4Count: int = filereader.read_uint32() self.unknown7: float = filereader.read_float() self.unknown8: List[List[float]] = [] for _ in range(self.unknown4Count): newUnknown8 = filereader.read_vec_f(2) self.unknown8.append(newUnknown8)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.materialIndex: int = filereader.read_uint32() self.faceCount: int = filereader.read_uint32() self.faceNormals: List[List[float]] = [] self.faceDistancesFromOrigin: List[float] = [] for _ in range(self.faceCount): self.faceNormals.append(filereader.read_vec_f(3)) self.faceDistancesFromOrigin.append(filereader.read_float()) self.faceVertexIndices: List[List[int]] = [] for _ in range(self.faceCount): self.faceVertexIndices.append(filereader.read_vec_uint16(3)) self.faceVertexParamIndices: List[List[int]] = [] for _ in range(self.faceCount): self.faceVertexParamIndices.append(filereader.read_vec_uint16(3)) self.vertexParams: RSMAPVertexParameterCollection = RSMAPVertexParameterCollection( ) self.vertexParams.read(filereader)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.lightSize: int = filereader.read_uint32() self.id: int = filereader.read_uint32() #Some maps store a version string, others don't, not quite sure why. Also makes unknown6 quite unclear as to whether they are separate fields or not self.name_string: SizedCString = SizedCString(filereader) if self.name_string.string == "Version": self.version_string: SizedCString = self.name_string self.versionNumber: int = filereader.read_uint32() self.name_string = SizedCString(filereader) self.unknown6: int = filereader.read_uint32() else: self.unknown7: bytes = filereader.read_bytes(3) #3x3 matrix = 9 elements self.transformMatrix: List[float] = filereader.read_vec_f(9) self.position: List[float] = filereader.read_vec_f(3) self.color: List[int] = filereader.read_vec_uint32(3) self.constantAttenuation: float = filereader.read_float() self.linearAttenuation: float = filereader.read_float() self.quadraticAttenuation: float = filereader.read_float() #maybe? self.falloff: float = filereader.read_float() self.energy: float = filereader.read_float() self.type: int = filereader.read_bytes(1)[0]
def read_header_info(self, filereader: BinaryFileReader): """Reads top level information for this data structure""" self.size = filereader.read_uint32() self.id = filereader.read_uint32() self.version_string = SizedCString(filereader) self.versionNumber = filereader.read_uint32() self.name_string = SizedCString(filereader)
def read_header_info(self, filereader: BinaryFileReader): """Reads top level information for this data structure""" self.size = filereader.read_uint32() self.ID = filereader.read_uint32() self.name_string = SizedCString(filereader) #If the version string was actually set to version, then a version number is stored, along with object name if self.name_string.string == 'Version': self.version_string = self.name_string self.versionNumber = filereader.read_uint32() self.name_string = SizedCString(filereader) self.unknown4 = filereader.read_uint32() self.unknown5 = filereader.read_uint32()
def read(self, filereader: BinaryFileReader): super().read(filereader) self.name_string: SizedCString = SizedCString(filereader) self.geometryFlags: int = filereader.read_uint32() #?? self.geometryFlagsEvaluated: Dict[ str, bool] = RSEGeometryFlags.EvaluateFlags(self.geometryFlags) self.faceCount: int = filereader.read_uint32() self.faceIndices: List[int] = filereader.read_vec_uint16( self.faceCount)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.size = filereader.read_uint32() self.id = filereader.read_uint32() self.version_string = SizedCString(filereader) self.versionNumber = filereader.read_uint32() self.name_string = SizedCString(filereader) self.geometryData = RSMAPGeometryData() self.geometryData.read(filereader)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.name_string: SizedCString = SizedCString(filereader) self.transformCount: int = filereader.read_uint32() # ACount self.transforms: List[RSMAPShermanLevelTransformInformation] = [] for _ in range(self.transformCount): transformObj = RSMAPShermanLevelTransformInformation() transformObj.read(filereader) self.transforms.append(transformObj) self.unknown3Count: int = filereader.read_uint32() self.unknown3: List[float] = filereader.read_vec_f(self.unknown3Count) self.unknown4: int = filereader.read_bytes(1)[0]
def read(self, filereader: BinaryFileReader): super().read(filereader) self.vertexIndices: List[int] = filereader.read_vec_uint32(3) self.paramIndices: List[int] = filereader.read_vec_uint32(3) self.faceNormal: List[float] = filereader.read_vec_f(4) self.materialIndex: int = filereader.read_uint32()
def read_transition_objects(self, filereader: BinaryFileReader): """Reads the transition objects into a list""" self.transitionCount: int = filereader.read_uint32() self.transitions: List[RSMAPShermanLevelTransitionDefinition] = [] for _ in range(self.transitionCount): transition = RSMAPShermanLevelTransitionDefinition() transition.read(filereader) self.transitions.append(transition)
def read_vertex_params(self, filereader: BinaryFileReader): """ Reads a count of the number of vertex parameters, followed by the list of vertex parameters """ self.vertexParamsCount = filereader.read_uint32() self.vertexParams = [] for _ in range(self.vertexParamsCount): newParams = R6VertexParameterCollection() newParams.read(filereader) self.vertexParams.append(newParams)
def read_portals(self, filereader: BinaryFileReader): """reads all portals in list""" self.portalCount: int = filereader.read_uint32() self.portals: List[RSEMAPPortal] = [] for _ in range(self.portalCount): newPortal = RSEMAPPortal() newPortal.read(filereader) self.portals.append(newPortal)
def read_faces(self, filereader: BinaryFileReader): """ Reads a count of the number of faces, followed by the list of faces """ self.faceCount = filereader.read_uint32() self.faces = [] for _ in range(self.faceCount): newFace = R6FaceDefinition() newFace.read(filereader) self.faces.append(newFace)
def read_planning_levels(self, filereader: BinaryFileReader): """Reads the planning level objects into a list""" self.planningLevelCount: int = filereader.read_uint32() self.planningLevels: List[R6MAPPlanningLevelDefinition] = [] for _ in range(self.planningLevelCount): planLevel = R6MAPPlanningLevelDefinition() planLevel.read(filereader) self.planningLevels.append(planLevel)
def read_meshes(self, filereader: BinaryFileReader): """ Reads a count of the number of meshes, followed by the list of meshes """ self.meshCount = filereader.read_uint32() self.meshes = [] for _ in range(self.meshCount): newMesh = R6MeshDefinition() newMesh.read(filereader) self.meshes.append(newMesh)
def read(self, filereader: BinaryFileReader): """Reads the data from an RSB header. Overrides parent function""" super().read(filereader) self.version = filereader.read_uint32() self.width = filereader.read_uint32() self.height = filereader.read_uint32() if self.version == 0: self.containsPaletteRaw = filereader.read_uint32() if self.containsPaletteRaw == 1: self.containsPalette = True else: self.containsPalette = False #num_bytes_processed += 1 if self.version > 7: #process 3 more variables self.unknown2 = filereader.read_uint32() self.unknown3 = filereader.read_uint32() self.unknown4 = filereader.read_bytes(1) if self.version > 0: #bit depth information self.read_bit_mask(filereader) if self.version >= 9: self.unknown5 = filereader.read_uint32() self.dxtType = filereader.read_uint32() if self.dxtType >= 0 and self.dxtType < 5: self.isDXT = True
def read_face_groups(self, filereader: BinaryFileReader): """Reads the list of RSMAPFaceGroups from the file""" self.faceGroupCount = filereader.read_uint32() self.faceGroups: List[RSMAPFaceGroup] = [] for _ in range(self.faceGroupCount): newFaceGroup = RSMAPFaceGroup() newFaceGroup.read(filereader) self.faceGroups.append(newFaceGroup)
def read_objects(self, filereader: BinaryFileReader): """Reads all objects into a list""" self.objectCount: int = filereader.read_uint32() self.objects: List[RSEMAPObject] = [] for _ in range(self.objectCount): newObject = RSEMAPObject() newObject.read(filereader) self.objects.append(newObject)
def read_lights(self, filereader: BinaryFileReader): """Reads all lights into list""" self.lightCount: int = filereader.read_uint32() self.lights: List[R6MAPLight] = [] for _ in range(self.lightCount): newLight = R6MAPLight() newLight.read(filereader) self.lights.append(newLight)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.portalSize: int = filereader.read_uint32() self.id: int = filereader.read_uint32() self.version_string: SizedCString = SizedCString(filereader) self.versionNumber: int = filereader.read_uint32() self.name_string: SizedCString = SizedCString(filereader) self.vertexCount: int = filereader.read_uint32() self.vertices: List[List[float]] = [] for _ in range(self.vertexCount): self.vertices.append(filereader.read_vec_f(3)) self.roomA: int = filereader.read_uint32() self.roomB: int = filereader.read_uint32()
def read(self, filereader: BinaryFileReader): super().read(filereader) self.levelNumber: float = filereader.read_float() #A self.floorHeight: float = filereader.read_float() #B self.roomCount: int = filereader.read_uint32() self.roomNames: List[SizedCString] = [] for _ in range(self.roomCount): string = SizedCString(filereader) self.roomNames.append(string)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.header_begin_message = SizedCString(filereader) self.timePOSIXRaw = filereader.read_uint32() #special case handling, some files have a zero timestamp recorded, which datetime.fromtimestamp() doesn't like if self.timePOSIXRaw == 0: self.time = datetime(1970, 1, 1) else: self.time = datetime.fromtimestamp(self.timePOSIXRaw)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.id: int = filereader.read_uint32() self.version_string: SizedCString = SizedCString(filereader) self.versionNumber: int = filereader.read_uint32() self.name_string: SizedCString = SizedCString(filereader) self.unknown1: int = filereader.read_bytes(1)[0] self.unknown2: int = filereader.read_bytes(1)[0] if self.unknown1 == 0: self.unknown3: int = filereader.read_bytes(1)[0] self.shermanLevelCount: int = filereader.read_uint32() self.shermanLevels: List[R6MAPShermanLevelDefinition] = [] for _ in range(self.shermanLevelCount): newObject = R6MAPShermanLevelDefinition() newObject.read(filereader) self.shermanLevels.append(newObject) self.transitionCount: int = filereader.read_uint32() self.transitions: List[R6MAPShermanLevelTransitionDefinition] = [] for _ in range(self.transitionCount): tempTransition = R6MAPShermanLevelTransitionDefinition() tempTransition.read(filereader) self.transitions.append(tempTransition) self.levelHeightsCount: int = filereader.read_uint32() self.levelHeights: List[float] = filereader.read_vec_f( self.levelHeightsCount * 2) self.unknown5Count: int = filereader.read_uint32() self.unknown5: List[float] = filereader.read_vec_f(self.unknown5Count)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.name_string: SizedCString = SizedCString(filereader) self.AABB: List[float] = filereader.read_vec_f(6) self.unknown2Count: int = filereader.read_uint32() self.unknown2: List[float] = filereader.read_vec_f(self.unknown2Count) self.hasShermanLevelPlanArea: int = filereader.read_bytes(1)[0] if self.hasShermanLevelPlanArea == 1: self.shermanLevelPlanArea: R6MAPShermanLevelPlanAreaDefinition = R6MAPShermanLevelPlanAreaDefinition( ) self.shermanLevelPlanArea.read(filereader)