Changing rest position of an animation from .bvh file

Hi, i am trying to add an animation from a .bvh file to my human model made with makehuman, the problemis that my model has the arms open in t form and the rest position from the animation hasn´t them in that position. I have try to move the rest position manually but if meshes the animation, how can i change it?thank´s

Load it up into BVHacker. It is free. http://davedub.co.uk/bvhacker/ You can set a T pose there. Then save it.

I have downloaded the program but when i press set t pose the only thing i see is the skeleton in rest pose, but it doesn´t change to t rest pose.

I have found in this forum this script, what it mades is to set the position of the first frame as restposition, that is exactly what i need because my animation start with t-pose, the problem is that the script has errors in the calls of the fucntions and methods, maybe because it is older but i think that it will be simple to fix by someone with script knwloedges. Could anyone fix it?:



import bpy
import mathutils


# Just hardcoding names at the moment

rigId = "BvhRig"                # Id of the armature object
                                
ActionId = "BvhRig.003Action.001"           # Id of the action to convert 
rootBoneId = "Hips"              # the rootbone to take travel out from.. 

ob = bpy.data.objects["BvhRig.003"]




action = bpy.data.actions[ActionId]


print(action.name)
#action.select = True

#bpy.ops.action.clean(threshold=0.01)

frames = action.frame_range.magnitude




# for each key in the action for the hip posebone subtract out the movement.


transformVector = mathutils.Vector((0,0,0))

IdentityQuatro = [1,0,0,0]
quatro = [0,0,0,0]

for fcurve in action.fcurves:
    

 
    
    points = fcurve.keyframe_points
    
    
    i = 1
    while i < len(points):
           #if it's a rotation key we'll smack it hard.
        j = 0
        point = points[i]
        
        frame  = 0
        if fcurve.data_path.find("rotation_quaternion") > 0:
                
            
            # co gives us frame in 0, value in 1.
            frame = point.co[0]
            value = point.co[1]

            quatro[fcurve.array_index] = value + IdentityQuatro[fcurve.array_index] - points[0].co[1]
            #Ok take out the difference from pose mode.
            point.co[1] = quatro[fcurve.array_index]
            

            

        if fcurve.data_path == "pose.bones[\"%s\"].rotation_quaternion"%(rootBoneId):
            print("frame:{0} {1}".format(frame,quatro))
            
        
        i += 1 
        
#To do ... change the rest position to the pose in frame 0
#           with bpy.ops.pose.armature_apply()  but not sure how to make sure it's in frame 0 otherwise it puts pose in active frame which turns it to crap. Running the script in pose mode at frame 0 and it works a treat with this.
#          Either make all quatros in frame 0 to Identity or remove frame 0 to set it back to Tpose.
#          Move the Tpose in frame 0 to the origin. Well the Hips i suppose... not a real biggy.

#bpy.ops.pose.armature_apply()

Attachments