本文整理汇总了Python中s3py.io.StreamReader.chars方法的典型用法代码示例。如果您正苦于以下问题:Python StreamReader.chars方法的具体用法?Python StreamReader.chars怎么用?Python StreamReader.chars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类s3py.io.StreamReader
的用法示例。
在下文中一共展示了StreamReader.chars方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
# 需要导入模块: from s3py.io import StreamReader [as 别名]
# 或者: from s3py.io.StreamReader import chars [as 别名]
def read(self, stream, resource=None):
"""
"""
s = StreamReader(stream)
tag = s.chars(4)
assert tag == self.MAGIC
self.major_version = s.u32()
self.minor_version = s.u32()
self.unknown1 = s.u32()
self.unknown2 = s.u32()
self.unknown3 = s.u32()
self.date_created = s.u32()
self.date_modified = s.u32()
self.index_major_version = s.u32()
self.index_entry_count = s.u32()
self.index_entry_offset = s.u32()
self.index_size = s.u32()
self.hole_count = s.u32()
self.hole_offset = s.u32()
self.hole_size = s.u32()
self.index_minor_version = s.u32()
self.index_offset = s.u32()
self.unknown4 = s.u32()
self.reserved = [0] * 24
for i in range(24): self.reserved[i] = s.u32()
示例2: read
# 需要导入模块: from s3py.io import StreamReader [as 别名]
# 或者: from s3py.io.StreamReader import chars [as 别名]
def read(self, stream, resource=None):
s = StreamReader(stream)
assert s.chars(4) == self.TAG
self.version = s.u32()
cBlends = s.i32()
cLods = s.i32()
cPointers = s.i32()
cVectors = s.i32()
assert s.i32() == 0x00000008
assert s.i32() == 0x0000000C
blend_ptr = StreamPtr.begin_read(s)
vertex_ptr = StreamPtr.begin_read(s)
vector_ptr = StreamPtr.begin_read(s)
blend_ptr.end()
lod_ptrs = []
for blend_index in range(cBlends):
blend = Blend()
blend.age_gender_flags = s.u32()
blend.blend_region = s.u32()
self.blends.append(blend)
blend.lods = [Blend.LOD() for lod_index in range(cLods)]
lod_ptrs.append([self.LodPtr(s.u32(), s.u32(), s.u32()) for lod_index in range(cLods)])
vertex_ptr.end()
pointers = [self.VertexPtr(s.i16()) for pointer_index in range(cPointers)]
vector_ptr.end()
vectors = [[self.unpack(s.i16()) for i in range(3)] for vector_index in range(cVectors)]
for blend_index, blend in enumerate(self.blends):
start_vector_ptr = 0
current_vector_offset = 0
blend_ptr = lod_ptrs[blend_index]
for lod_index, lod in enumerate(blend.lods):
lod_blend_index = blend_index + lod_index
if lod_blend_index >= len(blend_ptr):
print('Skipping missing LOD %s - %s'%(lod_blend_index,len(blend_ptr)))
continue
lod_ptr = blend_ptr[blend_index + lod_index]
current_vertex_id = lod_ptr.start_vertex_id
for vector_ptr_index in range(lod_ptr.vertex_count):
vertex = Blend.Vertex()
vector_ptr = pointers[vector_ptr_index + start_vector_ptr]
current_vector_offset += vector_ptr.offset
vertex.id = current_vertex_id
vertex_vector_offset = 0
if vector_ptr.has_position:
vertex.position = vectors[current_vector_offset + vertex_vector_offset]
vertex_vector_offset += 1
if vector_ptr.has_normal:
vertex.normal = vectors[current_vector_offset + vertex_vector_offset]
vertex_vector_offset += 1
current_vertex_id += 1
lod.vertices.append(vertex)
start_vector_ptr += lod_ptr.vertex_count
current_vector_offset += lod_ptr.vector_count
示例3: read
# 需要导入模块: from s3py.io import StreamReader [as 别名]
# 或者: from s3py.io.StreamReader import chars [as 别名]
def read(self, stream, resources=None):
s = StreamReader(stream)
tag = s.chars(8)
if not tag == '_pilC3S_': raise Exception("Not a valid _S3Clip_")
self.version = s.u32()
self.unknown1 = s.u32()
self.frame_duration = s.f32()
self.max_frame_count = s.u16()
self.unknown2 = s.u16()
cCurves = s.u32()
cFloats = s.u32()
curveOffset = StreamPtr.begin_read(s)
frameOffset = StreamPtr.begin_read(s)
nameOffset = StreamPtr.begin_read(s)
srcNameOffset = StreamPtr.begin_read(s)
curveOffset.end()
curves = []
for curveIndex in range(cCurves):
cdi = CurveDataInfo()
cdi.read(stream)
curves.append(cdi)
nameOffset.end()
self.name = s.zs()
srcNameOffset.end()
self.source_file_name = s.zs()
frameOffset.end()
indexedFloats = []
for floatIndex in range(cFloats):
indexedFloats.append(s.f32())
trackMap = {}
self.tracks = []
for curveIndex,cdi in enumerate(curves):
cdi.frame_data_ptr.end()
if cdi.track_key not in trackMap.keys():
t = Track(cdi.track_key)
trackMap[cdi.track_key] = t
self.tracks.append(t)
track = trackMap[cdi.track_key]
frames = []
for frameIndex in range(cdi.frame_count):
f = Frame()
f.read(stream, cdi, indexedFloats)
frames.append(f)
curve = Curve(cdi.type)
curve.flags = cdi.flags
curve.frames = frames
track[curve.type] = curve
return self
示例4: read
# 需要导入模块: from s3py.io import StreamReader [as 别名]
# 或者: from s3py.io.StreamReader import chars [as 别名]
def read(self, stream, keys):
s = StreamReader(stream)
tag = s.chars(4)
if not tag == self.TAG_TEXTURES or tag == self.TAG_NO_TEXTURES:
raise IOError(
"Invalid data, expected %s or %s, but got %s" % (self.TAG_TEXTURES, self.TAG_NO_TEXTURES, tag))
zero = s.u32()
assert zero == 0
param_len = s.u32()
cParams = s.i32()
items = []
for i in range(cParams):
item = self.Item()
item.read_pointer(stream)
items.append(item)
start = stream.tell()
for item in items:
self.__parameters[item.name] = item.read_data(stream, keys)
end = stream.tell()
assert (end - start) == param_len
示例5: read
# 需要导入模块: from s3py.io import StreamReader [as 别名]
# 或者: from s3py.io.StreamReader import chars [as 别名]
def read(self, stream, resources=None):
s = StreamReader(stream)
length = s.u32()
complateStr = s.chars(length, 16)
self.unknown = s.u32()
self.read_xml(complateStr, resources)
示例6: read
# 需要导入模块: from s3py.io import StreamReader [as 别名]
# 或者: from s3py.io.StreamReader import chars [as 别名]
def read(self, stream, resources=None):
s = StreamReader(stream)
assert s.chars(4) == DGN