powroupi / blender_mmd_tools

mmd_tools is a blender addon for importing Models and Motions of MikuMikuDance.
GNU General Public License v3.0
1.74k stars 278 forks source link

Mixamo's PMX animation to VMD #347

Closed ImNewAndLearning closed 3 years ago

ImNewAndLearning commented 3 years ago

I'm kinda new at blender and very new in MMD. I want to learn but I don't know how to export mixamo's pmx animation to vmd. I'm stuck, but I don't want to stop because I have this Idea that I want to make. I've been looking all over and can't seem to find the solution.

Here's the link: https://mega.nz/file/PUh03JZA#k0yULfs3uQSD7TVuAu-w_1nJvWPkCJKi0CXXuX7Mhbk

Any kind of help, workarounds, and/or solution is greatly appreciated :)

Hogarth-MMD commented 3 years ago

.pmx is an MMD model format, not an animation format. Blender's .fbx importer/exporter has bugs and is not feature complete. I think that possibly Maya is the only software that is not buggy with import and export of .fbx. Probably .bvh would be a better idea for exporting a skeleton animation from other software to Blender and Collada(.dae) for exporting a model from other software to Blender.

Hogarth-MMD commented 3 years ago

Your .pmx model seems to be in very good condition. It dances fine in MMD. But it has one serious problem. If you open this model in PMD/PMX editor, you can see that the names of the texture images of the model are Japanese, but the image files in the model folder have English names. So you don't get any correct display of image textures of your model.

powroupi commented 3 years ago

Here are the steps of Blender 2.92.0, and hope you can understand this workflow better with this tutorial. :smile: (Maybe there are some plugins out there could do this job in a easier way, I don't know, sorry. :cry: ) (bone_map.zip contains bone_map.csv and untitled.vpd)

  1. Open an empty scene, import FBX Laying Idle.fbx with default settings.

  2. Clear Armature object's location/rotation/scale using hotkey Alt-G, Alt-R, Alt-S, then press Home key to view all objects. [!!! Important !!!] 2

  3. Define the Rest Pose of the animation and rename bones to match the bone names of your MMD model. The following are the steps: (A bone mapping file would need to be created manually at first time. You can use bone_map.csv for test.)

    • Select Armature object, go to [MMD] tab -> click [Convert Model] with default settings. 3-1

    • Select Armature object, go to [Pose Mode]. 3-2

    • Only select bone mixamorig:Hips, then [Select] -> [Invert] to invert selection, then [Pose] -> [Clear Transform] -> [All]. Then only select bone mixamorig:LeftArm, rotate -45 degrees along global Y-axis. And then only select bone mixamorig:RightArm, rotate 45 degrees along global Y-axis. The result is like this picture. So, we can get a VMD motion without rotating using this rest pose. 3-5

    • Go to [Text Editor] window, Drag-drop bone_map.csv to open it in Blender's Text Editor. 3-8

    • Go back to [3D Viewport] window, Click [Translation] to rename bones with Dictionary bone_map.csv, Types [Bones], Modes [Blender Names], enable [Overwrite] and [Allow Fails] (because we're not renaming bones to ASCII names) 3-9 Here is the result: 3-10

  4. Click [Export] to export VMD untitled.vmd, enable [Treat Current Pose as Rest Pose]. 4

  5. Import PMX The Traveler Female.pmx with default settings. (or you can only import [Mesh] and [Armature] parts just for test) 5

  6. Pose your model to fit the rest pose of the VMD file. The following are the steps:

    • Select armature object The Traveler Female_arm, go to [Pose Mode].

    • Only select bone 全ての親, rotate -180 degrees along global X-axis, so we have similar rest pose in Pose space. 6

    • You can adjust more bones like fingers, spines and hips/center bone to fit it better. (considering overall mesh shaping and pivot point of each bone). The untitled.vpd is an example for adjusting hips, you can import pose to this MMD model.

  7. Import VMD untitled.vmd with Scale 0.1, Margin 0, enable [Treat Current Pose as Rest Pose]. (Because this FBX model is about 10 times more than this PMX model, we use scale 0.1.) 7

  8. Go to [MMD Display] panel of [Misc] tab, disable every leg IK. (Then you can clear rotation of bone 全ての親, so you get a normal standing pose animation.) 8

ImNewAndLearning commented 3 years ago

@powroupi Thank you so much! If it doesn't take much of your time, can I also build physics with this? The "build" is grayed out I don't know know how to do this...

I've been trying for almost a week and a half trying to figure stuff out, thank you so much for very detailed steps! I'm extremely grateful for your help!

powroupi commented 3 years ago

You're welcome. :smile:

can I also build physics with this? The "build" is grayed out I don't know know how to do this...

The "build" is grayed out when you didn't import any [Physics] parts, so [Properties] window -> [Scene] -> [Rigid Body World] is not added. You can click [Build]/[Clean], but there won't be any difference in this case.

The above tutorial is only focus on FBX animation to VMD. You can re-export VMD of this PMX model, then load this PMX model and re-exported VMD in MMD. Or open a new Blender file, and import full parts of this PMX model, [Build] physics, and import re-exported VMD to it with default [Margin] 5 or more to make final result.

ImNewAndLearning commented 3 years ago

I would like to exhaust my questions, I hope it doesn't take too much of your time.

I'd like to clean out some animations but the keyframes resets it back... is there any way to save it then applies it to the rest of the keyframes? Thank you for the reply btw!

powroupi commented 3 years ago

First, before exporting VMD, make sure to add keyframes to those bones/IKs which don't have keyframes at first frame if you changed their values.

If you want to adjust animation, for example, change left arm's rotation while keeping the motion:

  1. Change [Timeline] window to [Graph Editor] window. q2
  2. Select left arm, rotate it as you like, and add a keyframe at first frame. q3 q4 q5
  3. Adjust keyframes to make the curve smooth.
    • Expand the group of left arm's curves, double click [W Quaternion] to select the curve. q6a
    • Press C to use Circle Select, middle mouse click at first frame to deselect it. q6b
    • Press G, and then press Y to move keyframes vertically until matching the first frame, left mouse click (or press [Enter]) to confirm the change. q6c
    • The same method to make other keyframes as smooth as possible. q6d

You could also try Proportional Editing to edit the curve, there should be lots of good tutorials of Blender you can find. :smile:

ImNewAndLearning commented 3 years ago

I think this is it for all of my questions! Thank you so much for the help! I've learnt so much from you and I'm extremely grateful! I can't wait to make the scene that I've been planning for weeks!

Again, thank you for taking your time giving detailed instructions! And somehow I can't stop thanking you, so thank you again! 😄

gurenFo commented 2 years ago

Here are the steps of Blender 2.92.0, and hope you can understand this workflow better with this tutorial. 😄 (Maybe there are some plugins out there could do this job in a easier way, I don't know, sorry. 😢 ) (bone_map.zip contains bone_map.csv and untitled.vpd)

1. Open an empty scene, import FBX `Laying Idle.fbx` with default settings.

2. Clear `Armature` object's location/rotation/scale using hotkey Alt-G, Alt-R, Alt-S, then press Home key to view all objects. _**[!!! Important !!!]**_
   ![2](https://user-images.githubusercontent.com/9333484/120136259-81e72900-c204-11eb-807b-85852948f34f.jpg)

3. Define the Rest Pose of the animation and rename bones to match the bone names of your MMD model. The following are the steps: (A bone mapping file would need to be created manually at first time. You can use `bone_map.csv` for test.)

   * Select `Armature` object, go to [MMD] tab -> click [Convert Model] with default settings.
     ![3-1](https://user-images.githubusercontent.com/9333484/120136485-d38fb380-c204-11eb-9920-8d1a67fe7b09.jpg)
   * Select `Armature` object, go to [Pose Mode].
     ![3-2](https://user-images.githubusercontent.com/9333484/120136507-e4402980-c204-11eb-824d-1a60e2c60861.jpg)
   * Only select bone `mixamorig:Hips`, then [Select] -> [Invert] to invert selection, then [Pose] -> [Clear Transform] -> [All]. Then only select bone `mixamorig:LeftArm`, rotate -45 degrees along global Y-axis. And then only select bone `mixamorig:RightArm`, rotate 45 degrees along global Y-axis. The result is like this picture. So, we can get a VMD motion without rotating using this rest pose.
     ![3-5](https://user-images.githubusercontent.com/9333484/120136563-076ad900-c205-11eb-98be-91d47c006359.jpg)
   * Go to [Text Editor] window, Drag-drop `bone_map.csv` to open it in Blender's Text Editor.
     ![3-8](https://user-images.githubusercontent.com/9333484/120136653-3e40ef00-c205-11eb-8264-08869343abfe.jpg)
   * Go back to [3D Viewport] window, Click [Translation] to rename bones with Dictionary `bone_map.csv`, Types [Bones], Modes [Blender Names], enable [Overwrite] and [Allow Fails] (because we're not renaming bones to ASCII names)
     ![3-9](https://user-images.githubusercontent.com/9333484/120136682-47ca5700-c205-11eb-9f9e-20d0e170ba21.jpg) Here is the result:
     ![3-10](https://user-images.githubusercontent.com/9333484/120136695-4f89fb80-c205-11eb-9920-81b8883b982a.jpg)

4. Click [Export] to export VMD `untitled.vmd`, enable [Treat Current Pose as Rest Pose].
   ![4](https://user-images.githubusercontent.com/9333484/120136757-75170500-c205-11eb-85b1-c3651168a9cd.jpg)

5. Import PMX `The Traveler Female.pmx` with default settings. (or you can only import [Mesh] and [Armature] parts just for test)
   ![5](https://user-images.githubusercontent.com/9333484/120136773-7e07d680-c205-11eb-8940-b8f926c8ee68.jpg)

6. Pose your model to fit the rest pose of the VMD file. The following are the steps:

   * Select armature object `The Traveler Female_arm`, go to [Pose Mode].
   * Only select bone `全ての親`, rotate -180 degrees along global X-axis, so we have similar rest pose in Pose space.
     ![6](https://user-images.githubusercontent.com/9333484/120136820-9841b480-c205-11eb-8d05-bb55e3429b60.jpg)
   * You can adjust more bones like fingers, spines and hips/center bone to fit it better. (considering overall mesh shaping and pivot point of each bone). The `untitled.vpd` is an example for adjusting hips, you can import pose to this MMD model.

7. Import VMD `untitled.vmd` with Scale `0.1`, Margin `0`, enable [Treat Current Pose as Rest Pose]. (Because this FBX model is about 10 times more than this PMX model, we use scale `0.1`.)
   ![7](https://user-images.githubusercontent.com/9333484/120137087-2158eb80-c206-11eb-85d1-f762368b8672.jpg)

8. Go to [MMD Display] panel of [Misc] tab, disable every leg IK. (Then you can clear rotation of bone `全ての親`, so you get a normal standing pose animation.)
   ![8](https://user-images.githubusercontent.com/9333484/120137103-29b12680-c206-11eb-98ec-e6a008b7797f.jpg)

im a 1month mmd newbie, spent 2 days just to follow your guide, this is super helpful to me, dont even know how to express my gratitude, thank you so much!