Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert to fbx file #57

Open
andrew-atef opened this issue Feb 12, 2024 · 3 comments
Open

convert to fbx file #57

andrew-atef opened this issue Feb 12, 2024 · 3 comments

Comments

@andrew-atef
Copy link

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

@hushaoqing
Copy link

+1

@JYuhao88
Copy link
Contributor

JYuhao88 commented Apr 8, 2024

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

@hushaoqing
Copy link

hushaoqing commented Apr 18, 2024

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,
    )
  1. https://gitlab.tuebingen.mpg.de/jtesch/smplx_blender_addon#installation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants