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.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.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.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(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_planning_level_list(self, filereader: BinaryFileReader, gameVer: str): """ Reads the list of planning levels, based on game version for slight format change gameVer should be a constant from RSEGameVersions """ super().read(filereader) self.read_header_info(filereader) self.read_planning_levels(filereader) if gameVer == RSEGameVersions.RAINBOW_SIX: self.unknown1: int = filereader.read_bytes(1)[0] #Y
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)
def read(self, filereader: BinaryFileReader): super().read(filereader) self.objectSize: int = filereader.read_uint32() self.objectType: int = filereader.read_uint32() self.version_string: SizedCString = SizedCString(filereader) self.versionNumber: int = filereader.read_uint32() self.name_string: SizedCString = SizedCString(filereader) if self.versionNumber >= self.RS_OBJECT_VERSION: self.bytes = filereader.read_bytes(self.objectSize) elif self.versionNumber == self.R6_OBJECT_VERSION: numberOfBytesToSkip = self.objectSize #skip 4 uints numberOfBytesToSkip = numberOfBytesToSkip - 4 * 4 #skip the length of the 2 strings numberOfBytesToSkip = numberOfBytesToSkip - self.name_string.string_length numberOfBytesToSkip = numberOfBytesToSkip - self.version_string.string_length self.bytes = filereader.read_bytes(numberOfBytesToSkip) else: log.critical("Unsupported Map object version: %d", self.versionNumber) return
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.unknown1: int = filereader.read_uint32() self.id: int = filereader.read_uint32() 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.unknown2_bytes: bytes = filereader.read_bytes(4) #ABCD self.unknown3: int = filereader.read_uint32() #U self.vertexCount: int = filereader.read_uint32() self.vertices: List[List[float]] = [] #coordinate for _ in range(self.vertexCount): self.vertices.append(filereader.read_vec_f(3)) self.vertexParamCount: int = filereader.read_uint32() self.vertexParams: List[R6VertexParameterCollection] = [] #coordinate2 for _ in range(self.vertexParamCount): newParams = R6VertexParameterCollection() newParams.read(filereader) self.vertexParams.append(newParams) self.faceCount: int = filereader.read_uint32() self.faces: List[R6FaceDefinition] = [] #coordinate3 for _ in range(self.faceCount): newFace = R6FaceDefinition() newFace.read(filereader) self.faces.append(newFace) self.unknown5: int = filereader.read_uint32() self.unknown6: int = filereader.read_uint32() self.unknown_7_string: SizedCString = SizedCString(filereader) self.unknown8: int = filereader.read_uint32() self.faceIndicesCount: int = filereader.read_uint32() self.faceIndices: List[int] = filereader.read_vec_uint32( self.faceIndicesCount) self.unknown10: int = filereader.read_uint32() self.unknown_11_string: SizedCString = SizedCString(filereader) self.unknown12: int = filereader.read_uint32()
def read_image(self, width: int, height: int, bytes_per_pixel: int, filereader: BinaryFileReader): """Reads data from the file that is to be interpreted as an image. Size of data read is determined by resolution and bytes per pixel. Image is not converted to RGBA image here, as the data can be a number of internal formats""" self.image = [] for _ in range(width * height): self.image.append(filereader.read_bytes(bytes_per_pixel))
def read(self, filereader: BinaryFileReader): super().read(filereader) self.size = filereader.read_uint32() self.ID = filereader.read_uint32() self.version_string = SizedCString(filereader) if self.version_string.string == 'Version': self.versionNumber = filereader.read_uint32() self.material_name = SizedCString(filereader) else: self.material_name = self.version_string self.texture_name = SizedCString(filereader) self.opacity = filereader.read_float() self.emissiveStrength = filereader.read_float() self.textureAddressMode = filereader.read_uint32( ) #1 = WRAP, 3 = CLAMP. https://docs.microsoft.com/en-au/windows/desktop/direct3d9/d3dtextureaddress gameVer = self.get_material_game_version() #check if it's a rainbow six file, or rogue spear file if gameVer == RSEGameVersions.RAINBOW_SIX: # Rainbow Six files typically have material sizes this size, or contain no version number self.ambientColorUInt = filereader.read_rgb_color_24bpp_uint() self.ambientColorFloat = list( normalize_color(self.ambientColorUInt)) self.diffuseColorUInt = filereader.read_rgb_color_24bpp_uint() self.diffuseColorFloat = list( normalize_color(self.diffuseColorUInt)) self.specularColorUInt = filereader.read_rgb_color_24bpp_uint() self.specularColorFloat = list( normalize_color(self.specularColorUInt)) self.normalizedColors = False elif gameVer == RSEGameVersions.ROGUE_SPEAR: #It's a Rogue Spear file self.ambientColorFloat = filereader.read_rgba_color_32bpp_float() self.ambientColorUInt = list( unnormalize_color(self.ambientColorFloat)) self.diffuseColorFloat = filereader.read_rgba_color_32bpp_float() self.diffuseColorUInt = list( unnormalize_color(self.diffuseColorFloat)) self.specularColorFloat = filereader.read_rgba_color_32bpp_float() self.specularColorUInt = list( unnormalize_color(self.specularColorFloat)) self.normalizedColors = True else: log.warning("Unhandled case") self.specularLevel = filereader.read_float() self.twoSidedRaw = filereader.read_bytes(1)[0] #TODO: Find a better way to read floats, maybe make this a function self.twoSided = False if self.twoSidedRaw > 0: self.twoSided = True