pep8 cleanup
This commit is contained in:
@@ -699,5 +699,6 @@ class UpdateAnimData(bpy.types.Operator):
|
||||
if __name__ == "__main__":
|
||||
bpy.ops.anim.update_data_paths()
|
||||
|
||||
|
||||
def register():
|
||||
pass
|
||||
|
||||
@@ -82,9 +82,9 @@ def get_console(console_id):
|
||||
namespace["__builtins__"] = sys.modules["builtins"]
|
||||
namespace["bpy"] = bpy
|
||||
namespace["C"] = bpy.context
|
||||
|
||||
namespace.update(__import__("mathutils").__dict__) # from mathutils import *
|
||||
namespace.update(__import__("math").__dict__) # from math import *
|
||||
|
||||
namespace.update(__import__("mathutils").__dict__) # from mathutils import *
|
||||
namespace.update(__import__("math").__dict__) # from math import *
|
||||
|
||||
console = InteractiveConsole(locals=namespace, filename="<blender_console>")
|
||||
|
||||
@@ -186,7 +186,7 @@ def execute(context):
|
||||
|
||||
# restore the stdin
|
||||
sys.stdin = stdin_backup
|
||||
|
||||
|
||||
# execute any hooks
|
||||
for func, args in execute.hooks:
|
||||
func(*args)
|
||||
|
||||
@@ -34,7 +34,7 @@ class BvhImporter(bpy.types.Operator, ImportHelper):
|
||||
'''Load a OBJ Motion Capture File'''
|
||||
bl_idname = "import_anim.bvh"
|
||||
bl_label = "Import BVH"
|
||||
|
||||
|
||||
filename_ext = ".bvh"
|
||||
filter_glob = StringProperty(default="*.bvh", options={'HIDDEN'})
|
||||
|
||||
|
||||
@@ -30,19 +30,19 @@ from mathutils import Vector, Euler, Matrix
|
||||
|
||||
class bvh_node_class(object):
|
||||
__slots__ = (
|
||||
'name',# bvh joint name
|
||||
'parent',# bvh_node_class type or None for no parent
|
||||
'children',# a list of children of this type.
|
||||
'rest_head_world',# worldspace rest location for the head of this node
|
||||
'rest_head_local',# localspace rest location for the head of this node
|
||||
'rest_tail_world',# # worldspace rest location for the tail of this node
|
||||
'rest_tail_local',# # worldspace rest location for the tail of this node
|
||||
'channels',# list of 6 ints, -1 for an unused channel, otherwise an index for the BVH motion data lines, lock triple then rot triple
|
||||
'rot_order',# a triple of indicies as to the order rotation is applied. [0,1,2] is x/y/z - [None, None, None] if no rotation.
|
||||
'anim_data',# a list one tuple's one for each frame. (locx, locy, locz, rotx, roty, rotz)
|
||||
'has_loc',# Conveinience function, bool, same as (channels[0]!=-1 or channels[1]!=-1 channels[2]!=-1)
|
||||
'has_rot',# Conveinience function, bool, same as (channels[3]!=-1 or channels[4]!=-1 channels[5]!=-1)
|
||||
'temp')# use this for whatever you want
|
||||
'name', # bvh joint name
|
||||
'parent', # bvh_node_class type or None for no parent
|
||||
'children', # a list of children of this type.
|
||||
'rest_head_world', # worldspace rest location for the head of this node
|
||||
'rest_head_local', # localspace rest location for the head of this node
|
||||
'rest_tail_world', # worldspace rest location for the tail of this node
|
||||
'rest_tail_local', # worldspace rest location for the tail of this node
|
||||
'channels', # list of 6 ints, -1 for an unused channel, otherwise an index for the BVH motion data lines, lock triple then rot triple
|
||||
'rot_order', # a triple of indicies as to the order rotation is applied. [0,1,2] is x/y/z - [None, None, None] if no rotation.
|
||||
'anim_data', # a list one tuple's one for each frame. (locx, locy, locz, rotx, roty, rotz)
|
||||
'has_loc', # Conveinience function, bool, same as (channels[0]!=-1 or channels[1]!=-1 channels[2]!=-1)
|
||||
'has_rot', # Conveinience function, bool, same as (channels[3]!=-1 or channels[4]!=-1 channels[5]!=-1)
|
||||
'temp') # use this for whatever you want
|
||||
|
||||
def __init__(self, name, rest_head_world, rest_head_local, parent, channels, rot_order):
|
||||
self.name = name
|
||||
@@ -58,7 +58,6 @@ class bvh_node_class(object):
|
||||
self.has_loc = channels[0] != -1 or channels[1] != -1 or channels[2] != -1
|
||||
self.has_rot = channels[3] != -1 or channels[4] != -1 or channels[5] != -1
|
||||
|
||||
|
||||
self.children = []
|
||||
|
||||
# list of 6 length tuples: (lx,ly,lz, rx,ry,rz)
|
||||
@@ -105,9 +104,7 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
|
||||
# Split by whitespace.
|
||||
file_lines = [ll for ll in [l.split() for l in file_lines] if ll]
|
||||
|
||||
|
||||
# Create Hirachy as empties
|
||||
|
||||
if file_lines[0][0].lower() == 'hierarchy':
|
||||
#print 'Importing the BVH Hierarchy for:', file_path
|
||||
pass
|
||||
@@ -119,9 +116,8 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
|
||||
|
||||
channelIndex = -1
|
||||
|
||||
|
||||
lineIdx = 0 # An index for the file.
|
||||
while lineIdx < len(file_lines) -1:
|
||||
lineIdx = 0 # An index for the file.
|
||||
while lineIdx < len(file_lines) - 1:
|
||||
#...
|
||||
if file_lines[lineIdx][0].lower() == 'root' or file_lines[lineIdx][0].lower() == 'joint':
|
||||
|
||||
@@ -137,9 +133,9 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
|
||||
|
||||
#print '%snode: %s, parent: %s' % (len(bvh_nodes_serial) * ' ', name, bvh_nodes_serial[-1])
|
||||
|
||||
lineIdx += 2 # Incriment to the next line (Offset)
|
||||
lineIdx += 2 # Incriment to the next line (Offset)
|
||||
rest_head_local = Vector((float(file_lines[lineIdx][1]), float(file_lines[lineIdx][2]), float(file_lines[lineIdx][3]))) * GLOBAL_SCALE
|
||||
lineIdx += 1 # Incriment to the next line (Channels)
|
||||
lineIdx += 1 # Incriment to the next line (Channels)
|
||||
|
||||
# newChannel[Xposition, Yposition, Zposition, Xrotation, Yrotation, Zrotation]
|
||||
# newChannel references indecies to the motiondata,
|
||||
@@ -150,7 +146,7 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
|
||||
rot_count = 0
|
||||
for channel in file_lines[lineIdx][2:]:
|
||||
channel = channel.lower()
|
||||
channelIndex += 1 # So the index points to the right channel
|
||||
channelIndex += 1 # So the index points to the right channel
|
||||
if channel == 'xposition':
|
||||
my_channel[0] = channelIndex
|
||||
elif channel == 'yposition':
|
||||
@@ -173,8 +169,7 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
|
||||
|
||||
channels = file_lines[lineIdx][2:]
|
||||
|
||||
my_parent = bvh_nodes_serial[-1] # account for none
|
||||
|
||||
my_parent = bvh_nodes_serial[-1] # account for none
|
||||
|
||||
# Apply the parents offset accumletivly
|
||||
if my_parent is None:
|
||||
@@ -188,24 +183,23 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
|
||||
bvh_nodes_serial.append(bvh_node)
|
||||
|
||||
# Account for an end node
|
||||
if file_lines[lineIdx][0].lower() == 'end' and file_lines[lineIdx][1].lower() == 'site': # There is somtimes a name after 'End Site' but we will ignore it.
|
||||
lineIdx += 2 # Incriment to the next line (Offset)
|
||||
if file_lines[lineIdx][0].lower() == 'end' and file_lines[lineIdx][1].lower() == 'site': # There is somtimes a name after 'End Site' but we will ignore it.
|
||||
lineIdx += 2 # Incriment to the next line (Offset)
|
||||
rest_tail = Vector((float(file_lines[lineIdx][1]), float(file_lines[lineIdx][2]), float(file_lines[lineIdx][3]))) * GLOBAL_SCALE
|
||||
|
||||
bvh_nodes_serial[-1].rest_tail_world = bvh_nodes_serial[-1].rest_head_world + rest_tail
|
||||
bvh_nodes_serial[-1].rest_tail_local = bvh_nodes_serial[-1].rest_head_local + rest_tail
|
||||
|
||||
|
||||
# Just so we can remove the Parents in a uniform way- End end never has kids
|
||||
# so this is a placeholder
|
||||
bvh_nodes_serial.append(None)
|
||||
|
||||
if len(file_lines[lineIdx]) == 1 and file_lines[lineIdx][0] == '}': # == ['}']
|
||||
bvh_nodes_serial.pop() # Remove the last item
|
||||
if len(file_lines[lineIdx]) == 1 and file_lines[lineIdx][0] == '}': # == ['}']
|
||||
bvh_nodes_serial.pop() # Remove the last item
|
||||
|
||||
if len(file_lines[lineIdx]) == 1 and file_lines[lineIdx][0].lower() == 'motion':
|
||||
#print '\nImporting motion data'
|
||||
lineIdx += 3 # Set the cursor to the first frame
|
||||
lineIdx += 3 # Set the cursor to the first frame
|
||||
break
|
||||
|
||||
lineIdx += 1
|
||||
@@ -307,7 +301,7 @@ def bvh_node_dict2objects(context, bvh_nodes, IMPORT_START_FRAME=1, IMPORT_LOOP=
|
||||
|
||||
# Parent the objects
|
||||
for bvh_node in bvh_nodes.values():
|
||||
bvh_node.temp.makeParent([bvh_node_child.temp for bvh_node_child in bvh_node.children], 1, 0) # ojbs, noninverse, 1 = not fast.
|
||||
bvh_node.temp.makeParent([bvh_node_child.temp for bvh_node_child in bvh_node.children], 1, 0) # ojbs, noninverse, 1 = not fast.
|
||||
|
||||
# Offset
|
||||
for bvh_node in bvh_nodes.values():
|
||||
@@ -318,7 +312,7 @@ def bvh_node_dict2objects(context, bvh_nodes, IMPORT_START_FRAME=1, IMPORT_LOOP=
|
||||
for name, bvh_node in bvh_nodes.items():
|
||||
if not bvh_node.children:
|
||||
ob_end = add_ob(name + '_end')
|
||||
bvh_node.temp.makeParent([ob_end], 1, 0) # ojbs, noninverse, 1 = not fast.
|
||||
bvh_node.temp.makeParent([ob_end], 1, 0) # ojbs, noninverse, 1 = not fast.
|
||||
ob_end.loc = bvh_node.rest_tail_local
|
||||
|
||||
|
||||
@@ -334,7 +328,7 @@ def bvh_node_dict2objects(context, bvh_nodes, IMPORT_START_FRAME=1, IMPORT_LOOP=
|
||||
|
||||
bvh_node.temp.rot = rx, ry, rz
|
||||
|
||||
bvh_node.temp.insertIpoKey(Blender.Object.IpoKeyTypes.LOCROT) # XXX invalid
|
||||
bvh_node.temp.insertIpoKey(Blender.Object.IpoKeyTypes.LOCROT) # XXX invalid
|
||||
|
||||
scn.update(1)
|
||||
return objects
|
||||
@@ -396,7 +390,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM
|
||||
if (bone.head - bone.tail).length < 0.001:
|
||||
if bvh_node.parent:
|
||||
ofs = bvh_node.parent.rest_head_local - bvh_node.parent.rest_tail_local
|
||||
if ofs.length: # is our parent zero length also?? unlikely
|
||||
if ofs.length: # is our parent zero length also?? unlikely
|
||||
bone.tail = bone.tail + ofs
|
||||
else:
|
||||
bone.tail.y = bone.tail.y + average_bone_length
|
||||
@@ -446,7 +440,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM
|
||||
(2, 1, 0): 'ZYX'}
|
||||
|
||||
for bvh_node in bvh_nodes.values():
|
||||
bone_name = bvh_node.temp # may not be the same name as the bvh_node, could have been shortened.
|
||||
bone_name = bvh_node.temp # may not be the same name as the bvh_node, could have been shortened.
|
||||
pose_bone = pose_bones[bone_name]
|
||||
pose_bone.rotation_mode = eul_order_lookup[tuple(bvh_node.rot_order)]
|
||||
|
||||
@@ -459,8 +453,8 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM
|
||||
|
||||
context.scene.update()
|
||||
|
||||
bpy.ops.pose.select_all() # set
|
||||
bpy.ops.anim.keyframe_insert_menu(type=-4) # XXX - -4 ???
|
||||
bpy.ops.pose.select_all() # set
|
||||
bpy.ops.anim.keyframe_insert_menu(type=-4) # XXX - -4 ???
|
||||
|
||||
|
||||
#XXX action = Blender.Armature.NLA.NewAction("Action")
|
||||
@@ -475,7 +469,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM
|
||||
# Replace the bvh_node.temp (currently an editbone)
|
||||
# With a tuple (pose_bone, armature_bone, bone_rest_matrix, bone_rest_matrix_inv)
|
||||
for bvh_node in bvh_nodes.values():
|
||||
bone_name = bvh_node.temp # may not be the same name as the bvh_node, could have been shortened.
|
||||
bone_name = bvh_node.temp # may not be the same name as the bvh_node, could have been shortened.
|
||||
pose_bone = pose_bones[bone_name]
|
||||
rest_bone = arm_data.bones[bone_name]
|
||||
bone_rest_matrix = rest_bone.matrix_local.rotation_part()
|
||||
@@ -498,7 +492,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM
|
||||
prev_euler = [Euler() for i in range(len(bvh_nodes))]
|
||||
|
||||
# Animate the data, the last used bvh_node will do since they all have the same number of frames
|
||||
for frame_current in range(len(bvh_node.anim_data)-1): # skip the first frame (rest frame)
|
||||
for frame_current in range(len(bvh_node.anim_data) - 1): # skip the first frame (rest frame)
|
||||
# print frame_current
|
||||
|
||||
# if frame_current==40: # debugging
|
||||
@@ -537,7 +531,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM
|
||||
|
||||
for cu in action.fcurves:
|
||||
if IMPORT_LOOP:
|
||||
pass # 2.5 doenst have cyclic now?
|
||||
pass # 2.5 doenst have cyclic now?
|
||||
|
||||
for bez in cu.keyframe_points:
|
||||
bez.interpolation = 'LINEAR'
|
||||
@@ -564,5 +558,5 @@ def load(operator, context, filepath="", rotate_mode='NATIVE', scale=1.0, use_cy
|
||||
IMPORT_LOOP=use_cyclic)
|
||||
|
||||
print('Done in %.4f\n' % (time.time() - t1))
|
||||
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -32,14 +32,13 @@ import os
|
||||
|
||||
|
||||
def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_uv_coords=True, use_colors=True):
|
||||
|
||||
|
||||
def rvec3d(v):
|
||||
return round(v[0], 6), round(v[1], 6), round(v[2], 6)
|
||||
|
||||
|
||||
def rvec2d(v):
|
||||
return round(v[0], 6), round(v[1], 6)
|
||||
|
||||
|
||||
scene = context.scene
|
||||
obj = context.object
|
||||
|
||||
@@ -94,15 +93,14 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
|
||||
# incase
|
||||
color = uvcoord = uvcoord_key = normal = normal_key = None
|
||||
|
||||
mesh_verts = mesh.vertices # save a lookup
|
||||
ply_verts = [] # list of dictionaries
|
||||
mesh_verts = mesh.vertices # save a lookup
|
||||
ply_verts = [] # list of dictionaries
|
||||
# vdict = {} # (index, normal, uv) -> new index
|
||||
vdict = [{} for i in range(len(mesh_verts))]
|
||||
ply_faces = [[] for f in range(len(mesh.faces))]
|
||||
vert_count = 0
|
||||
for i, f in enumerate(mesh.faces):
|
||||
|
||||
|
||||
smooth = f.use_smooth
|
||||
if not smooth:
|
||||
normal = tuple(f.normal)
|
||||
@@ -110,7 +108,7 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
|
||||
|
||||
if faceUV:
|
||||
uv = active_uv_layer[i]
|
||||
uv = uv.uv1, uv.uv2, uv.uv3, uv.uv4 # XXX - crufty :/
|
||||
uv = uv.uv1, uv.uv2, uv.uv3, uv.uv4 # XXX - crufty :/
|
||||
if vertexColors:
|
||||
col = active_col_layer[i]
|
||||
col = col.color1[:], col.color2[:], col.color3[:], col.color4[:]
|
||||
@@ -136,13 +134,12 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
|
||||
color = col[j]
|
||||
color = int(color[0] * 255.0), int(color[1] * 255.0), int(color[2] * 255.0)
|
||||
|
||||
|
||||
key = normal_key, uvcoord_key, color
|
||||
|
||||
vdict_local = vdict[vidx]
|
||||
pf_vidx = vdict_local.get(key) # Will be None initially
|
||||
pf_vidx = vdict_local.get(key) # Will be None initially
|
||||
|
||||
if pf_vidx is None: # same as vdict_local.has_key(key)
|
||||
if pf_vidx is None: # same as vdict_local.has_key(key)
|
||||
pf_vidx = vdict_local[key] = vert_count
|
||||
ply_verts.append((vidx, normal, uvcoord, color))
|
||||
vert_count += 1
|
||||
@@ -176,13 +173,13 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
|
||||
file.write('end_header\n')
|
||||
|
||||
for i, v in enumerate(ply_verts):
|
||||
file.write('%.6f %.6f %.6f ' % mesh_verts[v[0]].co[:]) # co
|
||||
file.write('%.6f %.6f %.6f ' % mesh_verts[v[0]].co[:]) # co
|
||||
if use_normals:
|
||||
file.write('%.6f %.6f %.6f ' % v[1]) # no
|
||||
file.write('%.6f %.6f %.6f ' % v[1]) # no
|
||||
if use_uv_coords:
|
||||
file.write('%.6f %.6f ' % v[2]) # uv
|
||||
file.write('%.6f %.6f ' % v[2]) # uv
|
||||
if use_colors:
|
||||
file.write('%u %u %u' % v[3]) # col
|
||||
file.write('%u %u %u' % v[3]) # col
|
||||
file.write('\n')
|
||||
|
||||
for pf in ply_faces:
|
||||
@@ -202,5 +199,5 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
|
||||
if is_editmode:
|
||||
Blender.Window.EditMode(1, '', 0)
|
||||
"""
|
||||
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -66,9 +66,11 @@ class Export3DS(bpy.types.Operator, ExportHelper):
|
||||
def menu_func_export(self, context):
|
||||
self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)")
|
||||
|
||||
|
||||
def menu_func_import(self, context):
|
||||
self.layout.operator(Import3DS.bl_idname, text="3D Studio (.3ds)")
|
||||
|
||||
|
||||
def register():
|
||||
bpy.types.INFO_MT_file_import.append(menu_func_import)
|
||||
bpy.types.INFO_MT_file_export.append(menu_func_export)
|
||||
@@ -84,4 +86,3 @@ def unregister():
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
||||
|
||||
@@ -40,19 +40,18 @@ class ImportOBJ(bpy.types.Operator, ImportHelper):
|
||||
filename_ext = ".obj"
|
||||
filter_glob = StringProperty(default="*.obj;*.mtl", options={'HIDDEN'})
|
||||
|
||||
CREATE_SMOOTH_GROUPS = BoolProperty(name="Smooth Groups", description="Surround smooth groups by sharp edges", default= True)
|
||||
CREATE_FGONS = BoolProperty(name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default= True)
|
||||
CREATE_EDGES = BoolProperty(name="Lines as Edges", description="Import lines and faces with 2 verts as edge", default= True)
|
||||
SPLIT_OBJECTS = BoolProperty(name="Object", description="Import OBJ Objects into Blender Objects", default= True)
|
||||
SPLIT_GROUPS = BoolProperty(name="Group", description="Import OBJ Groups into Blender Objects", default= True)
|
||||
CREATE_SMOOTH_GROUPS = BoolProperty(name="Smooth Groups", description="Surround smooth groups by sharp edges", default=True)
|
||||
CREATE_FGONS = BoolProperty(name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default=True)
|
||||
CREATE_EDGES = BoolProperty(name="Lines as Edges", description="Import lines and faces with 2 verts as edge", default=True)
|
||||
SPLIT_OBJECTS = BoolProperty(name="Object", description="Import OBJ Objects into Blender Objects", default=True)
|
||||
SPLIT_GROUPS = BoolProperty(name="Group", description="Import OBJ Groups into Blender Objects", default=True)
|
||||
# old comment: only used for user feedback
|
||||
# disabled this option because in old code a handler for it disabled SPLIT* params, it's not passed to load_obj
|
||||
# KEEP_VERT_ORDER = BoolProperty(name="Keep Vert Order", description="Keep vert and face order, disables split options, enable for morph targets", default= True)
|
||||
ROTATE_X90 = BoolProperty(name="-X90", description="Rotate X 90.", default= True)
|
||||
ROTATE_X90 = BoolProperty(name="-X90", description="Rotate X 90.", default=True)
|
||||
CLAMP_SIZE = FloatProperty(name="Clamp Scale", description="Clamp the size to this maximum (Zero to Disable)", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=0.0)
|
||||
POLYGROUPS = BoolProperty(name="Poly Groups", description="Import OBJ groups as vertex groups.", default= True)
|
||||
IMAGE_SEARCH = BoolProperty(name="Image Search", description="Search subdirs for any assosiated images (Warning, may be slow)", default= True)
|
||||
|
||||
POLYGROUPS = BoolProperty(name="Poly Groups", description="Import OBJ groups as vertex groups.", default=True)
|
||||
IMAGE_SEARCH = BoolProperty(name="Image Search", description="Search subdirs for any assosiated images (Warning, may be slow)", default=True)
|
||||
|
||||
def execute(self, context):
|
||||
# print("Selected: " + context.active_object.name)
|
||||
@@ -74,19 +73,19 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
|
||||
# to the class instance from the operator settings before calling.
|
||||
|
||||
# context group
|
||||
use_selection = BoolProperty(name="Selection Only", description="Export selected objects only", default= False)
|
||||
use_all_scenes = BoolProperty(name="All Scenes", description="", default= False)
|
||||
use_animation = BoolProperty(name="Animation", description="", default= False)
|
||||
use_selection = BoolProperty(name="Selection Only", description="Export selected objects only", default=False)
|
||||
use_all_scenes = BoolProperty(name="All Scenes", description="", default=False)
|
||||
use_animation = BoolProperty(name="Animation", description="", default=False)
|
||||
|
||||
# object group
|
||||
use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers (preview resolution)", default= True)
|
||||
use_rotate_x90 = BoolProperty(name="Rotate X90", description="", default= True)
|
||||
use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers (preview resolution)", default=True)
|
||||
use_rotate_x90 = BoolProperty(name="Rotate X90", description="", default=True)
|
||||
|
||||
# extra data group
|
||||
use_edges = BoolProperty(name="Edges", description="", default=True)
|
||||
use_normals = BoolProperty(name="Normals", description="", default=False)
|
||||
use_hq_normals = BoolProperty(name="High Quality Normals", description="", default=True)
|
||||
use_uvs = BoolProperty(name="UVs", description="", default= True)
|
||||
use_uvs = BoolProperty(name="UVs", description="", default=True)
|
||||
use_materials = BoolProperty(name="Materials", description="", default=True)
|
||||
copy_images = BoolProperty(name="Copy Images", description="", default=False)
|
||||
use_triangles = BoolProperty(name="Triangulate", description="", default=False)
|
||||
@@ -94,11 +93,10 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
|
||||
use_nurbs = BoolProperty(name="Nurbs", description="", default=False)
|
||||
|
||||
# grouping group
|
||||
use_blen_objects = BoolProperty(name="Objects as OBJ Objects", description="", default= True)
|
||||
group_by_object = BoolProperty(name="Objects as OBJ Groups ", description="", default= False)
|
||||
group_by_material = BoolProperty(name="Material Groups", description="", default= False)
|
||||
keep_vertex_order = BoolProperty(name="Keep Vertex Order", description="", default= False)
|
||||
|
||||
use_blen_objects = BoolProperty(name="Objects as OBJ Objects", description="", default=True)
|
||||
group_by_object = BoolProperty(name="Objects as OBJ Groups ", description="", default=False)
|
||||
group_by_material = BoolProperty(name="Material Groups", description="", default=False)
|
||||
keep_vertex_order = BoolProperty(name="Keep Vertex Order", description="", default=False)
|
||||
|
||||
def execute(self, context):
|
||||
from . import export_obj
|
||||
@@ -117,6 +115,7 @@ def register():
|
||||
bpy.types.INFO_MT_file_import.append(menu_func_import)
|
||||
bpy.types.INFO_MT_file_export.append(menu_func_export)
|
||||
|
||||
|
||||
def unregister():
|
||||
bpy.types.INFO_MT_file_import.remove(menu_func_import)
|
||||
bpy.types.INFO_MT_file_export.remove(menu_func_export)
|
||||
|
||||
@@ -768,7 +768,7 @@ def _write(context, filepath,
|
||||
else:
|
||||
objects = scene.objects
|
||||
|
||||
full_path= ''.join(context_name)
|
||||
full_path = ''.join(context_name)
|
||||
|
||||
# erm... bit of a problem here, this can overwrite files when exporting frames. not too bad.
|
||||
# EXPORT THE FILE.
|
||||
@@ -789,7 +789,6 @@ def _write(context, filepath,
|
||||
EXPORT_POLYGROUPS,
|
||||
EXPORT_CURVE_AS_NURBS)
|
||||
|
||||
|
||||
scene.frame_set(orig_frame, 0.0)
|
||||
|
||||
# Restore old active scene.
|
||||
@@ -825,7 +824,7 @@ def save(operator, context, filepath="",
|
||||
use_animation=False,
|
||||
):
|
||||
|
||||
_write(context, filepath,
|
||||
_write(context, filepath,
|
||||
EXPORT_TRI=use_triangles,
|
||||
EXPORT_EDGES=use_edges,
|
||||
EXPORT_NORMALS=use_normals,
|
||||
|
||||
@@ -58,11 +58,12 @@ class ImportMDD(bpy.types.Operator, ImportHelper):
|
||||
from . import import_mdd
|
||||
return import_mdd.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
|
||||
|
||||
|
||||
class ExportMDD(bpy.types.Operator, ExportHelper):
|
||||
'''Animated mesh to MDD vertex keyframe file'''
|
||||
bl_idname = "export_shape.mdd"
|
||||
bl_label = "Export MDD"
|
||||
|
||||
|
||||
filename_ext = ".mdd"
|
||||
filter_glob = StringProperty(default="*.mdd", options={'HIDDEN'})
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ def zero_file(filepath):
|
||||
If a file fails, this replaces it with 1 char, better not remove it?
|
||||
'''
|
||||
file = open(filepath, 'w')
|
||||
file.write('\n') # apparently macosx needs some data in a blank file?
|
||||
file.write('\n') # apparently macosx needs some data in a blank file?
|
||||
file.close()
|
||||
|
||||
|
||||
@@ -84,13 +84,13 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
|
||||
|
||||
numframes = frame_end - frame_start + 1
|
||||
fps = float(fps)
|
||||
f = open(filepath, 'wb') #no Errors yet:Safe to create file
|
||||
f = open(filepath, 'wb') # no Errors yet:Safe to create file
|
||||
|
||||
# Write the header
|
||||
f.write(pack(">2i", numframes, numverts))
|
||||
|
||||
# Write the frame times (should we use the time IPO??)
|
||||
f.write(pack(">%df" % (numframes), *[frame / fps for frame in range(numframes)])) # seconds
|
||||
f.write(pack(">%df" % (numframes), *[frame / fps for frame in range(numframes)])) # seconds
|
||||
|
||||
#rest frame needed to keep frames in sync
|
||||
"""
|
||||
@@ -102,7 +102,7 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
|
||||
me.transform(mat_flip * obj.matrix_world)
|
||||
f.write(pack(">%df" % (numverts * 3), *[axis for v in me.vertices for axis in v.co]))
|
||||
|
||||
for frame in range(frame_start, frame_end + 1):#in order to start at desired frame
|
||||
for frame in range(frame_start, frame_end + 1): # in order to start at desired frame
|
||||
"""
|
||||
Blender.Set('curframe', frame)
|
||||
me_tmp.getFromObject(obj.name)
|
||||
@@ -127,5 +127,5 @@ def save(operator, context, filepath="", frame_start=1, frame_end=300, fps=25):
|
||||
Blender.Set('curframe', orig_frame)
|
||||
"""
|
||||
scene.frame_set(orig_frame)
|
||||
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -36,10 +36,10 @@ from struct import unpack
|
||||
|
||||
|
||||
def load(operator, context, filepath, frame_start=0, frame_step=1):
|
||||
|
||||
|
||||
scene = context.scene
|
||||
obj = context.object
|
||||
|
||||
|
||||
print('\n\nimporting mdd %r' % filepath)
|
||||
|
||||
if bpy.ops.object.mode_set.poll():
|
||||
@@ -68,37 +68,34 @@ def load(operator, context, filepath, frame_start=0, frame_step=1):
|
||||
new_shapekey.name = ("frame_%.4d" % fr)
|
||||
new_shapekey_name = new_shapekey.name
|
||||
|
||||
obj.active_shape_key_index = len(obj.data.shape_keys.keys)-1
|
||||
index = len(obj.data.shape_keys.keys)-1
|
||||
obj.active_shape_key_index = len(obj.data.shape_keys.keys) - 1
|
||||
index = len(obj.data.shape_keys.keys) - 1
|
||||
obj.show_only_shape_key = True
|
||||
|
||||
verts = obj.data.shape_keys.keys[len(obj.data.shape_keys.keys)-1].data
|
||||
verts = obj.data.shape_keys.keys[len(obj.data.shape_keys.keys) - 1].data
|
||||
|
||||
|
||||
for v in verts: # 12 is the size of 3 floats
|
||||
for v in verts: # 12 is the size of 3 floats
|
||||
v.co[:] = unpack('>3f', file.read(12))
|
||||
#me.update()
|
||||
obj.show_only_shape_key = False
|
||||
|
||||
|
||||
# insert keyframes
|
||||
shape_keys = obj.data.shape_keys
|
||||
|
||||
scene.frame_current -= 1
|
||||
obj.data.shape_keys.keys[index].value = 0.0
|
||||
shape_keys.keys[len(obj.data.shape_keys.keys)-1].keyframe_insert("value")
|
||||
shape_keys.keys[len(obj.data.shape_keys.keys) - 1].keyframe_insert("value")
|
||||
|
||||
scene.frame_current += 1
|
||||
obj.data.shape_keys.keys[index].value = 1.0
|
||||
shape_keys.keys[len(obj.data.shape_keys.keys)-1].keyframe_insert("value")
|
||||
shape_keys.keys[len(obj.data.shape_keys.keys) - 1].keyframe_insert("value")
|
||||
|
||||
scene.frame_current += 1
|
||||
obj.data.shape_keys.keys[index].value = 0.0
|
||||
shape_keys.keys[len(obj.data.shape_keys.keys)-1].keyframe_insert("value")
|
||||
shape_keys.keys[len(obj.data.shape_keys.keys) - 1].keyframe_insert("value")
|
||||
|
||||
obj.data.update()
|
||||
|
||||
|
||||
for i in range(frames):
|
||||
UpdateMesh(obj, i)
|
||||
|
||||
|
||||
@@ -552,7 +552,6 @@ class IsolateTypeRender(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
||||
class ClearAllRestrictRender(bpy.types.Operator):
|
||||
'''Reveal all render objects by setting the hide render flag'''
|
||||
bl_idname = "object.hide_render_clear_all"
|
||||
|
||||
@@ -123,21 +123,21 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
|
||||
|
||||
# Align Mode
|
||||
|
||||
if relative_to == 'OPT_4': # Active relative
|
||||
if relative_to == 'OPT_4': # Active relative
|
||||
if align_mode == 'OPT_1':
|
||||
obj_x = obj_loc[0] - negative_x - size_active_x
|
||||
|
||||
elif align_mode == 'OPT_3':
|
||||
obj_x = obj_loc[0] - positive_x + size_active_x
|
||||
|
||||
else: # Everything else relative
|
||||
else: # Everything else relative
|
||||
if align_mode == 'OPT_1':
|
||||
obj_x = obj_loc[0] - negative_x
|
||||
|
||||
elif align_mode == 'OPT_3':
|
||||
obj_x = obj_loc[0] - positive_x
|
||||
|
||||
if align_mode == 'OPT_2': # All relative
|
||||
if align_mode == 'OPT_2': # All relative
|
||||
obj_x = obj_loc[0] - center_x
|
||||
|
||||
# Relative To
|
||||
@@ -156,26 +156,24 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
|
||||
|
||||
obj.location[0] = loc_x
|
||||
|
||||
|
||||
if align_y:
|
||||
|
||||
# Align Mode
|
||||
|
||||
if relative_to == 'OPT_4': # Active relative
|
||||
if relative_to == 'OPT_4': # Active relative
|
||||
if align_mode == 'OPT_1':
|
||||
obj_y = obj_loc[1] - negative_y - size_active_y
|
||||
|
||||
elif align_mode == 'OPT_3':
|
||||
obj_y = obj_loc[1] - positive_y + size_active_y
|
||||
|
||||
else: # Everything else relative
|
||||
else: # Everything else relative
|
||||
if align_mode == 'OPT_1':
|
||||
obj_y = obj_loc[1] - negative_y
|
||||
|
||||
elif align_mode == 'OPT_3':
|
||||
obj_y = obj_loc[1] - positive_y
|
||||
|
||||
if align_mode == 'OPT_2': # All relative
|
||||
if align_mode == 'OPT_2': # All relative
|
||||
obj_y = obj_loc[1] - center_y
|
||||
|
||||
# Relative To
|
||||
@@ -194,26 +192,23 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
|
||||
|
||||
obj.location[1] = loc_y
|
||||
|
||||
|
||||
if align_z:
|
||||
|
||||
# Align Mode
|
||||
|
||||
if relative_to == 'OPT_4': # Active relative
|
||||
if relative_to == 'OPT_4': # Active relative
|
||||
if align_mode == 'OPT_1':
|
||||
obj_z = obj_loc[2] - negative_z - size_active_z
|
||||
|
||||
elif align_mode == 'OPT_3':
|
||||
obj_z = obj_loc[2] - positive_z + size_active_z
|
||||
|
||||
else: # Everything else relative
|
||||
else: # Everything else relative
|
||||
if align_mode == 'OPT_1':
|
||||
obj_z = obj_loc[2] - negative_z
|
||||
|
||||
elif align_mode == 'OPT_3':
|
||||
obj_z = obj_loc[2] - positive_z
|
||||
|
||||
if align_mode == 'OPT_2': # All relative
|
||||
if align_mode == 'OPT_2': # All relative
|
||||
obj_z = obj_loc[2] - center_z
|
||||
|
||||
# Relative To
|
||||
|
||||
@@ -86,6 +86,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even):
|
||||
|
||||
from bpy.props import *
|
||||
|
||||
|
||||
class RandomizeLocRotSize(bpy.types.Operator):
|
||||
'''Randomize objects loc/rot/scale'''
|
||||
bl_idname = "object.randomize_transform"
|
||||
|
||||
@@ -29,7 +29,7 @@ class AddPresetBase():
|
||||
- preset_subdir '''
|
||||
# bl_idname = "script.preset_base_add"
|
||||
# bl_label = "Add a Python Preset"
|
||||
bl_options = {'REGISTER'} # only because invoke_props_popup requires.
|
||||
bl_options = {'REGISTER'} # only because invoke_props_popup requires.
|
||||
|
||||
name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen=64, default="")
|
||||
remove_active = bpy.props.BoolProperty(default=False, options={'HIDDEN'})
|
||||
@@ -42,13 +42,13 @@ class AddPresetBase():
|
||||
|
||||
def execute(self, context):
|
||||
import os
|
||||
|
||||
|
||||
if hasattr(self, "pre_cb"):
|
||||
self.pre_cb(context)
|
||||
|
||||
|
||||
preset_menu_class = getattr(bpy.types, self.preset_menu)
|
||||
|
||||
if not self.remove_active:
|
||||
if not self.remove_active:
|
||||
|
||||
if not self.name:
|
||||
return {'FINISHED'}
|
||||
@@ -62,7 +62,7 @@ class AddPresetBase():
|
||||
return {'CANCELLED'}
|
||||
|
||||
filepath = os.path.join(target_path, filename) + ".py"
|
||||
|
||||
|
||||
if hasattr(self, "add"):
|
||||
self.add(context, filepath)
|
||||
else:
|
||||
@@ -352,6 +352,7 @@ class WM_MT_operator_presets(bpy.types.Menu):
|
||||
|
||||
preset_operator = "script.execute_preset"
|
||||
|
||||
|
||||
def register():
|
||||
pass
|
||||
|
||||
|
||||
@@ -21,11 +21,12 @@
|
||||
import bpy
|
||||
from bpy.props import *
|
||||
|
||||
|
||||
def write_svg(fw, mesh, image_width, image_height, face_iter):
|
||||
# for making an XML compatible string
|
||||
from xml.sax.saxutils import escape
|
||||
from os.path import basename
|
||||
|
||||
|
||||
fw('<?xml version="1.0" standalone="no"?>\n')
|
||||
fw('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" \n')
|
||||
fw(' "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')
|
||||
@@ -126,7 +127,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
for f in mesh_source.faces:
|
||||
tot_verts += len(f.vertices)
|
||||
|
||||
|
||||
faces_source = mesh_source.faces
|
||||
|
||||
# get unique UV's incase there are many overlapping which slow down filling.
|
||||
@@ -145,7 +145,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
mesh_new_materials = []
|
||||
mesh_new_face_vertices = []
|
||||
|
||||
|
||||
current_vert = 0
|
||||
|
||||
for face_data in face_hash_3:
|
||||
@@ -167,7 +166,7 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
mesh.faces.foreach_set("material_index", mesh_new_materials)
|
||||
|
||||
mesh.update(calc_edges=True)
|
||||
|
||||
|
||||
obj_solid = bpy.data.objects.new("uv_temp_solid", mesh)
|
||||
obj_wire = bpy.data.objects.new("uv_temp_wire", mesh)
|
||||
base_solid = scene.objects.link(obj_solid)
|
||||
@@ -177,11 +176,10 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
|
||||
# place behind the wire
|
||||
obj_solid.location = 0, 0, -1
|
||||
|
||||
|
||||
obj_wire.material_slots[0].link = 'OBJECT'
|
||||
obj_wire.material_slots[0].material = material_wire
|
||||
|
||||
|
||||
|
||||
# setup the camera
|
||||
cam = bpy.data.cameras.new("uv_temp")
|
||||
cam.type = 'ORTHO'
|
||||
@@ -204,7 +202,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
material_wire.use_shadeless = True
|
||||
material_wire.diffuse_color = 0, 0, 0
|
||||
|
||||
|
||||
# scene render settings
|
||||
scene.render.use_raytrace = False
|
||||
scene.render.alpha_mode = 'STRAIGHT'
|
||||
@@ -217,11 +214,11 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
if image_width > image_height:
|
||||
scene.render.pixel_aspect_y = image_width / image_height
|
||||
elif image_width < image_height:
|
||||
scene.render.pixel_aspect_x = image_height /image_width
|
||||
|
||||
scene.render.pixel_aspect_x = image_height / image_width
|
||||
|
||||
scene.frame_start = 1
|
||||
scene.frame_end = 1
|
||||
|
||||
|
||||
scene.render.file_format = 'PNG'
|
||||
scene.render.filepath = filepath
|
||||
|
||||
@@ -236,13 +233,12 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
|
||||
bpy.data.cameras.remove(cam)
|
||||
bpy.data.meshes.remove(mesh)
|
||||
|
||||
|
||||
bpy.data.materials.remove(material_wire)
|
||||
for mat_solid in material_solids:
|
||||
bpy.data.materials.remove(mat_solid)
|
||||
|
||||
|
||||
|
||||
class ExportUVLayout(bpy.types.Operator):
|
||||
"""Export UV layout to file"""
|
||||
|
||||
@@ -328,7 +324,6 @@ class ExportUVLayout(bpy.types.Operator):
|
||||
if is_editmode:
|
||||
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
|
||||
|
||||
|
||||
mesh = obj.data
|
||||
|
||||
mode = self.mode
|
||||
|
||||
@@ -85,10 +85,10 @@ class BRUSH_OT_set_active_number(bpy.types.Operator):
|
||||
number = IntProperty(name="number",
|
||||
description="Brush number")
|
||||
|
||||
_attr_dict = {"sculpt" : "use_paint_sculpt",
|
||||
_attr_dict = {"sculpt": "use_paint_sculpt",
|
||||
"vertex_paint": "use_paint_vertex",
|
||||
"weight_paint": "use_paint_weight",
|
||||
"image_paint" : "use_paint_texture"}
|
||||
"image_paint": "use_paint_texture"}
|
||||
|
||||
def execute(self, context):
|
||||
attr = self._attr_dict.get(self.mode)
|
||||
@@ -102,6 +102,7 @@ class BRUSH_OT_set_active_number(bpy.types.Operator):
|
||||
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
class WM_OT_context_set_boolean(bpy.types.Operator):
|
||||
'''Set a context value.'''
|
||||
bl_idname = "wm.context_set_boolean"
|
||||
@@ -668,7 +669,6 @@ class WM_OT_doc_edit(bpy.types.Operator):
|
||||
return wm.invoke_props_dialog(self, width=600)
|
||||
|
||||
|
||||
|
||||
from bpy.props import *
|
||||
|
||||
|
||||
@@ -689,7 +689,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
|
||||
'''Internal use (edit a property data_path)'''
|
||||
bl_idname = "wm.properties_edit"
|
||||
bl_label = "Edit Property"
|
||||
bl_options = {'REGISTER'} # only because invoke_props_popup requires.
|
||||
bl_options = {'REGISTER'} # only because invoke_props_popup requires.
|
||||
|
||||
data_path = rna_path
|
||||
property = rna_property
|
||||
@@ -803,6 +803,7 @@ class WM_OT_keyconfig_activate(bpy.types.Operator):
|
||||
bpy.utils.keyconfig_set(self.filepath)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class WM_OT_sysinfo(bpy.types.Operator):
|
||||
'''Generate System Info'''
|
||||
bl_idname = "wm.sysinfo"
|
||||
@@ -813,6 +814,7 @@ class WM_OT_sysinfo(bpy.types.Operator):
|
||||
sys_info.write_sysinfo(self)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
def register():
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user