MH into Godot tutorial

For discussions related to game development, and to game development software such as Unity, Unreal Engine, Godot and so on.

Re: MH into Godot tutorial

Postby tomcat » Sun Jun 19, 2022 9:13 am

I have made some cosmetic changes and very minor corrections. If there are no critical comments, I will post this tutorial on the Godot site next week.

Regarding the posting of this tutorial on the MH site. This is certainly a possibility. But I suppose that the first part will not be interesting for those who already work with MH — it's designed for those who have never dealt with MH before and gives only a basic understanding of the program. The second part will contain the Blender import itself and some non-obvious stuff.

I liked Patreon for its fast and quality support.
Foreigners' reactions to Russian "Bird's Milk" candies
— Are birds being milked there?
— In Russia everyone is milked. Here even zucchinis lay caviar…
User avatar
tomcat
 
Posts: 167
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow (Orcish Stan), Evil Empire

Re: MH into Godot tutorial

Postby tomcat » Wed Jun 22, 2022 3:49 pm

Creating a character for games in Godot using MakeHuman

Volume 2

Importing into Blender and assigning animations. Importing into Godot

Need two addons for Blender:



Step 1

Import

The import panel can be called in 2 ways:
  • File –> Import –> MakeHuman (.mhx2)
  • N-панель –> Import MHX2
result is identical:

Image


If you need facial animation, you can:
  • to enable the "Face Shapes" option for emotions via shape keys;
  • if you choose a rig with face bones, then the emotions can be realised by poses.

In Rigging turn on Add Rig and choose Rig Type [Exported].

The rig assigned to the MH will be imported.

[Import MHX2]

Image

Remove all the masks:

Image

If the clothes will be the only one, it's better to leave masks.


Step 2

Assignment of animation

*A little note. For the game, the animation must be played without moving the character. Moving the character is done in the game engine by moving the object itself. As the animation in the example contains movement, you need to get rid of it (or take the animation already prepared). You can choose any convenient way for the character to stay in place. In my opinion, the easiest is to tie the Hips(root) bone to the position at rest. The way is not the best, but simple and fast. To do this, I make a copy of the skeleton at rest position. This is only necessary for binding.

To assign the animation use Retarget BVH plugin finalized by punkduck (for which he is very thankful).

Image

[Load And Retarget] allows you to load animation and immediately apply to the character.

Select animation (02_01.bvh) and load it.

Image

Image

*Now bind the Hips animation bone to the rest pose bone for the character to walk in place.

Image

Add the running animation (02_03.bvh).

Image

Now the file is ready to be exported to Godot.

Image

The documentation for the engine recommends that you triangulate the models.

But Blender does not allow you to triangulate an object that contains shape keys:
Code: Select all
Modifier cannot be applied to a mesh with shape keys



Step 3

Godot. Import

The Blender Importer Addon for Godot allows you to open Blender files as Godot scenes.

This feature is built into Godot 4, but it doesn't work correctly there.

Just save the .blend file in your project folder and it will be automatically imported into the engine.

In an open scene, you can remove the resting pose skeleton you don't need anymore and separate clothes by scene for easy switching:

Image

Video

Face morphs will be transferred, but you must remember to set the same Shapes settings for different body parts.

Image


The main part of the tutorial is finished.


Translated with http://www.DeepL.com/Translator (free version)
Last edited by tomcat on Mon Aug 15, 2022 5:51 pm, edited 7 times in total.
Foreigners' reactions to Russian "Bird's Milk" candies
— Are birds being milked there?
— In Russia everyone is milked. Here even zucchinis lay caviar…
User avatar
tomcat
 
Posts: 167
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow (Orcish Stan), Evil Empire

Re: MH into Godot tutorial

Postby tomcat » Thu Jun 30, 2022 8:29 pm

Some suggestions that arose during the creation of the tutorial

  • Make an option in .mhx2 to save body parts and clothes separately, so they would be automatically put into Blender collections (for example, body parts into "body parts" collection, and clothes into "clothes" collection, maybe even by categories: "sports", "casual"…).
  • Support importing collections from Blender, so that Blender collections open as nodes in Godot.
Foreigners' reactions to Russian "Bird's Milk" candies
— Are birds being milked there?
— In Russia everyone is milked. Here even zucchinis lay caviar…
User avatar
tomcat
 
Posts: 167
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow (Orcish Stan), Evil Empire

Re: MH into Godot tutorial

Postby tomcat » Sat Jul 02, 2022 6:33 pm

Creating a character for games in Godot using MakeHuman

Volume 3

  1. Change of hair (eyebrows, eyelashes, teeth).
  2. Body Shapes (Shape Keys).


Part 1

Change of hair (eyebrows, eyelashes, teeth)


Step 1

Changing body parts is somewhat different from choosing clothes. Since you can't have a character with several hairstyles (unlike clothes), you have to work with each hairstyle individually.

It is assumed that there are already:
  • the original MakeHuman model, which needs to be modified;
  • a Blender file derived from this model.


Load the model for which you want to change the hairstyle. Choose the hairstyle you want:

Image

bob02
author
Joel Palmius
Jonas Hauquier



If you want, you can add eyebrows, eyelashes, teeth to transfer. It is better to remove unnecessary things.

The model is exported in .mhx2 format ("Scale units" in meters).


Step 2

Blender

Opens the previously saved file with the original model.
  1. The file with the new hairstyle is imported into it.

    Image
  2. The hairstyle is transferred to the collection to the original model and linked (with a Shift).
  3. The armature from the original model is assigned.
  4. The entire new collection should be deleted.
  5. The file is saved to the Godot project folder.

Image


Step 3

Godot

The Blender file imported into Godot can be saved as a new scene. If the previous file was already saved as a scene, the hair can be transferred to it as a node.

Image


Translated with http://www.DeepL.com/Translator (free version)
Last edited by tomcat on Mon Aug 15, 2022 5:36 pm, edited 1 time in total.
Foreigners' reactions to Russian "Bird's Milk" candies
— Are birds being milked there?
— In Russia everyone is milked. Here even zucchinis lay caviar…
User avatar
tomcat
 
Posts: 167
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow (Orcish Stan), Evil Empire

Re: MH into Godot tutorial

Postby tomcat » Sun Jul 24, 2022 6:41 pm

Final part of the tutorial.

Volume 3


Part 2

Shape Keys

Assignment of shape keys

It is assumed that there are already:
  • the original MakeHuman model, which needs to be modified;
  • a Blender file derived from this model.

Step 1

MakeHuman

Load the model into which you want to add the shape key. The model should have clothes, to which a key will be applied to the form. Apply the modifier:

Image

The operation must be repeated for each key.

The model is exported in .mhx2 format (units in meters).


Step 2

Blender

Opens the previously saved file with the original model.

Triangulation

The engine documentation recommends triangulating the models.

But Blender does not allow you to triangulate an object that contains shape keys.

Code: Select all
Modifier cannot be applied to a mesh with shape keys

If the model does not contain shape keys, then that model can be triangulated before they are assigned.


Choice of modifiers for shape keys

You may only assign modifiers that do not change the size of the model skeleton! If the modifier changes the dimensionality of the skeleton (e.g. arm/leg length, shoulder width etc.), the result of the animation will be unpredictable.



  1. The modified model is imported into the file with the original model.
  2. The part (body) of the modified model is selected first.
  3. Then the same part of the original model is selected (with CTRL).
  4. Assign a shape key (Object Data Properties –> Shape Keys –> Join as shapes)

    Image
  5. The procedure is repeated with the clothing elements.
  6. The entire new collection should be deleted.
  7. The file is saved in the Godot project folder.


Step 3
Godot

The Blender file imported into Godot is saved as a new scene.

There is a bug: if "Bland Shape" is set to 1, artifacts appear:

Image

It is desirable to set the value to less than 1.0:

Image


A huge grateful thanks to those who have helped and supported me:

Translated with http://www.DeepL.com/Translator (free version)
Last edited by tomcat on Mon Aug 15, 2022 5:36 pm, edited 1 time in total.
Foreigners' reactions to Russian "Bird's Milk" candies
— Are birds being milked there?
— In Russia everyone is milked. Here even zucchinis lay caviar…
User avatar
tomcat
 
Posts: 167
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow (Orcish Stan), Evil Empire

Re: MH into Godot tutorial

Postby tomcat » Sat Jul 30, 2022 9:11 am

Some remarks about working with newer versions of the software:
  • In Blender 3, the Retarget BVH plugin does not work yet.
  • Godot 4 does not import .blend files correctly. It is recommended to import via glTF.
Foreigners' reactions to Russian "Bird's Milk" candies
— Are birds being milked there?
— In Russia everyone is milked. Here even zucchinis lay caviar…
User avatar
tomcat
 
Posts: 167
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow (Orcish Stan), Evil Empire

Re: MH into Godot tutorial

Postby tomcat » Mon Aug 15, 2022 5:54 pm

Volume 4

Adding animation

It is assumed that there are already:

  • Blender file with animation;
  • A scene in Godot derived from this file.

Step 1

Blender

Opens a previously saved file with the original model and animations.

  1. A new animation is imported.
  2. The file is saved in the Godot project folder.

Note. In this example, the jump animation is applied in place. In general, it is desirable to move the model in the game engine, as a node, then it will be possible to change the height of the jump. But in this case, I will show a fixed jump. To do this, leave the constraint of the bone fixed on the X-axis only. This change will affect the existing animations, but they are already in the scene file in Godot.

Image


Step 2

Godot

  1. From the new file imported into Godot, only a new animation is needed:

    Image

  2. It can be copied or saved for future use:

    Image

  3. Open AnimationPlayer in an existing scene and load the new animation file there by copying or exporting:

    Image

That's it, the animation is added to the scene file.


Translated with http://www.DeepL.com/Translator (free version)
Foreigners' reactions to Russian "Bird's Milk" candies
— Are birds being milked there?
— In Russia everyone is milked. Here even zucchinis lay caviar…
User avatar
tomcat
 
Posts: 167
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow (Orcish Stan), Evil Empire

Previous

Return to Game development

Who is online

Users browsing this forum: No registered users and 1 guest