B Tutorial 3D Modelling & Texturing & Implementing

Users who are viewing this thread

vGod2F5.png


"My name is Quintillius. I have been modding since years ago. I have worked on

Europe 1805 vII and A New Era and I feel it's time to pass on my knowledge

to potential new modders.


So you want to learn how to model an object and texture it and implement it into the game?

Well then you are at the right place. This tutorials contains series of tutorials covering modelling, texturing

and coding. Since Yoshiboy's tutorial is outdated (8 years old!), I have made a new (extended) tutorial for you. If you do not get some things, just continue following the steps. More information will come. Have fun!


Table of Contents

1. Basics
2. Setting up mod
3. Modelling in Wings3D
4. UV-mapping & Texturing
5. Importing in OpenBRF
6. Coding
7. Test your model




1. Basics
[size=6pt]

A mod stands for modification. A modification of a game to be more precise.

At first you need a program if you want to model anything. However a model isn't enough. You will need to texture it. This tutorial uses Wings3D 1.2 and Photoshop CS4 and we create a mod for Warband.

Mount & Blade uses the .brf extension to store models. We use OpenBRF to create such files. Textures are saved as .dds files, you need a separate converter/plugin for this. Then as a final point we let the game know it needs to read your newly create files. This is done by editing the ModuleSystem. Before you can use the ModuleSystem you need to download Python. Which is guided by this tutorial:

ModuleSystem & Python installation

Step 1.5 is already explained in my tutorial here. Below you can download what you need:

- Modeller program (Wings3D, 3dsMax, Maya)
- Texturer program (Adobe Photoshop, Gimp)
- .dds converter (download for Photoshop)
- OpenBRF
- ModuleSystem
- Python



2. Setting up mod

Let's start with creating the actual modification. Go to ...\Warband\Modules. You should locate this folder on your computer. A common installation has this location:

C:\Program Files\Mount&Blade Warband\Modules

Here you will find a folder named Native. Create a copy of it and rename it... well what's the name of your new mod?
We will use MyMod in this scenario.

Open the ...\Warband\MyMod folder. I hope you have downloaded the ModuleSystem. Put this in this folder and leave it alone for a short time. Alright now you will notice some interesting things:

- Textures
- Resource
- Module.ini


First Textures is the folder where you put in your .dds textures. Resource is used to store .brf files. Now open module.ini. You should change these lines:

module_name = <mod name>
scan_module_textures = <insert 1>

Congratulations! You have just created your first mod.



3. Modelling in Wings3d

It's time to put some content in your mod. What about creating a new double headed axe?
The best thing is to import an existing axe from the game into Wings3D and edit that.

1. First we need to export the axe from a .brf file. Start OpenBRF. Click File > Open.

2. Navigate to: ...\Warband\CommonRes [!] - Here are all Native models stored.

3. Open Weapon_meshes1.brf. Pick dblhead_ax.


loVTvZLl.png

4. Export this weapon to some location. OpenBRf will export this to .obj.


48lUqesl.png

5. Start Wings3D and as you can see in the following image. Use File > Import > Wavefront .obj > select "dblhead_ax.obj"


BpPUxHNl.png

6. I hope you are a bit familiar with Wings3D camera. If you don't like it, change it. Just play with it until you feel it's good. You can use the camera of SketchUp, Maya and other programmes: Settings > Camera > Camera Mode

xtRKAGVl.png

7. Just a few basic tricks:

4 boxes in the center

Change between vertex, edge, face and object mode.


Right mouse click (RMB)

If you have nothing selected, you can create a new model.

Choose between cube, cylinder, grid and more.

I use cube often as a start. Note: these options change if you

have selected the model. Options for vertex, edge, face and object mode differ.


Tab

Change between smooth and wireframe mode. This is also possible by clicking View > Wireframe


QhSylsol.png

[size=6pt]8. Select the whole model while being in face mode and use right mouse button, then click Tesselate > Untriangulate. This causes the object to maintain a rectangular wireframe. This is easier to edit. Those triangular faces are gone.

PD2PYkQl.png

9. Press Spacebar to unselect everything. Choose vertex mode and click the the vertex at the top of this axe. Now click right mouse button > .Move. > .Z. > Tab > insert 3.

FdrzjHfl.png

10. Choose face mode. Now select the same face as in the screenshot below. Do the same thing at opposite side and click right mouse button > .Extrude. > Tab > .Normal. > insert 2. Click RMB again > .Scale Axis. > .Z. > Tab > insert 2.

WEg8UeTl.png

11. Go to face mode and select the top faces of these two newly created piramid-like structures. RMB > .Scale Uniform. > .Z. > make it smaller.

8o8iaecl.png

12. Select edge mode. Time to select the edges of the handle. Now let's do some magic. Press 3. Yes, press 3. Now continue with pressing C (shortcut for Connect). Great job! You made some new faces which we can edit. Select these and press RMB > RMB on .Move. > select edge mode > select a random edge at the handle > RMB to finish action > move the faces to the center of the two blades.

Z6XTIKkl.png


ouI3DsKl.png


hSmH6OFl.png

13. While still having these faces selected, click RMB > .Extrude. > .Normal. > Tab > insert 1 > .Scale Axis. > .Z. > Tab > insert 1

WzckNWMl.png

14. Go to object mode and select the object. It should look like in the image below. Now take a look at the amount of polygons. Polygons = faces. This will become more when we export this triangular (automatic). We will learn later what polygons do.

vo5r.png


4. UV-mapping & Texturing

[size=6pt]1. Select the whole object in either face or object mode and click RMB > .UV Mapping. (at the bottom of the list).


OOzrPOyl.png

2. Wings3D shows a checkerboard texture with the faces of your model coloured with red. You can move these faces. But since we have edited the model, added faces and such, we will delete these. Select all faces in UV-mapping window with CTRL+A > RMB > Delete.

XM2o1sol.png

3. Now repeat step 1. Use RMB > Segment by > Projection. This window is used to unwrap your objects in separate surfaces. Click RMB > Continue > Projection Normal. Now you have sort of blueprint which can be used in Photoshop. Take a look at your model in the main window. Now you see the checkerboard texture on every face. But we don't want the checkerboard!


NzrTzFOl.png


cpcjaRTl.png


7UnHg5ml.png

4. You should have the UV mapping window opened. As you know the axe blades are metallic and the handle is wooden. In the next chapter we will create a texture which is divided in a metal and wooden part. Let's say the right side will be metal and left side wooden.

So we have a problem. The UV map of the axe is a mess.

5. Use face mode and select one face of a blade. Yes one face. Now press + until you selected the whole blade. Do the same for the other blade. Now move the UV mapped surfaces in the UV mapping window outside the actual texture at the right side..

6. Select a face of the pike and hold + until everything except the two blades are selected.
Now hold CTRL while deselecting the handle with the cursor. You have now selected everything except the handle and the blades, haven't you? Go to object mode (UV-map) and
Move it to the place I suggested in step 5.

As you see the UV mapping window is has a checkerboard with in the center our texture. Let me explain this. Every square is just a copy of the texture. So if make your UV mapped faces 100x as big, you will see lots of copies on your actual model in main window. This is handy if you have a homogeneous texture like rock, stucco, wood.

7. We have detected a problem! Not everything went well. It seems some faces are glued. You need to separate them. Do this by selecting everything and go to edge mode > RMB > Cut. Tip: you can unselect faces by holding CTRL + select with cursor.
Make sure Everything fits within one texture square and faces that need a metal texture are at the right and faces that need a wood texture are at the left side as shown in next image.

Tip: Rotate some parts while being in object mode, use Tab and insert 90 degrees to rotate it perfectly.

JtSdBGVl.png

8. Let's edit the actual texture. Click RMB > Create Texture. A new window pops up. Take a look at the various options for Size. You will notice different resolutions. The bigger the texture, the more it demands from your computer of course! It will also require more megabytes

128x128 - Low quality, only use if texturing small items.
256x256 - You shouldn't use this.
512x512 - Default
1024x1024 - Perfect if you need to texture complete walls.
2048x2048 - Used for skyboxes.
4096x4096 - Should never be used.
[size=6pt]

[size=6pt]9. Let's move on. You see behind Background another button. Namely Options. Click it. Make sure you tick Color. Press Ok. Your settings are now:

[size=6pt]Size: 512x512
Background: white
Draw Edges: yes
[size=6pt]

Click Ok. You have now a blueprint. Great job.


parkw6xl.png

10. Quit this window. We need the outliner. You can activate it by searching in the top level buttons, click Window > Outliner. Let me explain a few things.

ot3TqSUl.png



[size=6pt]Unnamed_object1
This is the object. You can leave it alone.

Weapons1
Old material, remove this by RMB > Delete

Unnamed_object1_auv
Rename it by RMB > Rename > insert "doubleaxe".
These three things are called materials. With other words, they contain the faces. You can assign faces to different materials. But that's not what we want to do.

AuvBG
Rename it by RMB > Rename > insert "doubleaxe".

This is the texture. We want to export this with RMB > Make External > Save it to some location Tip: Create your own library of textures with following folders: Textures > Double Axe

JZQM9gQl.png

11. It's time to open Photoshop. Open this .bmp texture (File > Open).

12. Do you feel we need textures as well? Let's visit:

http://cgtextures.com/

This site contains a lot of textures. You can download them freely.
Get a texture of metal.

13. Copy the image and paste it into photoshop. Now you have a new layer. You should consider your work in Photoshop as a desk. Layers are photo's you lay on the desk. That's the principle. This offers possibilities like hiding layers behind other layers. Move the layer in the north-east corner. Copy it by holding ALT+move. Make sure you have covered the whole right part of your texture with images of metal.


O4q5OHAl.png

14. Now do the same with a wood image. As final action; click on a layer RMB > Flatten Image. Now you have one single layer. Adjust the contrast/brightness by Image > Adjustments > Brightness/Contrast. Play with it. We need to darken it.

Zd1hkVVl.png


nOB8rFbl.png

15. Save it quickly with CTRL+SHIFT+S as a .BMP texture. Now save it as a .PSD file so you can edit it easily. If you start planning to make many objects, consider creating your own library with textures.

Note: Wings3D can only read the .BMP texture if you didn't move the file.

16. Time to create the texture, hehe. Save it as .dds in folder ...Warband\Modules\MyMod\Textures with minimal the following options:


DXT1 No alpha
Mipmaps: 12

NypkMRul.png

17. Go back to Wings3D. RMB on doubleaxe > Refresh. Congratulations! Your model is finished. If you don't feel so. Try to play with the UV map. (face mode > CTRL+A > RMB > .UV Mapping.).
Note: Making the surfaces in UV mapping mode bigger improves the quality.


AMIXNrCl.png




5. Importing in OpenBRF
1. Are you happy with your new model? Let's export it. Go to File > Export > click little box after Wavefront (.obj). Make sure the settings are same as below in the screenshot.

[size=8pt]
One group per material: ticked
Triangulation: ticked
Import Scale: 10.0
Export Scale: 0.1
Export normals/smoothing groups: usually ticked, but you can untick this (quicker export)
Export UV coordinates: ticked


fugx.png


lvvy.png



[size=6pt]You can untick Export normals/smoothing groups, because OpenBRF will do the work for us. For an explanation what they do see below:

Normals

We won't deal with this, you should skip this, because you don't need

to use it. But if you want to know it; normal maps are something which create a 3D view

of a flat surface. Look at the following images. The first one shows us an actual model

with many polygons, the second is a normal map. The third is a flat surface

rendered with normal map on. This creates a nice 3D view for free.

Now forget this and move on.



400px-Normal_map_example_with_scene_and_result.png

[size=6pt]

Smoothing

They mean the use of soft/hard edges. You can manually make

edges soft or hard. The difference is clearly visible at these images:


Soft:

ft5UHu5l.png

[size=6pt]

Hard:

xMrINvol.png


[size=6pt]
[size=6pt]2. Now export and replace the existing "dblhead_ax.obj" file. Rename it to doubleaxe.

3. Save your model again, but now as a .wings file. I bet you know how to do that. You use of course CTR+SHIFT+S.
Note: Give everything the same name. Photoshop file, .dds, .wings3d, .obj, texture, material. That's easier.

4. Time to open OpenBRF. Import the file with Import > Static Mesh. Time to explain something about OpenBRF. You can consider it a library of meshes, materials, textures and collision meshes.

Meshes - The actual models
Materials - Especially useful to assign shaders.
Textures -
Collision Meshes - Models consisting of solid faces which prevent you from walking through ingame.
[size=6pt]


EiQfwo3l.png

[size=6pt]5. We have now imported the mesh (object/model). Let's import the material & texture. We create these by clicking Import > New Material > tick "Also add new texture..." > rename "new_material" to "doubleaxe" > Ok.
If everything went well you should be able to see your model with texture applied to.

We have now 3 tabs. Mes1, Mat1 and Tex1. Mes1 stands for: Meshes (1x).
Go to tab Mat1 (materials) and change shader to "tex_mul_color" as visible below:


UaKjiSYl.png

6. Let's do some magic. This is very useful information, listen carefully; click the mesh while being in Mes1 tab: RMB > Recompute Normals > Ok. OpenBRF now automatically calculates the hardness of your model See chapter 4.17 - Smoothing of this tutorial.

Now pick "Color with Ambient Occlusion". OpenBRF will now create some basic shadows.

Do you see the tab Make a collision mesh. Don't click it, it's only needed for scene props (scene models; buildings, carts). Again a collision mesh prevents you from walking through the model. If a surface of this mesh is less than 90 degrees you will be able to climb ingame (handy for stair models).


HVwdHEGl.png

Time to learn you something important: polygons. Polygons = faces.
Select your mesh while being in the Mes1 tab. You will be able to view the amount of polygons. This should absolutely not be very high. Otherwise it demands too much from your computer. Here's a list providing averages for each type model:

Average amount of polygons per type model said:
[size=6pt]Normal helmet : 500
Average amount of polygons per type model said:
Full faced helmet : 800/1000

A body armor : 1000

A sword : 250
Special/Detailed sword : 400
Small axe : 300
Two handed axe : 400
Two bladed axe : 500
Lance : 150/250
Spear : 200/300

Shield : 400/500

Bow : 100/200
Crossbow : 300/400

Scene prop : 500-2000
[size=6pt]

You see we are far below the average amount of polygons, very good!
It's of course possible to make exemptions. Take for example my model of the St. Peter Basilica which is about 350,000 polygons. I have a lot performance problems with it, so try to avoid such models.


7. Save your .brf file in ...Warband\Modules\MyMod\Resource\, do this by clicking File > Save as.



6. Coding

1. Open the ModuleSystem folder. Now open this file: module_items.py.

2. Search for a similiar weapon (axe). So search for this: two_handed_axe. Copy the whole text to the bottom just before the ].

Code:
["two_handed_axe",         "Two Handed Axe", [("two_handed_battle_axe_a",0)], itp_type_two_handed_wpn|itp_merchandise| itp_two_handed|itp_primary|itp_bonus_against_shield|itp_wooden_parry|itp_unbalanced, itc_nodachi|itcf_carry_axe_back,
90 , weight(4.5)|difficulty(10)|spd_rtng(96) | weapon_length(90)|swing_damage(38 , cut) | thrust_damage(0 ,  pierce),imodbits_axe ],
[size=6pt]


3. Let's break it down:

["two_handed_axe", - Used as reference for other files. Change it to doubleaxe.

"Two Handed Axe", - The name the game shows to the player. Change it to Double Headed Axe.

[("two_handed_battle_axe_a",0)], - A refer to the mesh in the .brf file. Change it to doubleaxe.

The other pieces of code are weapon stats. Now save this file.
Note: the code is much clearer if you install ++Notepad.


MPTluxTl.png

[size=6pt]4. These files (.py) are Python files. You need to convert them to .txt files as stored in ...Warband\Modules\MyMod\. Do this by building the module. Start build_module.bat. You should not encounter any error. If you do, please fix it by re-opening module_items and searching for the problem in your new piece of code.
Below screenshot shows you a .build_module.bat without any error:

PH8A5L1l.png


5. Open ...Warband\Modules\MyMod\module.ini. Go to the bottom and paste this: load_mod_resource = doubleaxe. This tells the game to load your .brf file in the Resource folder.
Note: you can change 'doubleaxe.brf' to 'Weapons' if you want and import all items in that .brf file.



7. Test your model

Congratulations! You have modelled, textured and implemented your first model in Warband! Now start the game as soon as possible and test it. Ride to a town and buy your weapon (have patience, you will not find your weapon quickly).



Raaaaaaawr!!

QhTyPQql.jpg




Hope I've helped you! Many credits go to Yoshiboy for using some parts of his outdated tutorial. Don't hesitate to show your gratitude or questions to me!

Quintillius
 
Last edited by a moderator:
Detecting problems

If you have encountered any problem or error you might take a look at the list below:

1. Check the mesh is triangulated on export.

2. Make sure you spelled all names correctly in your .brf file. Don't use capitals for ease.

3. If you get a get object failed error what it means is that it is looking for either a material, a texture reference or a texture file which does not exist. Likely causes of this are - misspelling things, typos and not having .brf files loaded in module.ini. Spelling is case sensitive.

4. If you're getting a attempt to reregister error it means that its trying to load a material or texture reference twice. Common causes of this are - Using a material/texture reference name which already is used by M&B, Spellings/ Typos, loading a .brf twice in module.ini.

5. Double check your module.ini - if you have texture references, materials or meshes in the wrong order it will cause an error. Also if you have duplicated entries it will cause an error.

6. You can't modify these things easily: heads (requires vertex animation), hair (complicated shaders), hands (vertex animation), bodys/armors/clothes (must be rigged to mesh), horses (rigging), animated bows (vertex animation), props (requires collision meshes), buildings (collision meshes), interiors (collision meshes), animated map icons (vertex animation) ... with this technique. Those all require extra knowledge. This means you can edit things like swords (other weapons), shields, hats/helmets, etc..

7. Check the texture references; do they have numbers like 875435646 as a flag? That's wrong, replace with 000AA000.

8. Make sure you haven't added the extra lines:

Code:
load_resource = textures
load_resource = materials
load_resource = materials_face_gen

to module.ini . If (and only if) you have duplicates of these lines of code in the file then delete one set of duplicates.

9. If you don't get any errors but your mesh doesn't seem to appear in game then you probably have referenced the mesh wrong in the python files. Double check spelling and capitals and also remember that you should be using the name of the mesh inside the brf, not the name of the actual brf file itself.
 
Any tips on how to create decent-quality maps, could you pls help me out with zis :roll:

edit; I mean multiplayer ones. Your tutorial looks like the newest one, so I decided to ask 'ere :wink:
 
Alp said:
Any tips on how to create decent-quality maps, could you pls help me out with zis :roll:

edit; I mean multiplayer ones. Your tutorial looks like the newest one, so I decided to ask 'ere :wink:
There are special threads about "scening" which is what I presume you are refering to.
 
yus, gokzor, you got what I meant. Infact you are a decent scener/mapper and I could use your help too though dunno if you are available, uni thing, you know. Anyway bottomline is this nab needs some help.
 
Hey, first of all: Thank you for the tutorial. WIthout it, I think I wouldn't even have managed to come as far. Yet, I have a problem and couldn't find the solution for it, so I was hoping someone here could help me maybe.

I have a ready 3D model, made and edited in Wings 3D, exported and everything the way the tutorial said.
Wings 3D accepts the textures, and everything works fine. The model name is "aquila".
01_zps76b890f7.png

The textures are added to the folder as described as well.
02_zps20ba5f48.png
This is the original folder I keep the files in:
06_zpsf93783f8.png

This is my problem: It opens the file correctly, but it never accepts the textures.
03_zps0a842fc9.png

04_zps7bd66847.png

05_zps81bb845e.png

I am very sorry if this is the wrong place to ak this, but since I followed this tutorial I thought it might be the best place.

Thanks in advance.

 
Thank you for that amazingly quick reply! That sounds quite simple. One last question though, if I may. (It's my first attempt to add something to the game, so... please excuse eventual stupidity.) Which of the files has to be saved as .brf and when? I thought that once this worked I would save everything compiled as the .brf file, but apparently it is different, so do I just save my .obj file as .brf or? Or do I have to use the weapon_thingy and extract it to there?
 
If you open OpenBRF and import the .obj model, the .dds texture and create a material (you did so) you have actually made a library. You can save this library as .brf (OpenBRF file) in the ...Warban\Modules\<yourmod>\Resource folder. Use File > Save as. After this OpenBRF can read your .dds texture file which you have saved in the \Textures folder.
 
Back
Top Bottom