Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
bpy.context.scene.objects.active = obj #set active object
mesh = bmesh.new();
mesh.from_mesh(obj.data)
for face in mesh.faces:
face.select = False
for face in mesh.faces:
if face.smooth == True:
face.select = True
smoothcount += 1
else:
flatcount += 1
face.select = False
mesh.to_mesh(obj.data)
bpy.context.scene.update()
bpy.ops.object.mode_set(mode='EDIT')
print("Select Smooth Count(s):",smoothcount," Flat Count(s):",flatcount)
bselected = True
break
if bselected:
print("Selected Face(s) Exectue!")
self.report({'INFO'}, "Selected Face(s) Exectue!")
else:
print("Didn't select Mesh Object!")
self.report({'INFO'}, "Didn't Select Mesh Object!")
print("----------------------------------------")
return{'FINISHED'}
class OBJECT_OT_MeshClearWeights(bpy.types.Operator):
bl_idname = "object.meshclearweights" # XXX, name???
bl_label = "Remove Vertex Weights"#"Remove Mesh vertex weights"
__doc__ = """Remove all mesh vertex groups weights for the bones."""
def invoke(self, context, event):
for obj in bpy.data.objects:
if obj.type == 'MESH' and obj.select == True:
for vg in obj.vertex_groups:
obj.vertex_groups.remove(vg)
self.report({'INFO'}, "Mesh Vertex Groups Remove!")
break
return{'FINISHED'}
def unpack_list(list_of_tuples):
l = []
for t in list_of_tuples:
l.extend(t)
return l
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
def rebuildmesh(obj):
#make sure it in object mode
print("Mesh Object Name:",obj.name)
bpy.ops.object.mode_set(mode='OBJECT')
for i in bpy.context.scene.objects: i.select = False #deselect all objects
obj.select = True
bpy.context.scene.objects.active = obj
me_ob = bpy.data.meshes.new(("Re_"+obj.name))
mesh = obj.data
faces = []
verts = []
smoothings = []
uvfaces = []
#print("creating array build mesh...")
mmesh = obj.to_mesh(bpy.context.scene,True,'PREVIEW')
uv_layer = mmesh.tessface_uv_textures.active
for face in mmesh.tessfaces:
smoothings.append(face.use_smooth)#smooth or flat in boolean
if uv_layer != None:#check if there texture data exist
faceUV = uv_layer.data[face.index]
uvs = []
for uv in faceUV.uv:
uvs.append((uv[0],uv[1]))
uvfaces.append(uvs)
#print((face.vertices[:]))
if len(face.vertices) == 3:
faces.extend([(face.vertices[0],face.vertices[1],face.vertices[2],0)])
else:
faces.extend([(face.vertices[0],face.vertices[1],face.vertices[2],face.vertices[3])])
#vertex positions
for vertex in mesh.vertices:
verts.append(vertex.co.to_tuple())
#vertices weight groups into array
vertGroups = {} #array in strings
for vgroup in obj.vertex_groups:
vlist = []
for v in mesh.vertices:
for vg in v.groups:
if vg.group == vgroup.index:
vlist.append((v.index,vg.weight))
#print((v.index,vg.weight))
vertGroups[vgroup.name] = vlist
#print("creating mesh object...")
#me_ob.from_pydata(verts, [], faces)
me_ob.vertices.add(len(verts))
me_ob.tessfaces.add(len(faces))
me_ob.vertices.foreach_set("co", unpack_list(verts))
me_ob.tessfaces.foreach_set("vertices_raw",unpack_list( faces))
me_ob.tessfaces.foreach_set("use_smooth", smoothings)#smooth array from face
#check if there is uv faces
if len(uvfaces) > 0:
uvtex = me_ob.tessface_uv_textures.new(name="retex")
for i, face in enumerate(me_ob.tessfaces):
blender_tface = uvtex.data[i] #face
mfaceuv = uvfaces[i]
if len(mfaceuv) == 3:
blender_tface.uv1 = mfaceuv[0];
blender_tface.uv2 = mfaceuv[1];
blender_tface.uv3 = mfaceuv[2];
if len(mfaceuv) == 4:
blender_tface.uv1 = mfaceuv[0];
blender_tface.uv2 = mfaceuv[1];
blender_tface.uv3 = mfaceuv[2];
blender_tface.uv4 = mfaceuv[3];
me_ob.update()#need to update the information to able to see into the secne
obmesh = bpy.data.objects.new(("Re_"+obj.name),me_ob)
bpy.context.scene.update()
#Build tmp materials
materialname = "ReMaterial"
for matcount in mesh.materials:
matdata = bpy.data.materials.new(materialname)
me_ob.materials.append(matdata)
#assign face to material id
for face in mesh.tessfaces:
me_ob.faces[face.index].material_index = face.material_index
#vertices weight groups
for vgroup in vertGroups:
group = obmesh.vertex_groups.new(vgroup)
for v in vertGroups[vgroup]:
group.add([v[0]], v[1], 'ADD')# group.add(array[vertex id],weight,add)
bpy.context.scene.objects.link(obmesh)
#print("Mesh Material Count:",len(me_ob.materials))
matcount = 0
#print("MATERIAL ID OREDER:")
for mat in me_ob.materials:
#print("-Material:",mat.name,"INDEX:",matcount)
matcount += 1
print("Mesh Object Name:",obmesh.name)
bpy.context.scene.update()
return obmesh
class OBJECT_OT_UTRebuildMesh(bpy.types.Operator):
bl_idname = "object.utrebuildmesh" # XXX, name???
bl_label = "Rebuild Mesh"#"Rebuild Mesh"
__doc__ = """It rebuild the mesh from scrape from the selected mesh object. Note the scale will be 1:1 for object mode. To keep from deforming"""
def invoke(self, context, event):
print("----------------------------------------")
print("Init Mesh Bebuild...")
bselected = False
bpy.ops.object.mode_set(mode='OBJECT')
for obj in bpy.data.objects:
if obj.type == 'MESH' and obj.select == True:
rebuildmesh(obj)
self.report({'INFO'}, "Rebuild Mesh Finish!")
print("Finish Mesh Build...")
print("----------------------------------------")
return{'FINISHED'}
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
def rebuildarmature(obj):
currentbone = [] #select armature for roll copy
print("Armature Name:",obj.name)
objectname = "ArmatureDataPSK"
meshname ="ArmatureObjectPSK"
armdata = bpy.data.armatures.new(objectname)
ob_new = bpy.data.objects.new(meshname, armdata)
bpy.context.scene.objects.link(ob_new)
bpy.ops.object.mode_set(mode='OBJECT')
for i in bpy.context.scene.objects: i.select = False #deselect all objects
ob_new.select = True
bpy.context.scene.objects.active = obj
bpy.ops.object.mode_set(mode='EDIT')
for bone in obj.data.edit_bones:
if bone.parent != None:
currentbone.append([bone.name,bone.roll])
else:
currentbone.append([bone.name,bone.roll])
bpy.ops.object.mode_set(mode='OBJECT')
for i in bpy.context.scene.objects: i.select = False #deselect all objects
bpy.context.scene.objects.active = ob_new
bpy.ops.object.mode_set(mode='EDIT')
for bone in obj.data.bones:
bpy.ops.object.mode_set(mode='EDIT')
newbone = ob_new.data.edit_bones.new(bone.name)
newbone.head = bone.head_local
newbone.tail = bone.tail_local
for bonelist in currentbone:
if bone.name == bonelist[0]:
newbone.roll = bonelist[1]
break
if bone.parent != None:
parentbone = ob_new.data.edit_bones[bone.parent.name]
newbone.parent = parentbone
ob_new.animation_data_create()#create animation data
if obj.animation_data != None:#check for animation
ob_new.animation_data.action = obj.animation_data.action #just make sure it here to do the animations if exist
print("Armature Object Name:",ob_new.name)
return ob_new
class OBJECT_OT_UTRebuildArmature(bpy.types.Operator):
bl_idname = "object.utrebuildarmature" # XXX, name???
bl_label = "Rebuild Armature" #Rebuild Armature
__doc__ = """If mesh is deform when importing to unreal engine try this. It rebuild the bones one at the time by select one armature object scrape to raw setup build. Note the scale will be 1:1 for object mode. To keep from deforming"""
def invoke(self, context, event):
print("----------------------------------------")
print("Init Rebuild Armature...")
bselected = False
for obj in bpy.data.objects:
if obj.type == 'ARMATURE' and obj.select == True:
rebuildarmature(obj)
self.report({'INFO'}, "Rebuild Armature Finish!")
print("End of Rebuild Armature.")
print("----------------------------------------")
return{'FINISHED'}
class UDKActionSetListPG(bpy.types.PropertyGroup):
bool = BoolProperty(default=False)
string = StringProperty()
actionname = StringProperty()
bmatch = BoolProperty(default=False,name="Match", options={"HIDDEN"},description = "This check against bone names and action group names matches and override boolean if true.")
bexport = BoolProperty(default=False,name="Export",description = "Check this to export the animation")
template_list_controls = StringProperty(default="bmatch:bexport", options={"HIDDEN"})
bpy.utils.register_class(UDKActionSetListPG)
bpy.types.Scene.udkas_list = CollectionProperty(type=UDKActionSetListPG)
bpy.types.Scene.udkas_list_idx = IntProperty()
class UDKObjListPG(bpy.types.PropertyGroup):
bool = BoolProperty(default=False)
string = StringProperty()
bexport = BoolProperty(default=False,name="Export", options={"HIDDEN"},description = "This will be ignore when exported")
bselect = BoolProperty(default=False,name="Select", options={"HIDDEN"},description = "This will be ignore when exported")
otype = StringProperty(name="Type",description = "This will be ignore when exported")
template_list_controls = StringProperty(default="otype:bselect", options={"HIDDEN"})
bpy.utils.register_class(UDKObjListPG)
bpy.types.Scene.udkobj_list = CollectionProperty(type=UDKObjListPG)
bpy.types.Scene.udkobj_list_idx = IntProperty()
class UDKMeshListPG(bpy.types.PropertyGroup):
bool = BoolProperty(default=False)
string = StringProperty()
bexport = BoolProperty(default=False,name="Export", options={"HIDDEN"},description = "This object will be export when true.")
bselect = BoolProperty(default=False,name="Select", options={"HIDDEN"},description = "Make sure you have Mesh is parent to Armature.")
otype = StringProperty(name="Type",description = "This will be ignore when exported")
template_list_controls = StringProperty(default="bselect:bexport", options={"HIDDEN"})
bpy.utils.register_class(UDKMeshListPG)
bpy.types.Scene.udkmesh_list = CollectionProperty(type=UDKMeshListPG)
bpy.types.Scene.udkmesh_list_idx = IntProperty()
class UDKArmListPG(bpy.types.PropertyGroup):
bool = BoolProperty(default=False)
string = StringProperty()
bexport = BoolProperty(default=False,name="Export", options={"HIDDEN"},description = "This will be ignore when exported")
bselect = BoolProperty(default=False,name="Select", options={"HIDDEN"},description = "This will be ignore when exported")
otype = StringProperty(name="Type",description = "This will be ignore when exported")
armtemplate_list_controls = StringProperty(default="", options={"HIDDEN"})
bpy.utils.register_class(UDKArmListPG)
bpy.types.Scene.udkArm_list = CollectionProperty(type=UDKArmListPG)
bpy.types.Scene.udkArm_list_idx = IntProperty()
class Panel_UDKExport( bpy.types.Panel ):
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
bl_label = "UDK Export"
bl_idname = "OBJECT_PT_udk_tools"
#bl_space_type = "PROPERTIES"
#bl_region_type = "WINDOW"
#bl_context = "object"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
#def draw_header(self, context):
# layout = self.layout
#obj = context.object
#layout.prop(obj, "select", text="")
#@classmethod
#def poll(cls, context):
# return context.active_object
def draw(self, context):
layout = self.layout
path = get_dst_path()
object_name = ""
#if context.object:
# object_name = context.object.name
if context.active_object:
object_name = context.active_object.name
row10 = layout.row()
row10.prop(context.scene, "udk_option_smoothing_groups")
row10.prop(context.scene, "udk_option_clamp_uv")
row10.prop(context.scene, "udk_option_verbose")
row = layout.row()
row.label(text="Active object: " + object_name)
#layout.separator()
layout.prop(context.scene, "udk_option_filename_src")
row = layout.row()
row.label(text=path)
#layout.separator()
layout.prop(context.scene, "udk_option_export")
layout.prop(context.scene, "udk_option_selectobjects")
if context.scene.udk_option_selectobjects:
layout.operator("object.selobjectpdate")
layout.label(text="ARMATURE")
layout.template_list(context.scene, "udkArm_list", context.scene, "udkArm_list_idx",prop_list="template_list_controls", rows=3)
layout.label(text="MESH")
layout.template_list(context.scene, "udkmesh_list", context.scene, "udkmesh_list_idx",prop_list="template_list_controls", rows=5)
layout.prop(context.scene, "udk_option_selectanimations")
if context.scene.udk_option_selectanimations:
layout.operator("action.setanimupdate")
layout.label(text="Action Set(s)")
layout.template_list(context.scene, "udkas_list", context.scene, "udkas_list_idx",prop_list="template_list_controls", rows=5)
test = layout.separator()
layout.prop(context.scene, "udk_option_scale")
layout.prop(context.scene, "udk_option_rebuildobjects")
#layout.prop(context.scene, "udk_option_ignoreactiongroupnames")
row11 = layout.row()
row11.operator("object.udk_export")
row11.operator("object.toggle_console")
layout.operator(OBJECT_OT_UTRebuildArmature.bl_idname)
layout.label(text="Mesh")
layout.operator(OBJECT_OT_MeshClearWeights.bl_idname)
layout.operator(OBJECT_OT_UTSelectedFaceSmooth.bl_idname)
layout.operator(OBJECT_OT_UTRebuildMesh.bl_idname)
layout.operator(OBJECT_OT_UDKCheckMeshLines.bl_idname)
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
my_objlist = bpy.context.scene.udkArm_list
objectl = []
for objarm in bpy.context.scene.objects:#list and filter only mesh and armature
if objarm.type == 'ARMATURE':
objectl.append(objarm)
for _objd in objectl:#check if list has in udk list
bfound_obj = False
for _obj in my_objlist:
if _obj.name == _objd.name and _obj.otype == _objd.type:
_obj.bselect = _objd.select
bfound_obj = True
break
if bfound_obj == False:
#print("ADD ARMATURE...")
my_item = my_objlist.add()
my_item.name = _objd.name
my_item.bselect = _objd.select
my_item.otype = _objd.type
removeobject = []
for _udkobj in my_objlist:
bfound_objv = False
for _objd in bpy.context.scene.objects: #check if there no existing object from sense to remove it
if _udkobj.name == _objd.name and _udkobj.otype == _objd.type:
bfound_objv = True
break
if bfound_objv == False:
removeobject.append(_udkobj)
#print("remove check...")
for _item in removeobject: #loop remove object from udk list object
count = 0
for _obj in my_objlist:
if _obj.name == _item.name and _obj.otype == _item.otype:
my_objlist.remove(count)
break
count += 1
my_objlist = bpy.context.scene.udkmesh_list
objectl = []
for objarm in bpy.context.scene.objects:#list and filter only mesh and armature
if objarm.type == 'MESH':
objectl.append(objarm)
for _objd in objectl:#check if list has in udk list
bfound_obj = False
for _obj in my_objlist:
if _obj.name == _objd.name and _obj.otype == _objd.type:
_obj.bselect = _objd.select
bfound_obj = True
break
if bfound_obj == False:
my_item = my_objlist.add()
my_item.name = _objd.name
my_item.bselect = _objd.select
my_item.otype = _objd.type
removeobject = []
for _udkobj in my_objlist:
bfound_objv = False
for _objd in bpy.context.scene.objects: #check if there no existing object from sense to remove it
if _udkobj.name == _objd.name and _udkobj.otype == _objd.type:
bfound_objv = True
break
if bfound_objv == False:
removeobject.append(_udkobj)
#print("remove check...")
for _item in removeobject: #loop remove object from udk list object
count = 0
for _obj in my_objlist:
if _obj.name == _item.name and _obj.otype == _item.otype:
my_objlist.remove(count)
break
count += 1
class OBJECT_OT_UDKObjUpdate(bpy.types.Operator):
bl_idname = "object.selobjectpdate"
bl_label = "Update Object(s)"
__doc__ = "This will update the filter of the mesh and armature."
actionname = bpy.props.StringProperty()
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
def execute(self, context):
udkupdateobjects()
return{'FINISHED'}
def udkcheckmeshline():
objmesh = None
for obj in bpy.context.scene.objects:
if obj.type == 'MESH' and obj.select == True:
objmesh = obj
objmesh = triangulate_mesh(objmesh) #create a copy of the mesh
bpy.ops.object.mode_set(mode='OBJECT')
for i in bpy.context.scene.objects: i.select = False # deselect all objects
objmesh.select = True
bpy.context.scene.objects.active = objmesh #set active mesh
wedges = ObjMap()
points = ObjMap()
bpy.ops.object.mode_set(mode='EDIT') #set in edit mode
bpy.ops.mesh.select_all(action='DESELECT')
bpy.context.tool_settings.mesh_select_mode = (True, False, False) #select vertices
if objmesh != None:
print("found mesh")
print(objmesh)
print(objmesh.data.tessfaces)
vertex_list = []
for face in objmesh.data.tessfaces:
wedge_list = []
vect_list = []
for i in range(3):
vert_index = face.vertices[i]
vert = objmesh.data.vertices[vert_index]
vect_list.append( FVector(vert.co.x, vert.co.y, vert.co.z) )
vpos = objmesh.matrix_local * vert.co
p = VPoint()
p.Point.X = vpos.x
p.Point.Y = vpos.y
p.Point.Z = vpos.z
w = VVertex()
w.PointIndex = points.get(p) # store keys
index_wedge = wedges.get(w)
wedge_list.append(index_wedge)
no = face.normal
norm = FVector(no[0], no[1], no[2])
tnorm = vect_list[1].sub(vect_list[0]).cross(vect_list[2].sub(vect_list[1]))
dot = norm.dot(tnorm)
tri = VTriangle()
if dot > 0:
(tri.WedgeIndex2, tri.WedgeIndex1, tri.WedgeIndex0) = wedge_list
elif dot < 0:
(tri.WedgeIndex0, tri.WedgeIndex1, tri.WedgeIndex2) = wedge_list
else:
dindex0 = face.vertices[0];
dindex1 = face.vertices[1];
dindex2 = face.vertices[2];
vertex_list.append(dindex0)
vertex_list.append(dindex1)
vertex_list.append(dindex2)
bpy.ops.object.mode_set(mode='OBJECT')
for vertex in objmesh.data.vertices: #loop all vertex in the mesh list
for vl in vertex_list: #loop for error vertex
if vertex.index == vl: #if match set to select
vertex.select = True
break
bpy.ops.object.mode_set(mode='EDIT') #set in edit mode to see the select vertex
objmesh.data.update() # update object
bpy.context.scene.update() #update scene
message = "MESH PASS"
if len(vertex_list) > 0:
message = "MESH FAIL"
return message
class OBJECT_OT_UDKCheckMeshLines(bpy.types.Operator):
bl_idname = "object.udkcheckmeshline"
bl_label = "Check Mesh Vertices"
__doc__ = """Select the mesh for export test. This will create dummy mesh to see which area are broken. If the vertices share the same position it will causes an bug."""
def execute(self, context):
message = udkcheckmeshline()
self.report({'ERROR'}, message)
return{'FINISHED'}
class OBJECT_OT_ActionSetAnimUpdate(bpy.types.Operator):
bl_idname = "action.setanimupdate"
bl_label = "Update Action Set(s)"
__doc__ = "Select Armture to match the action set groups. All bones keys must be set to match with number of bones."
actionname = bpy.props.StringProperty()
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
def execute(self, context):
my_sett = bpy.context.scene.udkas_list
bones = []
armature = None
armatures = []
armatureselected = []
for objarm in bpy.context.scene.objects:
if objarm.type == 'ARMATURE':
#print("ADDED ARMATURE...")
armatures.append(objarm)
if objarm.select == True:
armatureselected.append(objarm)
if len(armatureselected) == len(armatures) == 1:
armature = armatures[0]
if len(armatures) == 1:
armature = armatures[0]
if len(armatureselected) == 1:
armature = armatureselected[0]
if armature != None:
for bone in armature.pose.bones:
bones.append(bone.name)
for action in bpy.data.actions:#action list
bfound = False
count = 0
for actionbone in action.groups:
#print("Pose bone name: ",actionbone.name)
for b in bones:
if b == actionbone.name:
count += 1
#print(b," : ",actionbone.name)
break
for actionlist in my_sett:
if action.name == actionlist.name:
bactionfound = True
if len(bones) == len(action.groups) == count:
actionlist.bmatch = True
else:
actionlist.bmatch = False
bfound = True
break
if bfound != True:
my_item = my_sett.add()
#print(dir(my_item.bmatch))
my_item.name = action.name
my_item.template_list_controls = "bmatch:bexport"
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
if len(bones) == len(action.groups) == count:
my_item.bmatch = True
else:
my_item.bmatch = False
removeactions = []
#check action list and data actions
for actionlist in bpy.context.scene.udkas_list:
bfind = False
notfound = 0
for act in bpy.data.actions:
if actionlist.name == act.name:
bfind = True
else:
notfound += 1
#print("ACT NAME:",actionlist.name," COUNT",notfound)
if notfound == len(bpy.data.actions):
#print("remove :",actionlist.name)
removeactions.append(actionlist.name)
#print("Not in the action data list:",len(removeactions))
#remove list or chnages in the name the template list
for actname in removeactions:
actioncount = 0
for actionlist in my_sett:
#print("action name:",actionlist.name)
if actionlist.name == actname:
my_sett.remove(actioncount);
break
actioncount += 1
return{'FINISHED'}
class ExportUDKAnimData(bpy.types.Operator):
"""Export Skeleton Mesh / Animation Data file(s)"""
bl_idname = "export_anim.udk" # this is important since its how bpy.ops.export.udk_anim_data is constructed
bl_label = "Export PSK/PSA"
__doc__ = """One mesh and one armature else select one mesh or armature to be exported"""
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
filepath = StringProperty(
subtype='FILE_PATH',
)
filter_glob = StringProperty(
default="*.psk;*.psa",
options={'HIDDEN'},
)
udk_option_smoothing_groups = bpy.types.Scene.udk_option_smoothing_groups
udk_option_clamp_uv = bpy.types.Scene.udk_option_clamp_uv
udk_option_verbose = bpy.types.Scene.udk_option_verbose
udk_option_filename_src = bpy.types.Scene.udk_option_filename_src
udk_option_export = bpy.types.Scene.udk_option_export
udk_option_scale = bpy.types.Scene.udk_option_scale
udk_option_rebuildobjects = bpy.types.Scene.udk_option_rebuildobjects
John Phan
committed
@classmethod
def poll(cls, context):
return context.active_object != None
def execute(self, context):
scene = bpy.context.scene
scene.udk_option_export_psk = (scene.udk_option_export == '0' or scene.udk_option_export == '2')
scene.udk_option_export_psa = (scene.udk_option_export == '1' or scene.udk_option_export == '2')
bpy.context.scene.udk_option_scale = self.udk_option_scale
bpy.context.scene.udk_option_rebuildobjects = self.udk_option_rebuildobjects
filepath = get_dst_path()
# cache settings
restore_frame = scene.frame_current
message = "Finish Export!"
try:
export(filepath)
except Error as err:
print(err.message)
message = err.message
# restore settings
scene.frame_set(restore_frame)
self.report({'WARNING', 'INFO'}, message)
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
wm.fileselect_add(self)
def menu_func(self, context):
default_path = os.path.splitext(bpy.data.filepath)[0] + ".psk"
self.layout.operator(ExportUDKAnimData.bl_idname, text="Skeleton Mesh / Animation Data (.psk/.psa)").filepath = default_path
#===========================================================================
# Entry
#===========================================================================
Brendon Murphy
committed
def register():
#print("REGISTER")
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_export.append(menu_func)
Brendon Murphy
committed
def unregister():
#print("UNREGISTER")
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_export.remove(menu_func)
Brendon Murphy
committed
if __name__ == "__main__":
#print("\n"*4)
print(header("UDK Export PSK/PSA 2.6", 'CENTER'))
register()
#loader
#filename = "D:/Projects/BlenderScripts/io_export_udk_psa_psk_alpha.py"
#exec(compile(open(filename).read(), filename, 'exec'))