Revision: 23555 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23555 Author: kazanbas Date: 2009-09-29 14:34:05 +0200 (Tue, 29 Sep 2009)
Log Message: ----------- Fixed import scripts: OBJ, 3DS. 2 bugs still perist though: imported meshes appear upside-down (foreach_set?) and materials don't import. Modified Paths: -------------- trunk/blender/release/scripts/io/import_3ds.py trunk/blender/release/scripts/io/import_obj.py trunk/blender/source/blender/makesrna/intern/rna_mesh.c Modified: trunk/blender/release/scripts/io/import_3ds.py =================================================================== --- trunk/blender/release/scripts/io/import_3ds.py 2009-09-29 12:16:58 UTC (rev 23554) +++ trunk/blender/release/scripts/io/import_3ds.py 2009-09-29 12:34:05 UTC (rev 23555) @@ -420,7 +420,7 @@ # bmesh_verts.extend( [myContextMesh_vertls[i] for i in vertsToUse] ) # +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 ) if bmesh.faces and (contextMeshUV or img): @@ -1140,14 +1140,15 @@ # to the class instance from the operator settings before calling. __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.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), ] def execute(self, context): - load_3ds(self.filename, context, 0.0, False, False) + load_3ds(self.path, context, 0.0, False, False) return ('FINISHED',) def invoke(self, context, event): Modified: trunk/blender/release/scripts/io/import_obj.py =================================================================== --- trunk/blender/release/scripts/io/import_obj.py 2009-09-29 12:16:58 UTC (rev 23554) +++ trunk/blender/release/scripts/io/import_obj.py 2009-09-29 12:34:05 UTC (rev 23555) @@ -87,11 +87,19 @@ l = [] for t in list_of_tuples: face = [i for i in t] + if len(face) != 3 and len(face) != 4: 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: face.append(0) + l.extend(face) + return l def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True): @@ -709,9 +717,9 @@ # me.verts.extend(verts_loc) # 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 - 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) if verts_tex and me.faces: @@ -1568,7 +1576,7 @@ # to the class instance from the operator settings before calling. __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_FGONS", name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default= True), @@ -1592,10 +1600,7 @@ def execute(self, context): # print("Selected: " + context.active_object.name) - if not self.filename: - raise Exception("filename not set") - - load_obj(self.filename, + load_obj(self.path, context, self.CLAMP_SIZE, self.CREATE_FGONS, Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh.c =================================================================== --- trunk/blender/source/blender/makesrna/intern/rna_mesh.c 2009-09-29 12:16:58 UTC (rev 23554) +++ trunk/blender/source/blender/makesrna/intern/rna_mesh.c 2009-09-29 12:34:05 UTC (rev 23555) @@ -982,9 +982,14 @@ RNA_def_property_flag(prop, PROP_DYNAMIC); 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_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); RNA_def_property_int_sdna(prop, NULL, "mat_nr"); RNA_def_property_ui_text(prop, "Material Index", ""); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs