def read(self, reader: ByteIO): self.endframeIndex = reader.read_uint32() self.motionFlags = reader.read_uint32() self.v0 = reader.read_float() self.v1 = reader.read_float() self.angle = reader.read_float() self.vector.read(reader) self.position.read(reader) return self
def read(self, reader: ByteIO): self.boneWeight.read(reader) self.position.read(reader) self.normal.read(reader) self.texCoordX = reader.read_float() self.texCoordY = reader.read_float() return self
def read(self, reader: ByteIO, MDL: SourceMdlFileData): entry = reader.tell() self.entry = entry self.baseHeaderOffset = reader.read_int32() self.nameOffset = reader.read_int32() self.theName = reader.read_from_offset(entry + self.nameOffset, reader.read_ascii_string) self.fps = reader.read_float() self.flags = self.STUDIO(reader.read_uint32()) self.frameCount = reader.read_uint32() self.movementCount = reader.read_uint32() self.movementOffset = reader.read_uint32() self.unused1 = [reader.read_uint32() for _ in range(6)] self.animBlock = reader.read_uint32() self.animOffset = reader.read_uint32() self.ikRuleCount = reader.read_uint32() self.ikRuleOffset = reader.read_uint32() self.animblockIkRuleOffset = reader.read_uint32() self.localHierarchyCount = reader.read_uint32() self.localHierarchyOffset = reader.read_uint32() self.sectionOffset = reader.read_uint32() self.sectionFrameCount = reader.read_uint32() self.spanFrameCount = reader.read_uint16() self.spanCount = reader.read_uint16() self.spanOffset = reader.read_uint32() self.spanStallTime = reader.read_float() self.fileOffsetStart2 = entry + self.spanOffset self.fileOffsetEnd2 = entry + self.spanOffset-1 if self.spanFrameCount!=0 or self.spanCount!=0 or self.spanOffset!=0 or self.spanStallTime!=0: for bone_index in range(len(MDL.bones)): bone = MDL.bones[bone_index] #type: SourceMdlBone if bone.flags & SourceMdlBone.BONE_HAS_SAVEFRAME_POS: self.fileOffsetEnd2 += self.spanCount * 6 if bone.flags & SourceMdlBone.BONE_HAS_SAVEFRAME_ROT: self.fileOffsetEnd2 += self.spanCount * 8 return self
def read(self, reader: ByteIO): entry = reader.tell() self.boneIndex = reader.read_uint32() self.boneNewParentIndex = reader.read_uint32() self.startInfluence = reader.read_float() self.peakInfluence = reader.read_float() self.tailInfluence = reader.read_float() self.endInfluence = reader.read_float() self.startFrameIndex = reader.read_uint32() self.localAnimOffset = reader.read_uint32() if self.localAnimOffset != 0: with reader.save_current_pos(): reader.seek(entry + self.localAnimOffset) self.theLocalAnims.read(reader) self.unused = [reader.read_uint32() for _ in range(4)] return self
def read(self, reader: ByteIO, mdl: SourceMdlFileDataV10): self.boneOffset = reader.tell() self.name = reader.read_ascii_string(32) self.parentBoneIndex = reader.read_int32() self.flags = reader.read_int32() self.boneControllerIndex = [reader.read_int32() for _ in range(6)] self.position.read(reader) self.rotation.read(reader) self.scale = [reader.read_float() for _ in range(6)] mdl.bones.append(self)
def read(self,reader:ByteIO): entry = reader.tell() self.cycle = reader.read_float() self.eventIndex = reader.read_uint32() self.eventType = reader.read_uint32() self.options = [reader.read_uint8() for _ in range(64)] self.nameOffset = reader.read_uint32() if self.nameOffset: self.theName = reader.read_from_offset(self.nameOffset+entry,reader.read_ascii_string) else: self.theName = str(self.eventIndex) return self
def read(self, reader: ByteIO, model: SourceVtxModel): entry = reader.tell() self.lod = len(model.vtx_model_lods) self.meshCount = reader.read_uint32() self.meshOffset = reader.read_uint32() self.switchPoint = reader.read_float() with reader.save_current_pos(): if self.meshOffset > 0: reader.seek(entry + self.meshOffset) for _ in range(self.meshCount): self.vtx_meshes.append(SourceVtxMesh().read(reader)) return self
def read(self, reader: ByteIO): for x in range(self.mat_cols): for y in range(self.mat_rows): self.mat[x][y] = reader.read_float()
def read(self, reader: ByteIO): self.x = reader.read_float() self.y = reader.read_float() self.z = reader.read_float() self.w = reader.read_float() return self
def read(self,reader:ByteIO,mdl:SourceMdlFileData): entry = reader.tell() self.baseHeaderOffset = reader.read_int32() self.nameOffset = reader.read_uint32() self.theName = reader.read_from_offset(entry+self.nameOffset,reader.read_ascii_string) self.activityNameOffset = reader.read_uint32() self.theActivityName = reader.read_from_offset(entry+self.activityNameOffset,reader.read_ascii_string) self.flags = reader.read_uint32() self.activity = reader.read_int32() self.activityWeight = reader.read_uint32() self.eventCount = reader.read_uint32() self.eventOffset = reader.read_uint32() self.bbMin.read(reader) self.bbMax.read(reader) self.blendCount = reader.read_uint32() self.animIndexOffset = reader.read_uint32() self.movementIndex = reader.read_uint32() self.groupSize = [reader.read_uint32() for _ in range(2)] self.paramIndex = [reader.read_int32() for _ in range(2)] self.paramStart = [reader.read_uint32() for _ in range(2)] self.paramEnd = [reader.read_uint32() for _ in range(2)] self.paramParent = reader.read_uint32() self.fadeInTime = reader.read_float() self.fadeOutTime = reader.read_float() self.localEntryNodeIndex = reader.read_uint32() self.localExitNodeIndex = reader.read_uint32() self.nodeFlags = reader.read_uint32() self.entryPhase = reader.read_float() self.exitPhase = reader.read_float() self.lastFrame = reader.read_float() self.nextSeq = reader.read_uint32() self.pose = reader.read_uint32() self.ikRuleCount = reader.read_uint32() self.autoLayerCount = reader.read_uint32() self.autoLayerOffset = reader.read_uint32() self.weightOffset = reader.read_uint32() self.poseKeyOffset = reader.read_uint32() self.ikLockCount = reader.read_uint32() self.ikLockOffset = reader.read_uint32() self.keyValueOffset = reader.read_uint32() self.keyValueSize = reader.read_uint32() self.cyclePoseIndex = reader.read_uint32() if mdl.version == 49: self.activityModifierOffset = reader.read_int32() self.activityModifierCount = reader.read_uint32() self.unused = [reader.read_uint32() for _ in range(5)] else: self.unused = [reader.read_uint32() for _ in range(7)] if self.groupSize[0] > 1 and self.groupSize[1] > 1 and self.poseKeyOffset !=0: with reader.save_current_pos(): reader.seek(entry+self.poseKeyOffset) for _ in range(self.groupSize[0]+self.groupSize[1]): self.thePoseKeys.append(reader.read_float()) if self.eventCount > 0 and self.eventOffset!=0: with reader.save_current_pos(): reader.seek(entry+self.eventOffset) for _ in range(self.eventCount): self.theEvents.append(SourceMdlEvent().read(reader)) return self
def read(self, reader: ByteIO): self.weight = [reader.read_float() for _ in range(3)] self.bone = [reader.read_uint8() for _ in range(3)] self.boneCount = reader.read_uint8() return self
def read(self, reader: ByteIO): entry = reader.tell() self.name_offset = reader.read_int32() self.name = reader.read_from_offset(entry + self.name_offset, reader.read_ascii_string) self.value = reader.read_float()
def read_from_buffer(self, reader: ByteIO): if self.format == DXGI_FORMAT.R32G32B32_FLOAT: return [ reader.read_float() for _ in range(self.format.name.count('32')) ] elif self.format == DXGI_FORMAT.R32G32B32_UINT: return [ reader.read_uint32() for _ in range(self.format.name.count('32')) ] elif self.format == DXGI_FORMAT.R32G32B32_SINT: return [ reader.read_int32() for _ in range(self.format.name.count('32')) ] elif self.format == DXGI_FORMAT.R32G32B32A32_FLOAT: return [ reader.read_float() for _ in range(self.format.name.count('32')) ] elif self.format == DXGI_FORMAT.R32G32B32A32_UINT: return [ reader.read_uint32() for _ in range(self.format.name.count('32')) ] elif self.format == DXGI_FORMAT.R32G32B32A32_SINT: return [ reader.read_int32() for _ in range(self.format.name.count('32')) ] elif self.format == DXGI_FORMAT.R16G16_FLOAT: return [ short_to_float(reader.read_int16()) for _ in range(self.format.name.count('16')) ] elif self.format == DXGI_FORMAT.R32G32_FLOAT: return [ short_to_float(reader.read_float()) for _ in range(self.format.name.count('32')) ] elif self.format == DXGI_FORMAT.R16G16_SINT: return [ reader.read_int16() for _ in range(self.format.name.count('16')) ] elif self.format == DXGI_FORMAT.R16G16_UINT: return [ reader.read_uint16() for _ in range(self.format.name.count('16')) ] elif self.format == DXGI_FORMAT.R8G8B8A8_SNORM: return [ reader.read_int8() for _ in range(self.format.name.count('8')) ] elif self.format == DXGI_FORMAT.R8G8B8A8_UNORM: return [ reader.read_uint8() for _ in range(self.format.name.count('8')) ] elif self.format == DXGI_FORMAT.R8G8B8A8_UINT: return [ reader.read_uint8() for _ in range(self.format.name.count('8')) ] else: raise NotImplementedError('Unknown buffer format {}'.format( self.format.name))