本文整理汇总了Python中cuwo.bytes.ByteReader.read_float方法的典型用法代码示例。如果您正苦于以下问题:Python ByteReader.read_float方法的具体用法?Python ByteReader.read_float怎么用?Python ByteReader.read_float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cuwo.bytes.ByteReader
的用法示例。
在下文中一共展示了ByteReader.read_float方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_qmo
# 需要导入模块: from cuwo.bytes import ByteReader [as 别名]
# 或者: from cuwo.bytes.ByteReader import read_float [as 别名]
def convert_qmo(path):
data = ByteReader(open(path, 'rb').read())
qmo_file = QubicleFile()
qmo_model = QubicleModel()
x_size, y_size, z_size = 256, 256, 256
qmo_model.x_size = x_size
qmo_model.y_size = y_size
qmo_model.z_size = z_size
qmo_model.x_offset = -x_size / 2
qmo_model.y_offset = 0
qmo_model.z_offset = -z_size / 2
min_z = None
max_z = None
for i in xrange(256*256):
something = data.read_float()
something2 = data.read_float()
something3 = data.read_float()
something4 = data.read_uint32()
something5 = data.read_uint32()
size = data.read_uint32()*4
chunk_data = data.read(size)
x = i % 256
y = i / 256
z = something4
if min_z is None or max_z is None:
min_z = z
max_z = z + len(chunk_data) / 4
else:
min_z = min(z, min_z)
max_z = max(max_z, len(chunk_data) / 4)
for i in xrange(len(chunk_data) / 4):
r = ord(chunk_data[i*4])
g = ord(chunk_data[i*4+1])
b = ord(chunk_data[i*4+2])
a = ord(chunk_data[i*4+3])
if a == 0:
z += 1
continue
qmo_model.blocks[switch_axes(x, y, z)] = (r, g, b)
z += 1
qmo_model.y_offset
qmo_file.models.append(qmo_model)
writer = ByteWriter()
qmo_file.write(writer)
name = os.path.splitext(os.path.basename(path))[0]
out_path = os.path.join('genqmo', name + '.qmo')
open(out_path, 'wb').write(writer.get())
print 'Converted', path