login

Author Topic: Adding new items to m&b using Wings 3d (now with pictures!)  (Read 38990 times)

Yoshiboy

  • Guest
Adding new items to m&b using Wings 3d (now with pictures!)
« on: January 09, 2007, 11:25:07 AM »
NOTE: Lots of people are having problems with the tutorial. Some quick things to check if you're having problems:

1. Check the mesh is triangulated on export.
2. In your BRF containing the mesh, make sure BRFedit didn't import any extra materials or texture references. Take a look in the material and texture tabs and delete any entries.
3. Double check all names for spelling etc.
4. You can't modify heads, hair, hands, bodys/armors/clothes, horses, animated bows, props, buildings, interiors, animated map icons ... with this technique. Those all require extra knowledge.
5. Check the texture referances; do they have numbers like 875435646 as a flag? That's wrong, replace with 000AA000





This tutorial will take you through the process of adding new items to mount and blade using wings 3d, although many of the techniques discussed can be applied to other programs. Wings 3d is a free modelling program, it can be acquired here. For information on learning how to use wings3d you can look at the official forums tutorial center: found here. Although many of the links are broken there are many good tutorials if you have a little more of a browse. The other most most essential wings3d site is PPs wings3d center. That can be found here. In all honesty, sometimes it can simply be best to learn wings3d by spending lots of time messing around and learning about 3d modelling theory.


Wings3d is the program i use for all my 3d modelling and i find it extremely useful. Although a prior knowledge of the program will help you greatly, it is not completely needed. I will try to give as many hints and tips as i can if your not familiar with the program. The UI is pretty easy to work out, which again is a plus when starting out.

Lets give a run down on the camera, as people seem to have trouble. The wings camera is THE BEST camera for any 3d app IMO :P

Press down the middle mouse button to go into tumble mod. Scroll the middle mouse to zoom in and out. While in tumble mode, press Q to switch to pan mode. With a selection, press the A key to center your view on the selection, this one is incredibly useful. Space is the shortcut for deselect all. Not related to the camera, but still hugely useful.

If you have two mouse buttons and are missing a scroller ball then go "edit > preferences" Select the camera tab and change the number of mouse button to two. When in this mode holding ctrl and pressing the right mouse button will put you into tumble mode, and while in this you can zoom by holding down the right mouse key and pulling the mouse back and forward.

Anyway:

For texturing my meshes i use Adobe Photoshop, paint CAN be used but any more advanced program is much better. Gimp is also a good program to use, and free. http://www.gimp.org/

If you are wondering how to unwrap in wings 3d, take a look at my unwrapping tutorial here

another useful unwrapping tutorial in wings is this

Another one you can find here although that one refers to using an existing M&B texture and therefore material, our tut is set up for making a new texture and material.

You will need only one more tool to complete this tutorial apart from wings3d and some kind of texturing program:

Thors BRFEdit model importer/exported, which can be found here (thank you Thorgrim :) )

you will also need some kind of *.DDS conversion tool or plugin for your 2D graphics program. This is so that M&B can read the texture files.

here is the .dds converter

here are the tools for adobe Photoshop

Step 1 - Setting up your own mod file

Before you start you need to make your own mod file. To do this go into the "modules" folder, located in the mount and blade program files and duplicate the "native" folder. Re name it whatever you want your mod to be called.

Now, in this file you want to look for a file called "module.ini" this file basically tells mount and blade what files to load for your mod. You want to make sure the line:

Code: [Select]
scan_module_textures = 0
looks like this, with a 1 at the end.

Code: [Select]
scan_module_textures = 1
This tells mount and blade to look for new mod-specific textures.

After you have done this look in your mod folder, there should be some folders. Look for one called "Resource" and one called "Textures" . The "Resource" folder is for all your new meshes and materials and the "textures" folder is obviously for all of your new textures.



There are 3 main types of .brfs you will need in this "resource" folder.  You will need a material BRF for all of your new materials, a textures BRF for a reference to all your new textures and the final type of BRF is simply to store all of your mesh data. Once you get proficient at modding you will realize that you can in fact have materials, textures and meshes all in the same BRF, but for now, to stop you from getting too confused we will separate them out.

At this point, you should have set up the basics of your new mod and should be ready to start making your mesh!

Step 2 - Importing a mesh into wings3d

This step is primarily for getting a sense of scale of the M&B items compared to yours. It can also be useful to export M&B items for other things you are working on.

First you have to work out what kind of new item you are going to add. For the sake of this we are going to be adding a new hand held weapon to the game, like a sword. :)

Load up Thorgrims BRF editor.

Click on the 'open' button at the top left and go into mount and blades program files and find the folder in it called "commonres". This folder is full of all of the normal M&B BRFs. In here you select the group of meshes you want to get reference from. The one for weapons is called 'weapon_meshes1' . So we will go ahead and open that.



You should see a list of the meshes on the left with a preview of what the mesh looks like in the window to the right. Find a sword or weapon that looks appropriate or is similar to what you want to make.

You then want to select it from the list and click on the "export" button. Make sure you are exporting as an .obj file and find a suitable directory to export it into.



Close Thorgrim's BRF editor for now and go and open up wings3d.

Click on File > import and select the little box next to the 'wavefront (.obj)' option. This should open a little importing options menu.



Keep the swap Y and X axes box ticked but change the import export scales to:

Code: [Select]
Import Scale: 10.0

Export Scale: 0.1

Click ok

This will keep the objects to the correct scale when importing/exporting them and is very important.

Browse to your mesh file that you just exported and double click it - it should appear in the wings viewpoint.

Step 3 - Getting your new mesh set up in wings3d

Now that you have a mesh in wings3d and to scale, you want to get your new mesh which you want to add to M&B into wings as well.

It is important that you take notice of the center point of the scene, this is where the hand of the player will appear on the mesh for swords and most other items, this might be different for other items, but it will always be important.

If you want to make your own model now to import into M&B here are a few tips ;)

if you go "window > geometry graph" a new little window should appear with all the objects in the scene. There are a few little icons next to the objects. The padlock icon and the eye icons are the ones that interest you here. If you want to make sure you dont mess around with the imported mesh or a referance pic you are working off make sure you click the padlock. This will stop you from being able to select the mesh or manipulate it. Clicking the eye will make whichever object it is next to not visible. This is also useful when making a new mesh or cleaning up an imported one.

Which leads us onto the next technique. You can import a mesh from most programs. Wings 3d has quite a few import options.

If you have imported your model from another program you will want to look for any import/export problems that occured:

If you see any blue faces these faces have been set to "hidden" (or are assigned the "_hole_" material) and will not show when rendered. If you dont want these faces to be hidden simply click on them, right click, go 'material' and set their material to 'default'. These faces are important because in other modelling programs and in M&B they will not be shown at all.

Another way to look for mesh problems is to press tab (render or smooth view) and see if any faces appear totally black or stand out to the normal mesh. These areas need sorting out although going into how to sort out messy meshes could take all day ;)

Messy meshes can be very bad and will probably turn out even worse on export and at worse crash M&B or BRFedit.

At this point it is best to save your wings scene with your new model to export in and close wings3d.

If you want to learn some basics of modelling there is an excellent video tutorial series here:


Step 4 - Setting up a texture

Ok, at this point I am taking into account that you have already UV mapped your mesh and put it onto a new texture you have somewhere and all that is fine and dandy. If you don't have a clue what I'm talking about you will want to look for a link near the top for my tutorial on UV mapping and unwrapping. You can also check out the video tutorials in a link a few lines above this.

Now we need to set up the material and reference for the new mesh. Lets look at those other two BRF types i talked about.

You need to get your texture file in .DDS format and place it in your "textures" folder in your new mod folder. Take note of the name of it.

Open Thorgrim's BRF edit again and near the top you will see a series of tabs named "mesh", "mat", "tex", "col", "skel" and "shader". These are essentially the different types of BRF files that there are. The only ones you need to worry about at the moment are "mesh", "mat" and "tex" as these are your mesh, material and texture BRFs.

Now you need to create your new texture references. Click on the "tex" tab and press the add button near the bottom. Similarly to before this will create a new entry called "default_texture.dds". In the name box you will want to change this to the name of your new texture file you added to the textures folder (keeping the .dds at the end). Don't worry about the flags box, leave this as it is. You now have your texture reference, so like before go "save" and browse to your module resource folder (the current location might well be in the native resource folder, you don't want to be there) and save the BRF like you did before, for example: "my_new_textures".



This may pop up a box asking if you want to add the brf to module.ini - you can do this, as it will save time later on down the line, but if you think it will confuse you then don't. This tutorial will continue as if you have not added it.

Next we need a new material.

Go "File > New" at the top of the editor and click on the tab named "mat". Near the bottom press the button named "add". This will add a new material called "default_material" to the list of materials. Click on this material and you will see some of it's properties listed to the right.

In the Name box you will want to put the name of your new material, this can be anything but I would stay away from using spaces or things that will become confusing later on. In the diffuse Box you need to put the name of the texture you want for this material. This will be the texture you just added to the Textures folder. In the shader box just leave it as "tex_mul_color_alpha". The rest of the boxes you can also leave for now. Most of those are used when you want to create more complex textures. Make sure you press the "set" button to save changes. You have now created your new material! Click save, browse to your mod resource folder and save the BRF. Again it can be called anything but its probably good to call it something that wont get confusing and something without spaces. For example: "my_new_materials".



Again you may get a message about adding to module.ini - do the same as you did for the first time you got the message.

Once you have done this, you have finished making your new materials and texture referances! Well done!

Step 5 - getting the mesh into Thors BRF Editor

Open up wings and load up your scene with your new mesh to export in.

Now you want to export the mesh so click: File > export > wavefront (.obj) > click on the little box next to it like you did for importing

here you are presented with a few options -

The first box should be ticked, with the second left unticked.

the tesselation should be set to triangulation.

Keep the swap Y and X axes box ticked but change the import export scales to:


Code: [Select]
Import Scale: 10.0

Export Scale: 0.1

sub division steps should be set to 0

the last two tick boxes should be ticked and the last option asking which the default texture export should be set to doesnt matter so leave that how it is.



Click ok and find a directory to export your mesh to.

You now want to close wings 3d and open up Thors mesh editor.

Click on the import button and find your .obj you just exported.

The export will appear on the bottom of the list. Scroll down and click on it. You can now set the name of the mesh by typing in the 'name' box and clicking 'set'
In the material box, type in the name of the new material you just made and click 'set'

Here there is a little quirk of BRFedit where by it will sometimes import a material which you had assigned to the mesh in wings3d. We don't want to load this material so browse to the materials tab of BRFedit and if there is a material or two listed there select it and press "delete" to remove them.

Once you have your new mesh in the BRF, click 'save' at the top and browse to your mod's resource directory. Enter the name for your new BRF. For example - "my_new_weapons.brf"



And you have your new mesh stored in the BRF :)

Step 6 - Telling the game to load your mesh

Ok, once you have your texture in the right folder and your 3 new .BRFs in your Resource folder you want to edit that module.ini to make it use all these new files! (don't worry that its a .ini file, it can easily be edited with notepad or any other text editor)

Its quite a simple process really.

First of all you need to tell mount and blade to call your new textures BRF. (its important the order you load the BRFs. Texture references come first, followed by materials, followed by meshes)

simply add the line

Code: [Select]
load_mod_resource = my_new_weapon_textures
(replacing "my_new_weapon_textures" with whatever your textures BRF was called)

Its important you add this  line before the line:

Code: [Select]
load_resource = textures
Once this is done it needs to refer to your new materials file. This is done in a similar way. Add

Code: [Select]
load_mod_resource = my_new_weapon_materials
(replacing "my_new_weapon_materials" with whatever your materials BRF was called)

again its important you add this before the line:

Code: [Select]
load_resource = materials
Ok, now it should know to load your new materials and textures BRFs. You need to tell it to load your new meshes BRF. This one is pretty easy, after the line:

Code: [Select]
load_resource = materials_face_gen
add the line.

Code: [Select]
load_mod_resource = my_new_weapons
(obviously replacing "my_new_weapons" with the name of whatever your meshes BRF was called)



Once this is done, save module_info.ini

Ok, your very nearly there! Just one more step!

Step 7 - getting the mesh in game

Before you can see it in game you need to set up a new object with the mesh. For this we are going to use the python scripts. Read this thread for information on how to get started on the python scripts.

Once you have got all of the python scripts set up and referring to your mod you will want to create a new item that uses your mesh. To do this we use module_items.py
there is lots of information on using module_items.py in winters brilliant documentation found here.

There we have lots of information including creating a new item, when you have created this new item. In the part where you enter the mesh name, simply enter the name of your new mesh.

compile the scripts, and thats it. Your done. All you need to do is start up mount and blade and look around the shops.

Alternately you could add the item to the zendar chest so you can check it out quickly.
The zendar chest is actually a troop. This means that we want to open up module_troops.py and scroll all the way down until you find the entry for the zendar chest. You simply put the name of your item in the zendar chests inventory. So that the entry looks something like this (with my example item being "my_new_item"):

Code: [Select]
  ["zendar_chest","zendar_chest","zendar_chest",tf_hero|tf_inactive, 0,reserved,  fac_vaegirs,[itm_my_new_item],def_attrib|level(18),wp(60),knows_common, 0],
If you are still having trouble with module_troops.py then winter has the full length brilliant documentation here.

compile the code again, start M&B and there you have it, your first new item.



Happy modding!

ending points

Take note that if you want to add multipal items you still only need the 3 BRFs, you simply add more materials to the materials BRF, more textures to the textures BRF and import more Meshes into your meshes BRF.

After doing this, if you want to try importing new scenes and scene props, take a look at my extension tut here

if you have any questions about the tut or most things about wings3d i am the person to ask :)

PM me or e-mail me. It might be better than spamming the thread :)

I hope you liked my tut.

Yoshiboy
« Last Edit: October 18, 2008, 09:09:40 AM by Yoshiboy »

wihzzahrd

  • Guest
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #1 on: November 14, 2007, 04:28:57 PM »
Helped me a lot, thank you.

R4byde

  • Guest
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #2 on: March 01, 2008, 11:52:52 PM »
Sorry to necro this post; but I've followed it to the letter and keep getting a weird error.


CLICK HERE FOR FULLSIZE
http://img85.imageshack.us/my.php?image=painse5.jpg

Does anyone know what could cause this? I've already searched this and the TW forums but that came up blank.

Thanks.
« Last Edit: March 01, 2008, 11:55:11 PM by R4byde »

Yoshiboy

  • Guest
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #3 on: March 02, 2008, 05:00:47 AM »
Sorry, not sure. That could be anything. I would check all the names of your new stuff to make sure they don't use any funny characters.

R4byde

  • Guest
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #4 on: March 02, 2008, 09:32:48 AM »
Dang! Guess that means I just keep looking for what I did wrong. Thanks for the great tutorial by the way.

Offline Ron Losey

  • Master
  • *****
  • Posts: 4418
    • View Profile
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #5 on: March 05, 2008, 05:57:10 AM »
Dang! Guess that means I just keep looking for what I did wrong. Thanks for the great tutorial by the way.

What are you building, and what did you add?  If you can post some of your code, or upload what you have of the mod so far, somebody might be able to help you debug it.  But that is hard to do, if nobody has any idea what you added.

Also, whatever you added, try eliminating a piece at a time.  If all you added was new items, try eliminating all but one of them and running it.  Isolate the problem.  That will make it much easier for you, or for anybody else to try to help.

R4byde

  • Guest
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #6 on: March 05, 2008, 03:43:46 PM »
It's nothing wrong with my model or how I was adding it. All I did was alter the falchion mesh to look more like the brush knives some armies used to give to their artillery-men. The problem seems to be that I can't compile my new scripts (or even scripts from native) without getting a weird assertion error halfway through M&B's startup.

See my post here for more details. -> http://mbx.streetofeyes.com/index.php/topic,792.45.html

mrfredman

  • Guest
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #7 on: June 08, 2008, 07:30:52 PM »
First off, this tutorial was awesome and super helpful, thanks so much!

I've finished the tutorial, all the python scripts are in order, and everything is ready to go, but when I boot up my mod I get this error:

RGL Error
get_object failed for texture: hair_white

I think I have a guess as to why its happening, bu tmaybe you guys can help me with some troubleshooting. Oh also it crashes during the loading screen when it says its loading the INI file. So I'm assuming the problem is. This is what my INI looks like (at least the begining where i modified it)

module_name = Caldaria
map_min_x   = -105
map_max_x   =  105
map_min_y   = -105
map_max_y   =  105
map_sea_direction = -40
map_sea_speed_x = 0.02
map_sea_speed_y = -0.02
map_river_direction = 140
map_river_speed_x = 0.01
map_river_speed_y = -0.01

# use meshes map_tree_a through map_tree_r on for map trees
map_tree_types = 17
map_snow_tree_types  = 3
map_steppe_tree_types = 5
map_desert_tree_types  = 0

load_resource = textures
load_mod_resource = my_new_textures
load_resource = materials
load_mod_resource =  my_new_materials

Then, as you told me too I have this:

load_resource = town_houses
load_resource = doors
load_resource = churches
load_mod_resource = my_new_weapons

The rest is untouched from the regular ini.

I'm assuming this issue is happening because I'm telling it load textures right at the begining instead of where its used to. Is that the issue? And is so, how should I fix it? And if not, whats the actual problem, and how do i fix that?

Thanks a bunch!

Offline Ron Losey

  • Master
  • *****
  • Posts: 4418
    • View Profile
Re: Adding new items to mount and blade using Wings 3d (free)
« Reply #8 on: June 08, 2008, 07:44:43 PM »

RGL Error
get_object failed for texture: hair_white


Generally, this would mean that in your .BRF file, you have a material reference that calls for the texture "hair_white.dds", but the texture is either not there, or not listed in a BRF under textures.

conongmoi

  • Guest
Re: Adding new items to m&b using Wings 3d (now with pictures!)
« Reply #9 on: November 20, 2008, 06:28:45 PM »
Thanks to YoShiBoy and Ron Losey very much !
You are so great !  :)

I've fixed my error as mrfredman !

Thank you ! ;)