diff options
author | John Phan <darkneter@gmail.com> | 2012-04-14 20:29:49 +0400 |
---|---|---|
committer | John Phan <darkneter@gmail.com> | 2012-04-14 20:29:49 +0400 |
commit | 44f8827118f18f38f929c5eac86333a5b9c0b977 (patch) | |
tree | f144217d013146f11b0cbd6c9e18c60f72aaf2da | |
parent | c1984f79658b9d2497b70da49ea489a49dda3178 (diff) |
Some clean up in coding. Fixed merge meshes. Fixed error and fail message that will display.
-rw-r--r-- | io_export_unreal_psk_psa.py | 108 | ||||
-rw-r--r-- | io_import_scene_unreal_psk.py | 494 |
2 files changed, 550 insertions, 52 deletions
diff --git a/io_export_unreal_psk_psa.py b/io_export_unreal_psk_psa.py index dcc1847f..642038e3 100644 --- a/io_export_unreal_psk_psa.py +++ b/io_export_unreal_psk_psa.py @@ -114,7 +114,7 @@ MaterialName = [] # TODO: remove this 1am hack nbone = 0 exportmessage = "Export Finish" - +exportfile = True ######################################################################## # Generic Object->Integer mapping # the object must be usable as a dictionary key @@ -631,36 +631,33 @@ def meshmerge(selectedobjects): # http://en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python/Cookbook#Triangulate_NMesh #blender 2.63 format using the Operators/Commands to convert the mesh to tri mesh def triangulateNMesh(object): - print("Converting quad to tri mesh...") + print("Converting quad to tri mesh...",object.name) scene = bpy.context.scene bpy.ops.object.mode_set(mode='OBJECT') for i in scene.objects: i.select = False #deselect all objects object.select = True scene.objects.active = object #set the mesh object to current - bpy.ops.object.mode_set(mode='OBJECT') - me_da = object.data.copy() #copy data - me_ob = object.copy() #copy object - #note two copy two types else it will use the current data or mesh - me_ob.data = me_da - scene = bpy.context.scene - bpy.context.scene.objects.link(me_ob)#link the object to the scene #current object location - for i in scene.objects: i.select = False #deselect all objects - me_ob.select = True - scene.objects.active = me_ob #set the mesh object to current bpy.ops.object.mode_set(mode='EDIT') #Operators bpy.ops.mesh.select_all(action='SELECT')#select all the face/vertex/edge bpy.ops.mesh.quads_convert_to_tris() #Operators bpy.context.scene.update() bpy.ops.object.mode_set(mode='OBJECT') # set it in object print("Triangulate Mesh Done!") - return me_ob + return object #Texture not working still find a way to get it work # Actual object parsing functions def parse_meshes(blender_meshes, psk_file): - global exportmessage + global exportmessage, exportfile print("Number of Object Meshes:",len(blender_meshes)) for current_obj in blender_meshes: #number of mesh that should be one mesh here + if current_obj.parent != None: + print("Armature Found!") + else: + exportmessage = "Mesh is not parent to Armature!" + bpy.context.scene.objects.unlink(current_obj) + exportfile = False + return #material if len(current_obj.material_slots) > 0: counter = 0 @@ -681,8 +678,6 @@ def parse_meshes(blender_meshes, psk_file): counter += 1 print("PSK INDEX:",matdata.TextureIndex) - - points = ObjMap() wedges = ObjMap() discarded_face_count = 0 @@ -690,19 +685,13 @@ def parse_meshes(blender_meshes, psk_file): faceUV = None scene = bpy.context.scene #get current scene EXPORT_APPLY_MODIFIERS = True - currentmeshobject = current_obj; - - current_obj = triangulateNMesh(currentmeshobject) #convert tri incase - bpy.context.scene.objects.unlink(currentmeshobject) + current_obj = triangulateNMesh(current_obj) #convert tri incase me = current_obj.to_mesh(scene, EXPORT_APPLY_MODIFIERS, 'PREVIEW') #apply modified mesh and write mesh - - #print(dir(me)) - faceuv = len(me.uv_textures) > 0 #check if has uv texture if faceuv: uv_layer = me.tessface_uv_textures.active.data[:] else: - + print("No UV Texture is added and will be ignore!") has_UV = False for face in me.tessfaces: @@ -715,13 +704,13 @@ def parse_meshes(blender_meshes, psk_file): if len(face.vertices) != 3: #raise RuntimeError("Non-triangular face (%i)" % len(face.vertices)) exportmessage = "MESH IS NOT TRIANGLE (Alt + T)" + exportfile = False return if not is_1d_face(face,me):#face , Mesh wedge_list = [] vect_list = [] - for i in range(3): #UV TEXTURE, VERTICES vert_index = face.vertices[i] vert = me.vertices[vert_index] @@ -807,25 +796,19 @@ def parse_meshes(blender_meshes, psk_file): me.vertices[dindex0].select = True me.vertices[dindex1].select = True me.vertices[dindex2].select = True - - #raise RuntimeError("normal vector coplanar with face! points:", me.vertices[dindex0].co, current_mesh.vertices[dindex1].co, current_mesh.vertices[dindex2].co) + print("normal vector coplanar with face! points:", me.vertices[dindex0].co, current_mesh.vertices[dindex1].co, current_mesh.vertices[dindex2].co) exportmessage = "One of the face is dot or period or line, coplanar with the face" + exportfile = False + bpy.context.scene.objects.unlink(current_obj) return #print(dir(current_face)) - face.select = True - #print("smooth:",(current_face.use_smooth)) - #not sure if this right - #tri.SmoothingGroups - print(face.use_smooth) + #face.select = True + if face.use_smooth == True: tri.SmoothingGroups = 0 else: tri.SmoothingGroups = 1 - #tri.SmoothingGroups = face.use_smooth - #tri.SmoothingGroups = hex(face.use_smooth) - #print(hex(True)) - print(hex(face.use_smooth)) - #tri.SmoothingGroups = 1 + tri.MatIndex = object_material_index #print(tri) psk_file.AddFace(tri) @@ -835,8 +818,14 @@ def parse_meshes(blender_meshes, psk_file): print (" -- Dumping Mesh Points -- LEN:",len(points.dict)) for point in points.items(): psk_file.AddPoint(point) - #if len(points.dict) > 32767: + if len(points.dict) > 32767: #raise RuntimeError("Vertex point reach max limited 32767 in pack data. Your",len(points.dict)) + print("Vertex point reach max limited 32767 in pack data. Your",len(points.dict)) + exportmessage = "You have went over the limit on your Vectices/Vertex points. Limit is 32767." + exportfile = False + bpy.context.scene.objects.unlink(current_obj) + return + print (" -- Dumping Mesh Wedge -- LEN:",len(wedges.dict)) for wedge in wedges.items(): @@ -989,6 +978,7 @@ def parse_bone(blender_bone, psk_file, psa_file, parent_id, is_root_bone, parent parse_bone(current_child_bone, psk_file, psa_file, my_id, 0, mainparent, parent_root) def parse_armature(blender_armature, psk_file, psa_file): + global exportmessage, exportfile print ("----- parsing armature -----") print ('blender_armature length: %i' % (len(blender_armature))) @@ -1014,9 +1004,15 @@ def parse_armature(blender_armature, psk_file, psa_file): #will ingore this part of the ocde """ if len(current_armature.bones) == 0: - raise RuntimeError("Warning add two bones else it will crash the unreal editor.") + #raise RuntimeError("Warning add two bones else it will crash the unreal editor.") + exportmessage = "Warning add two bones else it will crash the unreal editor." + exportfile = False + return if len(current_armature.bones) == 1: - raise RuntimeError("Warning add one more bone else it will crash the unreal editor.") + #raise RuntimeError("Warning add one more bone else it will crash the unreal editor.") + exportmessage = "Warning add one more bone else it will crash the unreal editor." + exportfile = False + return mainbonecount = 0; for current_bone in current_armature.bones: #list the bone. #note this will list all the bones. @@ -1024,8 +1020,11 @@ def parse_armature(blender_armature, psk_file, psa_file): mainbonecount += 1 print("Main Bone",mainbonecount) if mainbonecount > 1: - #print("Warning there no main bone.") - raise RuntimeError("There too many Main bones. Number main bones:",mainbonecount) + print("Warning there no main bone.") + #raise RuntimeError("There too many Main bones. Number main bones:",mainbonecount) + exportmessage = "There no Main Bone!" + exportfile = False + return for current_bone in current_armature.bones: #list the bone. #note this will list all the bones. if(current_bone.parent is None): parse_bone(current_bone, psk_file, psa_file, 0, 0, current_obj.matrix_local, None) @@ -1468,7 +1467,7 @@ def parse_animation(blender_scene, blender_armatures, psa_file): def fs_callback(filename, context): #this deal with repeat export and the reset settings - global nbone, exportmessage + global nbone, exportmessage, exportfile nbone = 0 start_time = time.clock() @@ -1520,8 +1519,11 @@ def fs_callback(filename, context): #if there 1 mesh in scene add to the array if len(blender_meshes) == 1: mesh = blender_meshes[0] + print("MESH NAME",blender_meshes[0].name) blender_meshes = [] - blender_meshes.append(mesh.copy()) + copymesh = mesh.copy() + bpy.context.scene.objects.link(copymesh) + blender_meshes.append(copymesh) print(" - One Mesh Scene") #if there more than one mesh and one mesh select add to array elif (len(blender_meshes) > 1) and (len(selectmesh) == 1): @@ -1529,6 +1531,7 @@ def fs_callback(filename, context): exportmessage = "Error, Mesh Object not Center right should be (0,0,0)." for mesh in selectmesh:#remove object bpy.context.scene.objects.unlink(mesh) + exportfile = False return blender_meshes = [] copymesh = selectmesh[0] @@ -1562,6 +1565,7 @@ def fs_callback(filename, context): else: print(" - Too Many Meshes!") exportmessage = " - Select Mesh(s) For Export!" + exportfile = False print(" - Select One Mesh Object!") bmesh = False return @@ -1586,6 +1590,7 @@ def fs_callback(filename, context): elif blender_meshes[0].scale.x != 1 and blender_meshes[0].scale.y != 1 and blender_meshes[0].scale.z != 1: print("Error, Mesh Object not scale right should be (1,1,1).") exportmessage = "Error, Mesh Object not scale right should be (1,1,1)." + exportfile = False return elif blender_meshes[0].location.x == 0 and blender_meshes[0].location.y == 0 and blender_meshes[0].location.z == 0: #print("Okay") @@ -1595,10 +1600,12 @@ def fs_callback(filename, context): print("Error, Mesh Object not center.",blender_meshes[0].location) #exportmessage = "Error, Mesh Object not center." exportmessage = "Error, Mesh Object not center." + exportfile = False bMeshCenter = False return else: exportmessage = "Please Select your Meshes that matches that Armature for Export." + exportfile = False return else: bmesh = False @@ -1612,6 +1619,8 @@ def fs_callback(filename, context): print("Error, Armature Object not scale right should be (1,1,1).") exportmessage = "Error, Armature Object not scale right should be (1,1,1)." bArmatureScale = False + exportfile = False + return if blender_armature[0].location.x == 0 and blender_armature[0].location.y == 0 and blender_armature[0].location.z == 0: #print("Okay") bArmatureCenter = True @@ -1619,6 +1628,8 @@ def fs_callback(filename, context): print("Error, Armature Object not center.",blender_armature[0].location) exportmessage = "Error, Armature Object not center." bArmatureCenter = False + exportfile = False + return @@ -1629,6 +1640,7 @@ def fs_callback(filename, context): print("=================================") print("= Export Fail! =") print("=================================") + return else: exportmessage = "Export Finish!" #print("blender_armature:",dir(blender_armature[0])) @@ -1678,7 +1690,9 @@ def fs_callback(filename, context): raise # reset current frame - + if exportfile == False: + print("EXPORT STOP!") + return context.scene.frame_set(cur_frame) #set frame back to original frame ########################## @@ -2008,10 +2022,6 @@ class OBJECT_OT_UnrealExport(bpy.types.Operator): default_path = os.path.splitext(bpy.data.filepath)[0] + ".psk" fs_callback(default_path, bpy.context) - #self.report({'WARNING', 'INFO'}, exportmessage) - #self.report({'INFO'}, exportmessage) - #self.report({'DEBUG'}, exportmessage) - #self.report({'WARNING'}, exportmessage) self.report({'ERROR'}, exportmessage) return{'FINISHED'} diff --git a/io_import_scene_unreal_psk.py b/io_import_scene_unreal_psk.py index 81b6a911..d8fdcccc 100644 --- a/io_import_scene_unreal_psk.py +++ b/io_import_scene_unreal_psk.py @@ -20,7 +20,7 @@ bl_info = { "name": "Import Unreal Skeleton Mesh (.psk)", "author": "Darknet", "version": (2, 1), - "blender": (2, 6, 3), + "blender": (2, 6, 2), "location": "File > Import > Skeleton Mesh (.psk)", "description": "Import Skeleleton Mesh", "warning": "", @@ -74,6 +74,13 @@ skala = 1 flipyz = False flipuv = True +""" +def unpack_list(list_of_tuples): + l = [] + for t in list_of_tuples: + l.extend(t) + return l +""" #pack read words def word(long): s='' @@ -147,7 +154,289 @@ def drawmesh(): ob.vertex_groups.new(namebone) me_ob.update() bpy.context.scene.objects.link(ob) - +def drawmesh4(): + global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m + global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,mat_faceslist + global vertices,faces + print("CREATING MESH") + me_ob = bpy.data.meshes.new('testmesh') + print("CREATING BMESH") + bm = bmesh.new() # create an empty BMesh + #print(dir(bm)) + bm.from_mesh(me_ob) # fill it in from a Mesh + + #print("CREATING:") + + #vertices + #print("-VERTICES") + #for v_co in vertices: + #bm.verts.new(v_co) + + #faces + #print("-FACES") + for f_idx in faces: + #face idx + bm.faces.new([bm.verts[i] for i in f_idx]) + + print("-FACE SMOOTHS") + for face in bm.faces: + face.smooth = facesmooth[face.index] + + bm.to_mesh(me_ob) #write mesh + ob = bpy.data.objects.new("TestObject",me_ob) + me_ob.update() #update object + bpy.context.scene.objects.link(ob) #link to scene + + #print(dir(bm)) + + #create vertex group + for bone_id in range(len(bonesdata)): + bonedata = bonesdata[str(bone_id)] + namebone = bonedata[0]#.strip()[-25:] + #print("NAME:",namebone) + ob.vertex_groups.new(namebone) + + #print("CREATING > Assign Weights") + + + materialname = "pskmat" + psktexname = "psktex" + + me_ob.uv_textures.new() + for matcount in range(1): + matdata = bpy.data.materials.new(materialname + str(1)) + me_ob.materials.append(matdata) + + + print(dir(me_ob)) + #me_ob.tessface_uv_textures.new(name=psktexname) + #me_ob.uv_textures.new(name=psktexname) + #me_ob.uv_textures[0].active =True + + #print((me_ob.uv_textures[0].name)) + #print(dir(me_ob.uv_textures[0])) + #for uv in me_ob.uv_textures: + #print(dir(uv.data[0])) + + """ + print("NEW TEXTURE") + me_ob.uv_textures.new() + + print("CREATING UV") + for uv in me_ob.uv_textures: + #print(len(uv.data)) + for face in bm.faces: + print(dir(face.verts[0])) + #print(dir(uv.data[face.index].image)) + #print(dir(uv.data[face.index])) + + print("CREATING > Vertex Group") + """ + bpy.context.scene.update() +def drawmesh3(): + global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m + global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,mat_faceslist + global vertices,faces + print("CREATING MESH") + me_ob = bpy.data.meshes.new('testmesh') + print("CREATING BMESH") + bm = bmesh.new() # create an empty BMesh + #print(dir(bm)) + bm.from_mesh(me_ob) # fill it in from a Mesh + + print("CREATING:") + + #vertices + print("-VERTICES") + for v_co in vertices: + bm.verts.new(v_co) + + #faces + print("-FACES") + for f_idx in faces: + #face idx + bm.faces.new([bm.verts[i] for i in f_idx]) + + print("-FACE SMOOTHS") + for face in bm.faces: + face.smooth = facesmooth[face.index] + + bm.to_mesh(me_ob) #write mesh + ob = bpy.data.objects.new("TestObject",me_ob) + me_ob.update() #update object + bpy.context.scene.objects.link(ob) #link to scene + + #print(dir(bm)) + + #create vertex group + for bone_id in range(len(bonesdata)): + bonedata = bonesdata[str(bone_id)] + namebone = bonedata[0]#.strip()[-25:] + #print("NAME:",namebone) + ob.vertex_groups.new(namebone) + + #print("CREATING > Assign Weights") + + + materialname = "pskmat" + psktexname = "psktex" + + me_ob.uv_textures.new() + for matcount in range(1): + matdata = bpy.data.materials.new(materialname + str(1)) + me_ob.materials.append(matdata) + + + print(dir(me_ob)) + me_ob.tessface_uv_textures.new(name=psktexname) + #me_ob.uv_textures.new(name=psktexname) + #me_ob.uv_textures[0].active =True + + #print((me_ob.uv_textures[0].name)) + #print(dir(me_ob.uv_textures[0])) + #for uv in me_ob.uv_textures: + #print(dir(uv.data[0])) + + """ + print("NEW TEXTURE") + me_ob.uv_textures.new() + + print("CREATING UV") + for uv in me_ob.uv_textures: + #print(len(uv.data)) + for face in bm.faces: + print(dir(face.verts[0])) + #print(dir(uv.data[face.index].image)) + #print(dir(uv.data[face.index])) + + print("CREATING > Vertex Group") + """ + bpy.context.scene.update() +def drawmesh1(): + global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m + global vertexes_ids,bonesdata,meshesdata,groups,num_materials,skala,flipyz,flipuv,mat_faceslist + global vertices,faces + print(faces[0]) + me_ob = bpy.data.meshes.new('testmesh') + #obmesh = bpy.data.objects.new('testdata',me_ob) + #uvtex = me_ob.uv_textures.new(name="pskuvtexture") + #uvtex = me_ob.tessface_uv_textures.new(name="pskuvtexture") + + #material = bpy.data.materials.new('pskmat') + #me_ob.materials.append(material) + #uvtex = me_ob.uv_textures.new('pskuvtexture') + + #create mesh + #me_ob.from_pydata(vertexes,[],faceslist)#create the faces and vertices + + me_ob.vertices.add(len(vertices)) + me_ob.tessfaces.add(len(faces)) + me_ob.vertices.foreach_set("co", unpack_list(vertices)) + me_ob.tessfaces.foreach_set("vertices_raw",unpack_list( faces)) + + + + #bm = bmesh.new() # create an empty BMesh + #print(dir(bm)) + #bm.from_mesh(me_ob) # fill it in from a Mesh + + + #for v_co in vertices: + #bm.verts.new(v_co) + #for f_idx in faces: + #bm.faces.new([bm.verts[i] for i in f_idx]) + + + #bm.to_mesh(me_ob) + ob = bpy.data.objects.new("TestObject",me_ob) + me_ob.update() + bpy.context.scene.objects.link(ob) + + #set face smooth list boolean + #for face in bm.faces: + #face.smooth = facesmooth[face.index] + #bm.uv_textures.new() + #print(dir(bm)) + #bm.verts.foreach_set("co", vertices) + #bm.faces.add(len(faces)) + #bm.faces.foreach_set("vertices_raw", faces) + + #print(dir(me_ob)) + #print(dir(bm)) + + #print(dir(uvtex.data[0].image)) + #for countm in range(len(me_ob.uv_textures)): + #me_ob.update() + #uvtex = me_ob.uv_textures[countm] #add one uv texture + #me_ob.update() + #for i, face in enumerate(bm.faces): + #print(dir(face)) + + + + + #texture + #texture = bpy.data.textures.new(name="texture",type='IMAGE') + #material + #matdata = bpy.data.materials.new(name="pskmat") + #mtex = matdata.texture_slots.add() + #mtex.texture = texture + #mtex.texture_coords = 'UV' + #mtex.use_map_color_diffuse = True + #mtex.use_map_alpha = True + #uvtex = me_ob.uv_textures[0] + + #print(dir(uvtex.data[0])) + #print(dir(uvtex.data[0].image)) + #print(dir(texture)) + + #for i, face in enumerate(bm.faces): + #print(face.material_index) + #face.material_index = faceuv[i][1] + #blender_tface = uvtex.data[i].image #face + """ + + #mesh vertex group #not done + #create vertex group + for bone_id in range(len(bonesdata)): + bonedata = bonesdata[str(bone_id)] + namebone = bonedata[0]#.strip()[-25:] + obmesh.vertex_groups.new(namebone) + #assgin group + for m in range(len(groups)): + data = groups[m] + w = float(data[0]) + v_id = data[1] + gr = data[2] + gr = bonenames[gr] + + #for vgroup in obmesh.vertex_groups: + #print(vgroup.name,":",vgroup.index) + + for vgp in RWghts: + #bone index + if vgp[1] == vgroup.index: + #print(vgp) + #[vertex id],weight + vgroup.add([vgp[0]], vgp[2], 'ADD') + """ + + + # Finish up, write the bmesh back to the mesh + #bm.to_mesh(me_ob) + + + + #print((uvtex.name)) + #print((uvtex.data)) + #print(dir(uvtex)) + #print(dir(uvtex.data[0].image)) + #print(type(uvtex.data[0].image)) + + + + #bpy.context.scene.objects.link(obmesh) + bpy.context.scene.update() #Create Armature def check_armature(): global DEBUGLOG, plik,vertexes,uvcoord,faceslist,num_faces,facemat,facesmooth,m @@ -652,7 +941,7 @@ class OBJECT_OT_PSAPath(bpy.types.Operator): class OBJECT_OT_Path(bpy.types.Operator): bl_idname = "object.path" - bl_label = "MESH BUILD TEST" + bl_label = "MESH BUILD" __doc__ = "" # generic transform props view_align = BoolProperty( @@ -702,7 +991,206 @@ class OBJECT_OT_Path(bpy.types.Operator): #print(dir(uv.data[0])) #print(dir(uv.data[0].uv1)) return {'RUNNING_MODAL'} +""" +class OBJECT_OT_Path(bpy.types.Operator): + bl_idname = "object.path" + bl_label = "MESH BUILD" + __doc__ = "" + # generic transform props + view_align = BoolProperty( + name="Align to View", + default=False, + ) + location = FloatVectorProperty( + name="Location", + subtype='TRANSLATION', + ) + rotation = FloatVectorProperty( + name="Rotation", + subtype='EULER', + ) + def execute(self, context): + return {'FINISHED'} + + def invoke(self, context, event): + me = bpy.data.meshes.new("test") + obmade = bpy.data.objects.new("TestObject",me) + print("Create Simple Mesh") + bpy.data.scenes[0].objects.link(obmade) + for i in bpy.context.scene.objects: i.select = False #deselect all objects + obmade.select = True + bpy.context.scene.objects.active = obmade + + #bpy.ops.object.mode_set(mode='EDIT') + #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)]) + #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)]) + verts = [(0,0,0),(2,0,0),(2,0,2)] + #faces = [([0, 1, 2])] + + faces = [] + #faces.extend([(1,2,3,0)]) + faces.extend([(0,1,2,0)]) + #print(faces[0][0]) + #print(dir(me.tessfaces)) + me.vertices.add(len(verts)) + me.vertices.foreach_set("co", unpack_list(verts)) + + me.tessfaces.add(len(faces)) + #me.tessfaces.foreach_set("vertices_raw", unpack_list(faces)) + me.tessfaces.foreach_set("vertices", unpack_list(faces)) + #me.tessfaces.foreach_set("vertices_raw", (faces)) + print(len(me.tessfaces)) + me.tessface_uv_textures.new("uvtexture") + for uv in me.tessface_uv_textures: + print(len(uv.data)) + print(dir(uv.data[0])) + bm = bmesh.new() + bm.to_mesh(me) + #for v_co in verts: + #bm.verts.new(v_co) + for f_idx in faces: + bm.faces.new([bm.verts[i] for i in f_idx]) + #bm.to_mesh(me) + #ob = bpy.data.objects.new("TestObject",me) + #me.update() + + #print(dir(me)) + #me.uv_textures.new("uvtexture") + #for uv in me.uv_textures: + #print(len(uv.data)) + #from bpy_extras import object_utils + #object_utils.object_data_add(context, me, operator=self) + #ob = bpy.data.objects.new("TestObject",me) + #bpy.context.scene.objects.link(ob) + + return {'RUNNING_MODAL'} +""" +""" +class OBJECT_OT_Path(bpy.types.Operator): + bl_idname = "object.path" + bl_label = "PSA Path" + __doc__ = "" + # generic transform props + view_align = BoolProperty( + name="Align to View", + default=False, + ) + location = FloatVectorProperty( + name="Location", + subtype='TRANSLATION', + ) + rotation = FloatVectorProperty( + name="Rotation", + subtype='EULER', + ) + def execute(self, context): + return {'FINISHED'} + + def invoke(self, context, event): + me = bpy.data.meshes.new("test") + #ob = bpy.data.objects.new("TestObject",me) + print("Create Simple Mesh") + #bpy.data.scenes[0].objects.link(ob) + + #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)]) + #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)]) + verts = [(0,0,0),(2,0,0),(2,0,2)] + faces = [(0, 1, 2)] + #faces = [([1,2,3])] + + + bm = bmesh.new() + + for v_co in verts: + bm.verts.new(v_co) + + for f_idx in faces: + bm.faces.new([bm.verts[i] for i in f_idx]) + + bm.to_mesh(me) + ob = bpy.data.objects.new("TestObject",me) + me.update() + + print(dir(me)) + me.uv_textures.new("uvtexture") + for uv in me.uv_textures: + print(len(uv.data)) + + + + + #from bpy_extras import object_utils + #object_utils.object_data_add(context, me, operator=self) + bpy.context.scene.objects.link(ob) + + return {'RUNNING_MODAL'} +""" +""" +class OBJECT_OT_Path(bpy.types.Operator): + bl_idname = "object.path" + bl_label = "PSA Path" + __doc__ = "" + # generic transform props + view_align = BoolProperty( + name="Align to View", + default=False, + ) + location = FloatVectorProperty( + name="Location", + subtype='TRANSLATION', + ) + rotation = FloatVectorProperty( + name="Rotation", + subtype='EULER', + ) + #filepath = StringProperty(name="PSA File Path", description="Filepath used for importing the PSA file", maxlen= 1024, default= "") + #filter_glob = StringProperty( + #default="*.psa", + #options={'HIDDEN'}, + #) + def execute(self, context): + #context.scene.importpsapath = self.properties.filepath + return {'FINISHED'} + + def invoke(self, context, event): + me = bpy.data.meshes.new("test") + #ob = bpy.data.objects.new("TestObject",me) + print("Create Simple Mesh") + #bpy.data.scenes[0].objects.link(ob) + + #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)]) + #me.from_pydata([(0,0,0),(2,0,0),(2,0,2)],[(1,2),(2,3),(3,1)],[(1,2,3)]) + verts = [(0,0,0),(2,0,0),(2,0,2)] + faces = [(0, 1, 2, 3)] + #faces = [([1,2,3])] + + + bm = bmesh.new() + + for v_co in verts: + bm.verts.new(v_co) + #for f_idx in faces: + #bm.faces.new([bm.verts[i] for i in f_idx]) + bm.to_mesh(me) + me.update() + from bpy_extras import object_utils + object_utils.object_data_add(context, me, operator=self) + + #bpy.context.scene.objects.link(me) + + #me.from_pydata(verts,[],faces) + me.vertices.add(len(verts)) + me.tessfaces.add(len(faces)) + + me.vertices.foreach_set("co", unpack_list(verts)) + me.tessfaces.foreach_set("vertices_raw", (faces))#not working + + me.update() + + #bpy.context.window_manager.fileselect_add(self) + return {'RUNNING_MODAL'} +""" #import menu panel tool bar class VIEW3D_PT_unrealimport_objectmode(bpy.types.Panel): bl_space_type = "VIEW_3D" |