Changeset View
Changeset View
Standalone View
Standalone View
io_scene_3ds/import_3ds.py
| Context not available. | |||||
| def process_next_object_chunk(file, previous_chunk): | def process_next_object_chunk(file, previous_chunk): | ||||
| new_chunk = chunk() | new_chunk = chunk() | ||||
| while (previous_chunk.bytes_read < previous_chunk.length): | while previous_chunk.bytes_read < previous_chunk.length: | ||||
| #read the next chunk | #read the next chunk | ||||
| read_chunk(file, new_chunk) | read_chunk(file, new_chunk) | ||||
| Context not available. | |||||
| u_scale, v_scale, u_offset, v_offset = 1.0, 1.0, 0.0, 0.0 | u_scale, v_scale, u_offset, v_offset = 1.0, 1.0, 0.0, 0.0 | ||||
| mirror = False | mirror = False | ||||
| extension = 'wrap' | extension = 'wrap' | ||||
| while (new_chunk.bytes_read < new_chunk.length): | while new_chunk.bytes_read < new_chunk.length: | ||||
| #print 'MAT_TEXTURE_MAP..while', new_chunk.bytes_read, new_chunk.length | #print 'MAT_TEXTURE_MAP..while', new_chunk.bytes_read, new_chunk.length | ||||
| read_chunk(file, temp_chunk) | read_chunk(file, temp_chunk) | ||||
| Context not available. | |||||
| dirname = os.path.dirname(file.name) | dirname = os.path.dirname(file.name) | ||||
| #loop through all the data for this chunk (previous chunk) and see what it is | #loop through all the data for this chunk (previous chunk) and see what it is | ||||
| while (previous_chunk.bytes_read < previous_chunk.length): | while previous_chunk.bytes_read < previous_chunk.length: | ||||
| #print '\t', previous_chunk.bytes_read, 'keep going' | #print '\t', previous_chunk.bytes_read, 'keep going' | ||||
| #read the next chunk | #read the next chunk | ||||
| #print 'reading a chunk' | #print 'reading a chunk' | ||||
| Context not available. | |||||
| temp_data = file.read(STRUCT_SIZE_UNSIGNED_SHORT * num_faces_using_mat) | temp_data = file.read(STRUCT_SIZE_UNSIGNED_SHORT * num_faces_using_mat) | ||||
| new_chunk.bytes_read += STRUCT_SIZE_UNSIGNED_SHORT * num_faces_using_mat | new_chunk.bytes_read += STRUCT_SIZE_UNSIGNED_SHORT * num_faces_using_mat | ||||
| temp_data = struct.unpack("<%dH" % (num_faces_using_mat), temp_data) | temp_data = struct.unpack("<%dH" % num_faces_using_mat, temp_data) | ||||
| contextMeshMaterials.append((material_name, temp_data)) | contextMeshMaterials.append((material_name, temp_data)) | ||||
| Context not available. | |||||
| data[9:] + [1], | data[9:] + [1], | ||||
| )).transposed() | )).transposed() | ||||
| elif (new_chunk.ID == MAT_MAP_FILEPATH): | elif new_chunk.ID == MAT_MAP_FILEPATH: | ||||
| texture_name, read_str_len = read_string(file) | texture_name, read_str_len = read_string(file) | ||||
| if contextMaterial.name not in TEXTURE_DICT: | if contextMaterial.name not in TEXTURE_DICT: | ||||
| TEXTURE_DICT[contextMaterial.name] = load_image(texture_name, dirname, place_holder=False, recursive=IMAGE_SEARCH) | TEXTURE_DICT[contextMaterial.name] = load_image(texture_name, dirname, place_holder=False, recursive=IMAGE_SEARCH) | ||||
| Context not available. | |||||
| # if BPyMessages.Error_NoFile(filepath): | # if BPyMessages.Error_NoFile(filepath): | ||||
| # return | # return | ||||
| print("importing 3DS: %r..." % (filepath), end="") | print("importing 3DS: %r..." % filepath, end="") | ||||
| if bpy.ops.object.select_all.poll(): | if bpy.ops.object.select_all.poll(): | ||||
| bpy.ops.object.select_all(action='DESELECT') | bpy.ops.object.select_all(action='DESELECT') | ||||
| Context not available. | |||||