当前位置: 首页>>代码示例>>Python>>正文


Python StreamWriter.u16方法代码示例

本文整理汇总了Python中s3py.io.StreamWriter.u16方法的典型用法代码示例。如果您正苦于以下问题:Python StreamWriter.u16方法的具体用法?Python StreamWriter.u16怎么用?Python StreamWriter.u16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在s3py.io.StreamWriter的用法示例。


在下文中一共展示了StreamWriter.u16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

# 需要导入模块: from s3py.io import StreamWriter [as 别名]
# 或者: from s3py.io.StreamWriter import u16 [as 别名]
 def write(self, stream, resources):
     s = StreamWriter(stream)
     s.u32(resources.get_block_index(self.model, RCOL.Reference.PUBLIC))
     s.u32(self.flags)
     s.u16(self.id)
     s.u16(int(self.is_sunshadow))
     s.f32(self.min_z)
     s.f32(self.max_z)
开发者ID:markmanching,项目名称:s3py,代码行数:10,代码来源:geometry.py

示例2: write

# 需要导入模块: from s3py.io import StreamWriter [as 别名]
# 或者: from s3py.io.StreamWriter import u16 [as 别名]
 def write(self, stream, resource=None):
     s = StreamWriter(stream)
     self.frame_data_ptr = StreamPtr.begin_write(s)
     s.u32(self.track_key)
     s.f32(self.offset)
     s.f32(self.scale)
     s.u16(self.frame_count)
     self.flags.write(stream)
     s.u8(self.type)
     return self
开发者ID:markmanching,项目名称:s3py,代码行数:12,代码来源:__init__.py

示例3: write_rcol

# 需要导入模块: from s3py.io import StreamWriter [as 别名]
# 或者: from s3py.io.StreamWriter import u16 [as 别名]
 def write_rcol(self, stream, rcol):
     self.write_tag(stream)
     s = StreamWriter(stream)
     s.u32(self.version)
     cLights = len(self.lights)
     cOccluders = len(self.occluders)
     s.u32(4 + (cLights * 128) + (cOccluders * 14))
     s.u8(cLights)
     s.u8(cOccluders)
     s.u16(cOccluders * 14)
     for light in self.lights:
         start = stream.tell()
         light.write_rcol(stream)
         end = stream.tell()
         size = end - start
         blank = 128 - size
         dwords = int(blank / 4)
         for i in range(int(dwords)): s.u32(0)
     for occluder in self.occluders:
         occluder.write_rcol(stream)
开发者ID:markmanching,项目名称:s3py,代码行数:22,代码来源:lights.py

示例4: save

# 需要导入模块: from s3py.io import StreamWriter [as 别名]
# 或者: from s3py.io.StreamWriter import u16 [as 别名]
    def save(self,out_file=None):
        """
        """

        #temporary file to flush data to
        tmp_filename = tempfile.mktemp()
        tmp_stream = io.open(tmp_filename,'wb')
        s = StreamWriter(tmp_stream)

        self.header.index_entry_count = len(self.entries)

        #current package stream
        pkg_stream = None
        if self.stream:
            pkg_stream = self.stream
        elif exists(self.filename):
            pkg_stream = io.open(self.filename,'rb')


        #skip over header
        #this will be written at the end
        tmp_stream.seek(self.Header.SIZE, SEEK_SET)

        # Write data, update header and index
        self.index_flags = 0
        self.static_key = ResourceKey()
        if any(self.entries):
            self.index_flags = self.INDEX_FLAG.TYPE | self.INDEX_FLAG.GROUP
            static_key = None
            for index in self.entries:
                if index.delete_pending:
                    self.entries.remove(index)
                    continue
                data = None
                if index.key in self.__loaded_resources:
                    # index.compressed = False
                    wrapper = self.__loaded_resources[index.key]
                    with BytesIO() as wrapper_stream:
                        wrapper.write(wrapper_stream)
                        wrapper_stream.seek(0,SEEK_SET)
                        data = wrapper_stream.read(-1)
                    #memsize is uncompressed
                    index.mem_size = len(data)
                elif isinstance(pkg_stream, io.FileIO):
                    pkg_stream.seek(index.offset)
                    data = pkg_stream.read(index.mem_size)
                else:
                    continue
                if index.compressed:
                    data = Package.Compression.compress(data)
                #filesize could change if the index was compressed
                index.file_size = len(data)

                if static_key is None: static_key = index.key.clone()
                if not index.key.t == static_key.t:
                   static_key.t = 0
                   self.index_flags = Flag.unset(self.index_flags, self.INDEX_FLAG.TYPE)
                if not index.key.g == static_key.g:
                   static_key.g = 0
                   self.index_flags = Flag.unset(self.index_flags, self.INDEX_FLAG.GROUP)
                #record offset of this entry
                index.offset = tmp_stream.tell()
                #write data
                tmp_stream.write(bytearray(data))

            if self.index_flags: self.static_key = static_key

        # record offset for index table
        self.header.index_offset = tmp_stream.tell()
        # write index table
        s.u32(0)
        if Flag.is_set(self.index_flags, self.INDEX_FLAG.TYPE):
            s.u32(self.static_key.t)
        if Flag.is_set(self.index_flags, self.INDEX_FLAG.GROUP):
            s.u32(self.static_key.g)
        for index in self.entries:
            if not Flag.is_set(self.index_flags, self.INDEX_FLAG.TYPE):
                s.u32(index.key.t)
            if not Flag.is_set(self.index_flags, self.INDEX_FLAG.GROUP):
                s.u32(index.key.g)
            s.u32(index.key.t)
            s.u32(index.key.g)
            instance_hi = index.key.i >> 32
            instance_lo = index.key.i & 0xFFFFFFFF
            s.u32(instance_hi)
            s.u32(instance_lo)
            s.u32(index.offset)
            s.u32(index.file_size | 0x80000000)
            s.u32(index.mem_size)
            s.u16(0 if not index.compressed else 0xFFFF)
            s.u16(index.unknown)
        end = tmp_stream.tell()
        self.header.index_size = end - self.header.index_offset

        # Go back and write header
        tmp_stream.seek(0, SEEK_SET)
        self.header.write(tmp_stream)
        if pkg_stream:
            pkg_stream.close()
        if not out_file: out_file = self.filename
#.........这里部分代码省略.........
开发者ID:markmanching,项目名称:s3py,代码行数:103,代码来源:package.py


注:本文中的s3py.io.StreamWriter.u16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。