IDEA-Research / Motion-X

[NeurIPS 2023] Official implementation of the paper "Motion-X: A Large-scale 3D Expressive Whole-body Human Motion Dataset"
https://motion-x-dataset.github.io
Other
542 stars 15 forks source link

convert to fbx file #57

Open andrew-atef opened 7 months ago

andrew-atef commented 7 months ago

How to convert Motion-X files to FBX for 3D animation programs?

hushaoqing commented 7 months ago

+1

JYuhao88 commented 5 months ago

https://github.com/JYuhao88/SMPLerX-Server Here are some features you might find helpful.

hushaoqing commented 5 months ago

I solved this by first converting to AMASS format and then using smplx_blender_addon to export fbx.

  1. to AMASS format

def convert_to_amass_npz(npy_path, npz_path):

Read motion data from npy file

motion = np.load(npy_path)
motion = torch.tensor(motion).float()

# Extract motion parameters
motion_parms = {
    "root_orient": motion[:, :3],
    "pose_body": motion[:, 3 : 3 + 63],
    "pose_hand": motion[:, 66 : 66 + 90],
    "pose_jaw": motion[:, 66 + 90 : 66 + 93],
    "trans": motion[:, 309 : 309 + 3],
    "betas": motion[:, 312:],
}

# Create amass format data
frame_length = motion.shape[0]
gender = "male"

left_eye_smplhf_and_right_eye_smplhf = np.zeros((frame_length, 2 * 3))
# AMASS JOINTS format
poses = np.concatenate(
    (
        motion_parms["root_orient"],
        motion_parms["pose_body"],
        motion_parms["pose_jaw"],
        left_eye_smplhf_and_right_eye_smplhf,
        motion_parms["pose_hand"],
    ),
    axis=1,
)
trans = motion_parms["trans"]
betas = motion_parms["betas"][0]

# Save data in amass format (NPZ file)
os.makedirs(
    os.path.dirname(npz_path), exist_ok=True
)  # Create necessary directories
np.savez(
    npz_path,
    poses=poses,
    gender=gender,
    mocap_framerate=30,
    betas=betas,
    trans=trans,
)

2. https://gitlab.tuebingen.mpg.de/jtesch/smplx_blender_addon#installation