Ejemplo n.º 1
0
def details_data_parse(details_data):
    position = 0
    while position < len(details_data):
        position, block_id, block_size = xray_utils.read_block(position, details_data)
        
        if block_id == 0x0:
            slots_coords = parse_header(details_data[position : position + block_size], coord_y)
            position += block_size
            mesh_data = {}
            mesh_data['vertices'] = slots_coords
            mesh_data['triangles'] = ()
            mesh_data['uvs'] = None
            mesh_data['images'] = None
            mesh_data['material_indices'] = None
            mesh_data['materials'] = None
            xray_import.crete_mesh(mesh_data)
        elif block_id == 0x1:
            parse_meshes(details_data[position : position + block_size])
            position += block_size
        elif block_id == 0x2:
            coord_y = parse_slots(details_data[position : position + block_size])
            position += block_size
        else:
            print(' ! UNKNOW BLOCK ({0}) {1} BYTES'.format(hex(block_id), block_size))
            position += block_size
Ejemplo n.º 2
0
def ogf_data_parse(data):
    data_size = len(data)
    position = 0
    parse_children = False
    while position < data_size:
        position, block_id, block_size = xray_utils.read_block(position, data)
        if block_id == HEADER[0]:
            parse_header(data[position:position + block_size])
        elif block_id == TEXTURE[0]:
            texture_name = parse_texture(data[position:position + block_size])
        elif block_id == VERTICES[0]:
            vertices, uvs = parse_vertices(data[position:position +
                                                block_size])
        elif block_id == INDICES[0]:
            triangles = parse_indices(data[position:position + block_size])
        elif block_id == CHILDREN[0]:
            parse_childrens(data[position:position + block_size])
            parse_children = True
        else:
            pass
            # print('! UNKNOWN BLOCK: {0}'.format(hex(block_id)))
        position += block_size

    if not parse_children:
        mesh_data = {}
        mesh_data['vertices'] = vertices
        mesh_data['triangles'] = triangles
        mesh_data['uvs'] = uvs
        mesh_data['materials'] = None
        mesh_data['images'] = texture_name
        mesh_data['material_indices'] = None
        xray_import.crete_mesh(mesh_data)
Ejemplo n.º 3
0
def parse_children(data):
    position = 0
    while position < len(data):
        position, block_id, block_size = xray_utils.read_block(position, data)
        if block_id == HEADER[0]:
            parse_header(data[position:position + block_size])
        elif block_id == TEXTURE[0]:
            texture_name = parse_texture(data[position:position + block_size])
        elif block_id == VERTICES[0]:
            vertices, uvs = parse_vertices(data[position:position +
                                                block_size])
        elif block_id == INDICES[0]:
            triangles = parse_indices(data[position:position + block_size])
        elif block_id == SWIDATA[0]:
            offset = parse_swidata(data[position:position + block_size])
        else:
            pass
            # print('! UNKNOWN SUBBLOCK: 0x9-{0}'.format(hex(block_id)))
        position += block_size

    if offset:
        triangles = triangles[offset:]

    mesh_data = {}
    mesh_data['vertices'] = vertices
    mesh_data['triangles'] = triangles
    mesh_data['uvs'] = uvs
    mesh_data['materials'] = None
    mesh_data['images'] = texture_name
    mesh_data['material_indices'] = None
    return mesh_data
Ejemplo n.º 4
0
def parse_childrens(data):
    position = 0

    while position < len(data):
        position, mesh_id, mesh_size = xray_utils.read_block(position, data)
        mesh_data = parse_children(data[position:position + mesh_size])
        position += mesh_size
        xray_import.crete_mesh(mesh_data)
Ejemplo n.º 5
0
def parse_main(d):
    p = 0
    while p < len(d):
        p, block_id, block_size = xray_utils.read_block(p, d)
        if block_id == 0x0:
            format_version, p = u('I', d, p)  # 2205-CoP = 0
        elif block_id == 0x1:
            mesh_data = parse_tris(d[p:p + block_size])
            p += block_size
            return mesh_data
Ejemplo n.º 6
0
from stalker_tools import xray_utils