Sauerworld Forum

Sauerbraten Talk => General Chat => Topic started by: Salatiel on October 15, 2019, 04:38:16 AM

Title: Modifying Sauer Player Models - Guide
Post by: Salatiel on October 15, 2019, 04:38:16 AM
Modifying Sauer Player Models - Guide
Installing the tools
First and foremost, you need to download Blender (version 2.79) and an add-on to it that will allow you to import models and animations with the .md5 format and export them.

Download Blender 2.79
https://download.blender.org/release/Blender2.79/ (https://download.blender.org/release/Blender2.79/)
Download MD5 Importer & Exporter (thanks @pink-vertex)
https://github.com/pink-vertex/blender_addon_md5/archive/Release.zip (https://github.com/pink-vertex/blender_addon_md5/archive/Release.zip)

To install an addon simply open the "User Preferences" menu (CTRL + ALT + U) and go to the "Add-ons" tab, then follow the steps:

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_installaddon1.png)

Attaching a new object to the character
Now you have everything ready to import any character in .md5, to do that just go to the File -> Import menu and select MD5 Mesh (.md5mesh) , navigate to your Sauerbraten models folder (sauerbraten/packages/models) and choose the folder of one of the characters (inky, snoutx10k, mrfixit or captaincannon), the file you should import will appear as charactername.md5mesh.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_importMD5.png)

If all went well, the character should look like this:

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide1.png)

Our goal will be to put Suzanne, mascot of Blender, in the head of Captain Cannon, just add it by going to Add -> Mesh -> Monkey, and then move it to the position you prefer.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide2.png)
(ignore captain cannon's textures, it's just for a better visualization)

Since these are optional steps, follow the links below if you want to know how to move, rotate, scale and texturize objects in Blender:
Move, Rotate, Scale
https://docs.blender.org/manual/en/latest/modeling/meshes/editing/basics/move_rotate_scale.html
 (https://docs.blender.org/manual/en/latest/modeling/meshes/editing/basics/move_rotate_scale.html)UV Map Basics
https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/UV_Map_Basics (https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/UV_Map_Basics)

Now we need to attach our object to the "bone" of the character's head, so we will add an "Armature" Modifier to the monkey, just go to the tool icon and select it.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide3.png)

After adding an Armature, click on the "Object:" text field and choose MD5 (MD5 is Captain Cannon's armature name), then click the icon to the right of the tool icon to open the "Object data" menu.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide4.png)

Now you need to define which character bone our monkey should follow. To do so, change from "Object mode" to "Edit mode" and on the "Vertex Groups" tab, you will click the "+" visual button and rename the "Group" text for the bone name, in which case it will be "Head". By clicking on "Assign" all parts of our model will follow the character's "Head" bone.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide5.png)

Your modification is almost done, but before exporting back to .md5 you need to open your object's UV Map, ie define how the texture will interact with the faces of the model (our monkey). This is quite simple to do automatically, although the result is not very pleasant... Still in "Edit mode" press the U key and choose "Smart UV Project" and you're done, this step is necessary even if you don't want to add any texture to the model.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide6.png)

Now you need to go back to "Object mode" and apply the Position, Rotation and Scale of the monkey, press CTRL + A and choose "Location", press it again and choose "Rotation & Scale".

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide8.png)

Now you can export, select the whole character (including your object, make sure to select the armature last, otherwise the export button will not be available). Just replace the .md5mesh that you had imported before.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide7.png)

And good job, you just made your first mod!

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide9.png)

Texturing things

This yellowish color with white text means that the model has no texture, and to add it you will need to make some modifications to the md5.cfg file of the character you have chosen. If you are already a Blender lover, you probably already know how to make and organize textures in your model, so in this topic we will cover how to configure these textures in Sauerbraten.
A .cfg file is a simple text file that contains several commands, this text file can be executed manually by the player or automatically by the game. You will find your character's .cfg file in the same folder as his .md5mesh is.

Below is an example of the Captain Cannon cfg file, it is responsible for loading the model and applying the textures, as well as running the other files that configure the animations and etc.

sauerbraten/packages/models/captaincannon/md5.cfg

1 md5load "captaincannon.md5mesh" captaincannon 70
2 exec "packages/models/captaincannon/ragdoll.cfg"
3 md5tag Weapon tag_weapon
4 md5skin head "<dds>cc_head.png" "<dds>cc_head_mask.png"
5 md5bumpmap head "<dds>cc_head_normals.png"
6 md5skin body "<dds>cc_body.png" "<dds>cc_body_mask.png"
7 md5bumpmap body "<dds>cc_body_normals.png"
8 exec "packages/models/captaincannon/anims.cfg"
9 mdlscale 1225
10 mdlspec 60


You only need two things: The image to use as the texture and the name of the mesh to apply the texture to.
How to get the name of the mesh? It's simple, go back to Blender, select your object and see in the lower left corner what its name is, you can also modify it by pressing N and going to the "Item" tab.

(https://raw.githubusercontent.com/CubeBR/Sauerbraten/master/blender_modguide13.png)

You will probably have your own texture but for now we will steal a texture that is already in sauer, so we use md5dir to navigate to any other folder inside sauerbraten/packages/models.

Here we are accessing the folder sauerbraten/packages/models/tentus/chains (md5dir) and applying the skin.jpg texture on the Suzanne mesh (md5skin).

1 md5load "captaincannon.md5mesh" captaincannon 70
2 exec "packages/models/captaincannon/ragdoll.cfg"
3 md5tag Weapon tag_weapon
4 md5skin head "<dds>cc_head.png" "<dds>cc_head_mask.png"
5 md5bumpmap head "<dds>cc_head_normals.png"
6 md5skin body "<dds>cc_body.png" "<dds>cc_body_mask.png"
7 md5bumpmap body "<dds>cc_body_normals.png"
8 exec "packages/models/captaincannon/anims.cfg"
9 mdlscale 1225
10 mdlspec 60
11
12 md5dir tentus/chains
13 md5skin Suzanne skin.jpg

When you use md5dir, every md5 command below it will use the dir you chose as reference.

And you're done, the monkey should look like this:

(https://i.imgur.com/AuogQPZ.png)

Yeah it's horrible, but you got it...
It's all a matter of practice and creativity  ;D

Common errors:
Export button is unselectable = Means you didn't select character armature last.
AttributeError BMElem[key] Invalid key... = You didn't open your model's UV map.

I hope this post was helpful, below are some interesting links:
Sauerbraten MD5 Model Reference
http://sauerbraten.org/docs/models.html#md5_format (http://sauerbraten.org/docs/models.html#md5_format)
Blender Weight Painting
https://www.youtube.com/watch?v=Tl4qTgwQwYw (https://www.youtube.com/watch?v=Tl4qTgwQwYw)
Blender Texture Mapping
https://www.youtube.com/watch?v=eiDrRa6JvQ0 (https://www.youtube.com/watch?v=eiDrRa6JvQ0)
Blender Rigging
https://www.youtube.com/watch?v=Y0btZFIeGtY (https://www.youtube.com/watch?v=Y0btZFIeGtY)
How to animate a mapmodel in Sauerbraten (portuguese)
http://www.cubebr.com/2018/10/como-animar-mapmodels-do-sauerbraten.html (http://www.cubebr.com/2018/10/como-animar-mapmodels-do-sauerbraten.html)

as our dear Suicizer would say: be sure to check the licenses before modifying any model!
Title: Re: Modifying Sauer Player Models - Guide
Post by: h8 on October 17, 2019, 07:08:54 AM
nice guide. probably not gonna try it , it looks like hard work. but nice guide for those who might want to.
Title: Re: Modifying Sauer Player Models - Guide
Post by: Salatiel on October 17, 2019, 05:28:45 PM
nice guide. probably not gonna try it , it looks like hard work. but nice guide for those who might want to.

Thanks h8!
it seems hard but in the end it's just a bunch of buttons to click in order ;D
Title: Re: Modifying Sauer Player Models - Guide
Post by: Master on October 20, 2019, 12:32:30 PM
good job salatiel, very admirable work you are doing, I'll definitely try it out
Title: Re: Modifying Sauer Player Models - Guide
Post by: TristamK on November 02, 2019, 10:07:52 AM
Good job. In one day if my plans will start work i will try it.