-
Notifications
You must be signed in to change notification settings - Fork 0
Roadmap
At the current state of the things, the first mandatory thing is to make a library (module) out of ./blender/goofy_importer.py.
I'd like to keep the MPFB specific functionalities separated by the Blender ones and possibly also the BPY part separated by the generic Python part.
init_blender_context is meant to set up thing in the proper way to prepare Blender for a clean import, though I am afraid that the two lines 277 and 278.
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)I copied them from an existing example, but according to the documentation, they are supposed to select all the object present in the active scene, line 277, and delete them, line 278. For some reason (which I will be happy to investigate, given time) these two lines don't achieve the result we would expect by reading the official API documentation (bpy.ops.object.select_all() and bpy.ops.object.delete()), though I feel like they are unnecessary and potentially "dangerous".
If my observation above will be validated, removing the two lines, leave us with not much.
if bpy.context.object and bpy.context.object.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')Which could be moved to the function swith_mode().
(create_armature())[https://github.com/endersaka/bvh-reader-2/blob/1f9fc27b604e4df12575fdb3a88fdfea4b51289c/blender/script/goofy_importer.py#L251] creates a new armature.
The code at line 265 isn't necessary and is a not a concern of this function in my opinion. It could be called by consuming code and modified by using switch_mode(), instead.
# This
bpy.ops.object.mode_set(mode='EDIT')
# Will become this
switch_mode('EDIT')
# And will be moved to external code.NOTE: this is one of the functions that will not be used by MPFB. In fact, MPFB requires only to pose the existing bones.
create_bones() use the data retrieved from HIERARCHY section to create the amature bones. As the previous function, it is out of the scope of MPFB.
NOTE: the
switch_mode('EDIT')line, from the previous function, should be placed at the beginning of this one.
get_rest_poses() get the armature rest pose bone transformations (plural because I was thinking about the pose of each single bone) and store them in the REST_POSE variable.
With some improvements this is the first function of some interest for MPFB. In fact, storing the original rest pose of the armature, is crucial to apply correctly the frame transformations.
NOTE:
create_armature()returns the data block of the armature, though, it is probably not the most generic way to proceed. Maybe,create_armature()should simply return the armature object andget_rest_poses()could accept different types of data: data block, object, a string (the name of the armature), etc.
NOTE: a better name for
get_rest_poses()could beget_rest_pose_bones_transformations()or, simpler,get_rest_pose().
Finally, pose_bones() is the most important function for MPFB. It takes one parameter, motion, the MOTION section of the BVH file already structured in a dictionary easily consumable dictionary as mentioned in Future Plan.
This function does not exist yet. It is, ideally, the function that will store the imported bone transformations into an action keyframe.