diff --git a/release/scripts/bvh_import.py b/release/scripts/bvh_import.py index 30e42095d24..7b0c3928cbb 100644 --- a/release/scripts/bvh_import.py +++ b/release/scripts/bvh_import.py @@ -261,7 +261,7 @@ def read_bvh(file_path, GLOBAL_SCALE=1.0): while anim_data[-1][5] - rz > 180: rz+=360 while anim_data[-1][5] - rz < -180: rz-=360 - + # Done importing motion data # anim_data.append( (lx, ly, lz, rx, ry, rz) ) lineIdx += 1 @@ -484,12 +484,12 @@ def bvh_node_dict2armature(bvh_nodes, IMPORT_START_FRAME= 1): # KEYFRAME METHOD, SLOW, USE IPOS DIRECT - ''' + # Animate the data, the last used bvh_node will do since they all have the same number of frames for current_frame in xrange(len(bvh_node.anim_data)): - if current_frame==40: - break + #if current_frame==40: # debugging + # break # Dont neet to set the current frame for bvh_node in bvh_nodes.itervalues(): @@ -516,9 +516,9 @@ def bvh_node_dict2armature(bvh_nodes, IMPORT_START_FRAME= 1): # Insert the keyframe from the loc/quat pose_bone.insertKey(arm_ob, current_frame+IMPORT_START_FRAME, xformConstants) # END KEYFRAME METHOD - ''' + """ # IPO KEYFRAME SETTING # Add in the IPOs by adding keyframes, AFAIK theres no way to add IPOs to an action so I do this :/ for bvh_node in bvh_nodes.itervalues(): @@ -646,7 +646,7 @@ def bvh_node_dict2armature(bvh_nodes, IMPORT_START_FRAME= 1): w,x,y,z= nw,nx,ny,nz # IPO KEYFRAME SETTING - + """ pose.update() return arm_ob @@ -677,7 +677,7 @@ for f in ('/d/staggered_walk.bvh',): bvh_node_dict2armature(bvh_nodes, 1) ''' -def load_bvh_ui(file): +def load_bvh_ui(file, PREF_UI= True): if BPyMessages.Error_NoFile(file): return @@ -690,15 +690,16 @@ def load_bvh_ui(file): IMPORT_AS_EMPTIES = Draw.Create(0) # Get USER Options - pup_block = [\ - ('As Armature', IMPORT_AS_ARMATURE, 'Imports the BVH as an armature'),\ - ('As Empties', IMPORT_AS_EMPTIES, 'Imports the BVH as empties'),\ - ('Scale: ', IMPORT_SCALE, 0.001, 100.0, 'Scale the BVH, Use 0.01 when 1.0 is 1 metre'),\ - ('Start Frame: ', IMPORT_START_FRAME, 1, 30000, 'Frame to start BVH motion'),\ - ] - - if not Draw.PupBlock('BVH Import...', pup_block): - return + if PREF_UI: + pup_block = [\ + ('As Armature', IMPORT_AS_ARMATURE, 'Imports the BVH as an armature'),\ + ('As Empties', IMPORT_AS_EMPTIES, 'Imports the BVH as empties'),\ + ('Scale: ', IMPORT_SCALE, 0.001, 100.0, 'Scale the BVH, Use 0.01 when 1.0 is 1 metre'),\ + ('Start Frame: ', IMPORT_START_FRAME, 1, 30000, 'Frame to start BVH motion'),\ + ] + + if not Draw.PupBlock('BVH Import...', pup_block): + return print 'Attempting import BVH', file @@ -724,10 +725,13 @@ def load_bvh_ui(file): print 'Done in %.4f\n' % (Blender.sys.time()-t1) Blender.Window.WaitCursor(0) - def main(): Blender.Window.FileSelector(load_bvh_ui, 'Import BVH', '*.bvh') - + if __name__ == '__main__': main() - + ''' + scn = Blender.Scene.GetCurrent() + for ob in list(scn.objects): scn.objects.unlink(ob) + load_bvh_ui('/test.bvh', False) + ''' diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index 8e737f1f496..221a2d1adba 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -96,6 +96,7 @@ static PyObject *M_Scene_New( PyObject * self, PyObject * args, PyObject * keywords ); static PyObject *M_Scene_Get( PyObject * self, PyObject * args ); static PyObject *M_Scene_GetCurrent( PyObject * self ); +static PyObject *M_Scene_getCurrent_deprecated( PyObject * self ); static PyObject *M_Scene_Unlink( PyObject * self, PyObject * arg ); /*-----------------------Scene module doc strings-----------------------------*/ static char M_Scene_doc[] = "The Blender.Scene submodule"; @@ -115,7 +116,7 @@ struct PyMethodDef M_Scene_methods[] = { {"get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc}, {"GetCurrent", ( PyCFunction ) M_Scene_GetCurrent, METH_NOARGS, M_Scene_GetCurrent_doc}, - {"getCurrent", ( PyCFunction ) M_Scene_GetCurrent, + {"getCurrent", ( PyCFunction ) M_Scene_getCurrent_deprecated, METH_NOARGS, M_Scene_GetCurrent_doc}, {"Unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc}, {"unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc}, @@ -534,6 +535,12 @@ static PyObject *M_Scene_GetCurrent( PyObject * self ) { return Scene_CreatePyObject( ( Scene * ) G.scene ); } +static PyObject *M_Scene_getCurrent_deprecated( PyObject * self ) +{ + printf("Blender.Scene.getCurrent() is deprecated,\n\tuse Blender.Scene.GetCurrent() instead.\n"); + return Scene_CreatePyObject( ( Scene * ) G.scene ); +} + /*-----------------------Scene.Unlink()----------------------------------*/ static PyObject *M_Scene_Unlink( PyObject * self, PyObject * args )