KosukeFukazawa / CharacterAnimationTools

Character Animation Tools for Python.
MIT License
193 stars 14 forks source link

question about amass bvh conversion #1

Open pangwong opened 5 months ago

pangwong commented 5 months ago

Hi, when convert rotation data from amass to bvh, why we need the below transform? As for as I known, SMPL-X and BVH are both defined in standard right-hand coordinate with Y up and X right. Is the transforms relates with how the amass data defined ? I did not find related info. Thanks for your reply. https://github.com/KosukeFukazawa/CharacterAnimationTools/blob/9c8513c109eb9748aed4210ed120bc787e76e934/anim/amass.py#L61

pangwong commented 5 months ago

I found there are some hint in code of smplx-blender-addon, it sees that amass make XY as ground and Z as Up, so we only need to rotate amass data of -pi/2 around X axis ?

        if self.anim_format == "AMASS":
            # AMASS target floor is XY ground plane for SMPL-X template in OpenGL Y-up space (XZ ground plane).
            # Since SMPL-X Blender model is Z-up (and not Y-up) for rest/template pose, we need to adjust root node rotation to ensure that the resulting animated body is on Blender XY ground plane.
            bone_name = "root"
            if armature.pose.bones[bone_name].rotation_mode != 'QUATERNION':
                armature.pose.bones[bone_name].rotation_mode = 'QUATERNION'
            armature.pose.bones[bone_name].rotation_quaternion = Quaternion((1.0, 0.0, 0.0), radians(-90))
            armature.pose.bones[bone_name].keyframe_insert('rotation_quaternion', frame=1)