forked from bartvdbraak/blender
Fixed import scripts: OBJ, 3DS. 2 bugs still perist though: imported meshes appear upside-down (foreach_set?) and materials don't import.
This commit is contained in:
parent
0c3288eb35
commit
5443844cf6
@ -420,7 +420,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
|
|||||||
# bmesh_verts.extend( [myContextMesh_vertls[i] for i in vertsToUse] )
|
# bmesh_verts.extend( [myContextMesh_vertls[i] for i in vertsToUse] )
|
||||||
|
|
||||||
# +1 because of DUMMYVERT
|
# +1 because of DUMMYVERT
|
||||||
bmesh.faces.foreach_set("verts", unpack_face_list([[myVertMapping[vindex] for vindex in myContextMesh_facels[fIdx]] for fIdx in faces]))
|
bmesh.faces.foreach_set("verts_raw", unpack_face_list([[myVertMapping[vindex] for vindex in myContextMesh_facels[fIdx]] for fIdx in faces]))
|
||||||
# face_mapping = bmesh.faces.extend( [ [ bmesh_verts[ myVertMapping[vindex]+1] for vindex in myContextMesh_facels[fIdx]] for fIdx in faces ], indexList=True )
|
# face_mapping = bmesh.faces.extend( [ [ bmesh_verts[ myVertMapping[vindex]+1] for vindex in myContextMesh_facels[fIdx]] for fIdx in faces ], indexList=True )
|
||||||
|
|
||||||
if bmesh.faces and (contextMeshUV or img):
|
if bmesh.faces and (contextMeshUV or img):
|
||||||
@ -1140,14 +1140,15 @@ class IMPORT_OT_3ds(bpy.types.Operator):
|
|||||||
# to the class instance from the operator settings before calling.
|
# to the class instance from the operator settings before calling.
|
||||||
|
|
||||||
__props__ = [
|
__props__ = [
|
||||||
bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for importing the 3DS file", maxlen=1024, default= ""),
|
bpy.props.StringProperty(attr="path", name="File Path", description="File path used for importing the 3DS file", maxlen= 1024, default= ""),
|
||||||
|
|
||||||
# bpy.props.FloatProperty(attr="size_constraint", name="Size Constraint", description="Scale the model by 10 until it reacehs the size constraint. Zero Disables.", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=10.0),
|
# bpy.props.FloatProperty(attr="size_constraint", name="Size Constraint", description="Scale the model by 10 until it reacehs the size constraint. Zero Disables.", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=10.0),
|
||||||
# bpy.props.BoolProperty(attr="search_images", name="Image Search", description="Search subdirectories for any assosiated images (Warning, may be slow)", default=True),
|
# bpy.props.BoolProperty(attr="search_images", name="Image Search", description="Search subdirectories for any assosiated images (Warning, may be slow)", default=True),
|
||||||
# bpy.props.BoolProperty(attr="apply_matrix", name="Transform Fix", description="Workaround for object transformations importing incorrectly", default=False),
|
# bpy.props.BoolProperty(attr="apply_matrix", name="Transform Fix", description="Workaround for object transformations importing incorrectly", default=False),
|
||||||
]
|
]
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
load_3ds(self.filename, context, 0.0, False, False)
|
load_3ds(self.path, context, 0.0, False, False)
|
||||||
return ('FINISHED',)
|
return ('FINISHED',)
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
|
@ -87,11 +87,19 @@ def unpack_face_list(list_of_tuples):
|
|||||||
l = []
|
l = []
|
||||||
for t in list_of_tuples:
|
for t in list_of_tuples:
|
||||||
face = [i for i in t]
|
face = [i for i in t]
|
||||||
|
|
||||||
if len(face) != 3 and len(face) != 4:
|
if len(face) != 3 and len(face) != 4:
|
||||||
raise RuntimeError("{0} vertices in face.".format(len(face)))
|
raise RuntimeError("{0} vertices in face.".format(len(face)))
|
||||||
|
|
||||||
|
# rotate indices if the 4th is 0
|
||||||
|
if len(face) == 4 and face[3] == 0:
|
||||||
|
face = [face[3], face[0], face[1], face[2]]
|
||||||
|
|
||||||
if len(face) == 3:
|
if len(face) == 3:
|
||||||
face.append(0)
|
face.append(0)
|
||||||
|
|
||||||
l.extend(face)
|
l.extend(face)
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
|
def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
|
||||||
@ -709,9 +717,9 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
|
|||||||
# me.verts.extend(verts_loc)
|
# me.verts.extend(verts_loc)
|
||||||
|
|
||||||
# faces is a list of (vert_indices, texco_indices, ...) tuples
|
# faces is a list of (vert_indices, texco_indices, ...) tuples
|
||||||
# XXX faces should not contain edges
|
# XXX faces should contain either 3 or 4 verts
|
||||||
# XXX no check for valid face indices
|
# XXX no check for valid face indices
|
||||||
me.faces.foreach_set("verts", unpack_face_list([f[0] for f in faces]))
|
me.faces.foreach_set("verts_raw", unpack_face_list([f[0] for f in faces]))
|
||||||
# face_mapping= me.faces.extend([f[0] for f in faces], indexList=True)
|
# face_mapping= me.faces.extend([f[0] for f in faces], indexList=True)
|
||||||
|
|
||||||
if verts_tex and me.faces:
|
if verts_tex and me.faces:
|
||||||
@ -1568,7 +1576,7 @@ class IMPORT_OT_obj(bpy.types.Operator):
|
|||||||
# to the class instance from the operator settings before calling.
|
# to the class instance from the operator settings before calling.
|
||||||
|
|
||||||
__props__ = [
|
__props__ = [
|
||||||
bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the PLY file", maxlen= 1024, default= ""),
|
bpy.props.StringProperty(attr="path", name="File Path", description="File path used for importing the OBJ file", maxlen= 1024, default= ""),
|
||||||
|
|
||||||
bpy.props.BoolProperty(attr="CREATE_SMOOTH_GROUPS", name="Smooth Groups", description="Surround smooth groups by sharp edges", default= True),
|
bpy.props.BoolProperty(attr="CREATE_SMOOTH_GROUPS", name="Smooth Groups", description="Surround smooth groups by sharp edges", default= True),
|
||||||
bpy.props.BoolProperty(attr="CREATE_FGONS", name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default= True),
|
bpy.props.BoolProperty(attr="CREATE_FGONS", name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default= True),
|
||||||
@ -1592,10 +1600,7 @@ class IMPORT_OT_obj(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# print("Selected: " + context.active_object.name)
|
# print("Selected: " + context.active_object.name)
|
||||||
|
|
||||||
if not self.filename:
|
load_obj(self.path,
|
||||||
raise Exception("filename not set")
|
|
||||||
|
|
||||||
load_obj(self.filename,
|
|
||||||
context,
|
context,
|
||||||
self.CLAMP_SIZE,
|
self.CLAMP_SIZE,
|
||||||
self.CREATE_FGONS,
|
self.CREATE_FGONS,
|
||||||
|
@ -982,9 +982,14 @@ static void rna_def_mface(BlenderRNA *brna)
|
|||||||
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
||||||
RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length");
|
RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length");
|
||||||
RNA_def_property_int_funcs(prop, "rna_MeshFace_verts_get", "rna_MeshFace_verts_set", NULL);
|
RNA_def_property_int_funcs(prop, "rna_MeshFace_verts_get", "rna_MeshFace_verts_set", NULL);
|
||||||
|
|
||||||
RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
|
RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
|
||||||
|
|
||||||
|
/* leaving this fixed size array for foreach_set used in import scripts */
|
||||||
|
prop= RNA_def_property(srna, "verts_raw", PROP_INT, PROP_UNSIGNED);
|
||||||
|
RNA_def_property_int_sdna(prop, NULL, "v1");
|
||||||
|
RNA_def_property_array(prop, 4);
|
||||||
|
RNA_def_property_ui_text(prop, "Vertices", "Fixed size vertex indices array");
|
||||||
|
|
||||||
prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
|
prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
|
||||||
RNA_def_property_int_sdna(prop, NULL, "mat_nr");
|
RNA_def_property_int_sdna(prop, NULL, "mat_nr");
|
||||||
RNA_def_property_ui_text(prop, "Material Index", "");
|
RNA_def_property_ui_text(prop, "Material Index", "");
|
||||||
|
Loading…
Reference in New Issue
Block a user