io_scene_3ds: Update for Blender 3.x #104507

Closed
Sebastian Sille wants to merge 12 commits from nrgsille-patch-2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit 389eda1897 - Show all commits

View File

@ -168,7 +168,6 @@ scn = None
object_dictionary = {} object_dictionary = {}
object_matrix = {} object_matrix = {}
class Chunk: class Chunk:
__slots__ = ( __slots__ = (
"ID", "ID",
@ -189,7 +188,6 @@ class Chunk:
print('length: ', self.length) print('length: ', self.length)
print('bytes_read: ', self.bytes_read) print('bytes_read: ', self.bytes_read)
def read_chunk(file, chunk): def read_chunk(file, chunk):
temp_data = file.read(struct.calcsize(chunk.binary_format)) temp_data = file.read(struct.calcsize(chunk.binary_format))
data = struct.unpack(chunk.binary_format, temp_data) data = struct.unpack(chunk.binary_format, temp_data)
@ -201,7 +199,6 @@ def read_chunk(file, chunk):
# if debugging # if debugging
# chunk.dump() # chunk.dump()
def read_string(file): def read_string(file):
# read in the characters till we get a null character # read in the characters till we get a null character
s = [] s = []
@ -220,7 +217,6 @@ def read_string(file):
# IMPORT # IMPORT
###################################################### ######################################################
def process_next_object_chunk(file, previous_chunk): def process_next_object_chunk(file, previous_chunk):
new_chunk = Chunk() new_chunk = Chunk()
@ -228,14 +224,12 @@ def process_next_object_chunk(file, previous_chunk):
# read the next chunk # read the next chunk
read_chunk(file, new_chunk) read_chunk(file, new_chunk)
def skip_to_end(file, skip_chunk): def skip_to_end(file, skip_chunk):
buffer_size = skip_chunk.length - skip_chunk.bytes_read buffer_size = skip_chunk.length - skip_chunk.bytes_read
binary_format = "%ic" % buffer_size binary_format = "%ic" % buffer_size
file.read(struct.calcsize(binary_format)) file.read(struct.calcsize(binary_format))
skip_chunk.bytes_read += buffer_size skip_chunk.bytes_read += buffer_size
def add_texture_to_material(image, contextWrapper, pct, extend, alpha, scale, offset, angle, tintcolor, mapto): def add_texture_to_material(image, contextWrapper, pct, extend, alpha, scale, offset, angle, tintcolor, mapto):
shader = contextWrapper.node_principled_bsdf shader = contextWrapper.node_principled_bsdf
nodetree = contextWrapper.material.node_tree nodetree = contextWrapper.material.node_tree
@ -322,7 +316,6 @@ def add_texture_to_material(image, contextWrapper, pct, extend, alpha, scale, of
shader.location = (300, 300) shader.location = (300, 300)
contextWrapper._grid_to_location(1, 0, dst_node=contextWrapper.node_out, ref_node=shader) contextWrapper._grid_to_location(1, 0, dst_node=contextWrapper.node_out, ref_node=shader)
def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SEARCH, KEYFRAME): def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SEARCH, KEYFRAME):
from bpy_extras.image_utils import load_image from bpy_extras.image_utils import load_image
@ -1114,7 +1107,6 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SE
#pivot_matrix = mathutils.Matrix.Translation(pivot_matrix.to_3x3() @ -pivot) #pivot_matrix = mathutils.Matrix.Translation(pivot_matrix.to_3x3() @ -pivot)
ob.data.transform(pivot_matrix) ob.data.transform(pivot_matrix)
def load_3ds(filepath, def load_3ds(filepath,
context, context,
IMPORT_CONSTRAIN_BOUNDS=10.0, IMPORT_CONSTRAIN_BOUNDS=10.0,
@ -1123,7 +1115,6 @@ def load_3ds(filepath,
APPLY_MATRIX=True, APPLY_MATRIX=True,
global_matrix=None): global_matrix=None):
# global SCN # global SCN
# XXX # XXX
# if BPyMessages.Error_NoFile(filepath): # if BPyMessages.Error_NoFile(filepath):
# return # return
@ -1248,7 +1239,6 @@ def load_3ds(filepath,
print(" done in %.4f sec." % (time.time() - time1)) print(" done in %.4f sec." % (time.time() - time1))
file.close() file.close()
def load(operator, def load(operator,
context, context,
filepath="", filepath="",