vtx1.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:j3dview 作者: blank63 项目源码 文件源码
def unpack_array(stream,attribute_format,size):
    if attribute_format.attribute == gx.VA_POS:
        component_type = gx.ComponentType(attribute_format.component_type)
        component_count = gx.PositionComponentCount(attribute_format.component_count)
        array_type = Array
    elif attribute_format.attribute == gx.VA_NRM:
        component_type = gx.ComponentType(attribute_format.component_type)
        component_count = gx.NormalComponentCount(attribute_format.component_count)
        array_type = Array
    elif attribute_format.attribute in gx.VA_CLR:
        component_type = gx.ColorComponentType(attribute_format.component_type)
        component_count = gx.ColorComponentCount(attribute_format.component_count)
        array_type = ColorArray
    elif attribute_format.attribute in gx.VA_TEX:
        component_type = gx.ComponentType(attribute_format.component_type)
        component_count = gx.TexCoordComponentCount(attribute_format.component_count)
        array_type = Array
    else:
        raise FormatError('invalid vertex attribute')

    element_type = array_type.create_element_type(component_type,component_count)
    element_count = size//element_type.itemsize
    array = numpy.fromfile(stream,element_type,element_count).view(array_type)
    array.attribute = attribute_format.attribute
    array.component_type = component_type
    array.component_count = component_count
    array.scale_exponent = attribute_format.scale_exponent
    return array
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号