View Full Version : Merging Models Tutorial
Original Thread for Discussion (http://www.lucasforums.com/showthread.php?t=167209)
Lord Spartan asked me if I could explain better how to merge models, so I decided to make a tutorial step by step, this first part is about loading the file in Gmax and organizing the workspace. I'll be using the model pmbil as a base, and we will merge another body model mesh.
1. The Tools
1.The Kotor Tool by Fred Tetra you can find here:
2.MDLops by Cchargin:
3.Gmax, if you are new to 3d modelling you should download the tutorials and help files too:
4.Nwnmax for Gmax:
2. Loading the model
Once everything is installed and working let's create a folder for the project....I'll call it NewRobes. Next we extract the pmbil model from the game to NewRobes folder, to do that open Kotor Tools and select:
Kotor I -> BIFs -> models.bif -> Aurora Model -> pmbil.mdl
Then press the button “Extract File” and save the file on NewRobes folder.
The model's name is codified:
p -> player model
f or m -> female or male model
b or h -> body or head model
a or b ->underwear or cloths model
l, m or s -> large, medium or small body (soldier, scout or scoundrel)
a, b or c -> asian, black, caucasian skin colour (for heads) the number is the portrait used.
Extract the .mdx file and save in the same folder.
Kotor I->BIFs->models.bif->Aurora Model Extension->pmbil.mdx
To extract the texture used by the model:
If you don't know which textures the model uses I'll show you later how to find it. If you double click over image the image viewer will show it, if there is nothing written in the white box we can press the “Extract file”, select “Save as tga”, and save it in the same folder.
But our texture has a text there, so we will copy it to a text file too, to do that we check the “Export Selection to TXI file”, select the text, press “Write File”, we save it in the same folder as the model files.
Now in NewRobes folder we have four files pmbil.mdl, pmbil.mdx, pmbi01.txi and pmbi01.tga.
We are going to convert the pmbil.mdl from binary to ascii file, using MDLops. Start MDLops, activate “Kotor 2” button, and press “Select file” button, and select the file pmbil.mdl.
I usually let the “Extract animations” checked, I have seen some tutorials that says it should be unchecked though... Then press the “Read and Write model”, it will create a pmbil-ascii.mdl and pmbil-textures.txt file inside the NewRobes folder. The pmbil-textures.txt file tells which textures is used by the model, it is very useful if the model uses many textures with different names.
Now we start Gmax, remember to start Gmax not using its icon, but using Nwmax's icon, it will start the Snooper script too, without it you will have to paste the text from the Gmax's listener and copy on a text file to export the model. Gmax will start and the Nwmax roll-out will open.
To import the model we select it in the Nwmax roll-out “MDL Loading”, in the file name we use the browse button to select our pmbil-ascii.mdl file, in Options check “Import Geom Only” and then press “Import” button. The model and a lot of other stuff will appear in the screen. Minimize the Nwmax roll-out.
On the screen we have 4 panels...the Top, Front, Left and Perspective views, when you click inside one of the panels it is activated and it is shown by turning its board gray instead of the default dark blue.
You can change one panel to the other right clicking on the panel's name and selecting it in the menu, or using the shortcuts, T to top, B to bottom, L to left, R to right, F to front, K to Back (on Kotor models front and back are reversed), P to perspective, U to user view.
Now with the perspective panel activated we go at the bottom right of the screen where there are some tools to manipulate the visualization of the 3d space.
Some tools have only one option of use, but others have a small arrow on the right below it, if you put the mouse over the icon it will shows what the tool does, if you click on the icon it will turns orange showing that it is activated, if you hold the click it will show the other options for the tool as more icons, and to deactivate it just right click on the panel.
The default icons are from left to right and top to bottom,:
Zoom (shortcut key Z);
Zoom All – it zooms on all panels at same time (shortcut key assignable);
Zoom Selected – zooms selected objects (shortcut key E) or Zoom Extents (option)– zooms all the objects in the scene (shortcut key CTRL+ALT+Z);
Zoom Selected All – zooms selected objects in all panels (shortcut key assignable) or Zoom Extents All (option) - zooms selected in all panels (shortcut key SHIFT+CRTL+Z);
Field-of-view (works only on perspective panel – works as a zoom) or Zoom Region (option) – zooms a piece of the space delimited by the mouse (shotcut key CTRL+W);
Pan – moves the panels to the sides or up-down (shortcut key CTRL+P);
Arc Rotate – rotates the view (shortcut key V or CTRL+R);
Min/Max Panel – minimizes and maximizes the panel (shortcut key W);
So, with the perspective panel activated let's click on the “Min/Max Panel” (shortcut W), and it will increase the Perspective panel to fill the place of the 4 original panels.
Now use the visualization tools to see what we have on the 3d space... remember that if you want to undo the visualization you need press SHIFT+Z and to redo SHIFT+A.
I've used the arc rotate and zoom to get the image on the left on the maximized perspective panel. Here in the 3d scene we have the painted model's mesh which is the model that we see in the game.
There are some wire blue boxes , they are called helpers, they are used by the game to place other models or visual effects on the model's body. We should not change them, and we will use the bigger one at the base of the model to export it back to the game.
There are some colored solid polygonal forms, they are the bones, it means that if you move or rotate them, the body's mesh will deform or move to follow the movement. We will not use them yet, they are only used on Gmax when we need to fix the bones deformations, we will do it after the modeling and texture is done because if we change the number of vertices of the model the bones weight on each vertex will be recalculated and we lose part of the work done, this bones are used to create the character's shadow in the game too. And there are some white wire tetrahedron and icosahedron forms, they are bones too, but they are used to place the solid bones.
Let's save the file, go to the “File” menu and select “Save” choose a name and after the name add a number (for example: Robes_01) save it in the NewRobes folder.
Now, next time we save it after we have made a big change on the model we can use the “+” button that appears in the save dialog windows and it will save it as a new version, if you don't want to save as a new version you can use the CTRL+S to save over the file.
So let's select only the meshes and hide everything else that we won't be using by now, when we click on the “Select by name” icon (shortcut key H), on the top tool bar in the screen.
It will open the “Select Object” window check the “Display Sub tree” this will show a tree showing the hierarchy between the meshes, which are linked. In the list we will select the names, with the CTRL key pressed: torso, LArm, Rarm, feet.
Those are the meshes that of body, that we see in the game, once they are selected in the list, press the “Select” button, and in the 3d scene you will see those meshes with a white wireframe around it, to show that they are selected.
Now we will save this selection, with those 4 meshes selected write on the white space of the upper toolbar the name of the selection (for example: Mesh), then press the ENTER key.
To deselect those meshes click with the left mouse button on the 3d scene, now if you want select the meshes back, just select it on the toolbar using the arrow to browse the names of the selections.
With those 4 meshes selected, let's hide them clicking with the right mouse button in the 3d scene a red menu will appear, select “Hide Selection”.
Now we are left with only helpers and bones, let's separate them too... in the “Select by Name” icon open the “Select Object” window and select everything that has an _g at the end of the name, it will select all the bones, if the window closes, just call it again and continue the selection. Once you are done call the red menu and use the “Hide Selection”, if there is no bone left on the scene undo the hide (CTRL+Z) and name the selection as Bones and hide them again, now we have only the helpers.
Select all that is left using the “Selection by Name” icon and create another selection called Helpers, and hide them too.
Now we call back the mesh just selecting it on the name of the selection, a warning box will appear to tell that the objects of that selection is hidden and asks if you want it to bring them back, click yes.
Now we have only the 4 meshes on the 3d scene, it is a good time to save your work.
There is a problem with the uv map of the model, the texture is not in the right place, but as we are not going to use it anyway there is no reason to worry.
One important step is chose the right base mode for the model we are going to merge, in the model we've choosen (pmbil) the feet and gloves are separated from the whole torso, so the mesh we are going to add must be separated the same way, otherwise we will have problems with the bones as their configuration fits how the mesh is separated.
We can use a model that already have the same separation, Carth's cloths for example would fit well as it is separated the same way, or we can remodel our model to fit it.
Here I remodeled Carth's cloths to fit his underwear bone configurations.
That is how I load the base model, in part II we will see how to import and merge the new model.
Here is the second part, not the merging yet... but it is coming!
3. Preparing the model
Now we are going to work in the mesh we want to merge in our base, there are three reasons we want to merge meshes on the bases:
1.we have a new model modeled on another 3D program or even in Gmax/3DMax but it is a file without all the aurora base polygons/helpers/bones.
2.we want to merge parts of different models, for example, the torso of one model, the legs of other and the arms of a third one.
3.we have remodeled a body model from one game and want to port it to the other. If someone knows a better way to do it let me know, but remember that porting is illegal, only do that if the model you worked with is in both games.
I'll cover all those situations, the 1st and 2nd requires some modeling and UV editing/texture painting, and all of them will require bone weighting. So in this part we will talk about how we go into modeling in Gmax.
3.1 Importing a new model into Gmax.
Lord Spartan exported one of the body meshes to another program to remodel it, that is why he asked about merging, how he can add his new model into the game? So I have here the 3DS file of his model and we are going to import it into Gmax.
Start Gmax and open the file we loaded in the first part of this tutorial (Robes_01.gmax) and hide everything.
In the “File” menu click in the “Import”, choose the .3DS file and click ok in the 3DS Import warning, with “Merge objects with current scene” checked.
And in the next 3DS Import warning click no.
As this model was extracted from the game it follows the same division as the original model, the torso is separated from the arms and legs. But even if it was one whole piece we could just cut them to fit the bone setup. And both models are the same size.
With all those separated parts selected let's save this selection the same way we have done with the bones, helpers and mesh, name this selection model.
So let's see how the original model was constructed and them compare with our new model to see if it requires any modeling. Hide the Model Selection and unhide the Mesh selection.
Select only the torso by clicking with the left mouse button over it, and click on the “Modify” icon on the Gmax roll-out.
Here is where we control what we are changing in the model. Under the “Modify” icon there is the name of the mesh, in this case Torso, and the “Modifier List”, with the “Skin” and “Editable Mesh” modifiers.
Those modifiers are applied to the mesh to modify it somehow, using the “Editable Mesh” modifier we can move, delete, create vertices in the mesh, it is here that we model the it.
The “Skin” modifier is used to apply the bones to the mesh, and to change the influence of the bones over the vertices of the mesh. We shouldn't change the order that the modifiers are applied on the mesh.
If we wanted to change the mesh texture we would need to change the meshes' Uvmap for that we apply the “Unwrap UVW” modifier on the Torso mesh.
Select the “Editable Mesh” modifier, because we want apply the “Unwrap UVW” modifier over the “Editable Mesh” one, when you select it a warning will appear to tell you that there is another modifier, the “Skin” that depends of the “Editble mesh” and if you change or add something between them something weird can happens, just say yes.
Now we click on the arrow beside the Modifier list, a big list of modifiers will appear and we select the “Unwrap UVW” in the “UV Coordinate Modifiers”.
Ok, we have the 3 modifiers we need to change our model to use it in game, under the list there are some icons, the second one (show end result on/off) when it is active it is white and it shows the effect of all the modifiers applied to the mesh on the 3d scene, when it is deactivated it is half white and half gray, it shows only the effect of the modifier selected. Some modifiers doesn't allow it show the effect of others... for example the “Editable Mesh” when selected, it doesn't allow the “Skin” modifier shows its effect, even if icon is white. The light bulb turn on/off the modifier, but you can not see the difference now.
So let's see how each modifier works (good time to save your work) ;).
Select the “Editable Mesh” with the left mouse button, say yes to the warning, and click on the “+” icon beside the “Editable Mesh” modifier name. You will have a list that what can be selected and modified on the model.
Select the “Vertex” (selection mode) and you will see blue points all over the model, they are the model's vertices. If the vertices are blue it means they are deselected, when they are selected they are shown as red.
To select a vertex or any other geometry (once its selection mode is selected) you just need to left click on it or create a box with the left mouse button. Once a few are selected you need to press the CTRL key to select more or the ALT key to deselect some of them. If you want to view the edges too you can activate /deactivate it pressing the F4 key.
Under the modifier stack there are some options and tools to select and manipulate the geometry. It is a long panel that can be moved up and down with the mouse when the mouse icon turns to a hand.
The first part of it is “Selections” options.
There is a row of icons, they are “Vertex”, “Edges”, “Face”, “Polygon” and “Element”, you can activate them here or use the list under “Editable Mesh” modifier.
To select a polygon you need to use the “Face” or “Polygon” selection and click on the polygon, only its borders will show selected in red.
Some meshes like the torso is composed of many separated pieces of meshes, you can see the pieces using the “Element” selection, all the polygons of the separated piece are shown.
By selecting the elements of the torso mesh we see that it is one mesh composed of many smaller separated pieces.
This separation is important when you don't want all your model to be smoothed. All the edges of connected faces are rendered by the game as smooth, and the disconnected ones have a hard edge where it is not connected. Those hard edges are good for separate different pieces of cloth of the model.
In this Carth model, for example, you can see this seam in his arms because there is a cut necessary for the uvmap, and as Mdlops don't use the “smooth group” information from Gmax yet it can not be smoothed, so we get those seams, all the other faces of the model are connected so it is smoothed, there is no hard edges.
Let's see the elements of our new mesh... click in the “Editable Mesh” modifier to disable the mesh editing, hide the mesh and unhide the new model.
Here in the modifier list we have only the “Editable Mesh” modifier, click on it and select “Element”.
Now click over the model to select its elements.
In this case due to the export/import when we select its pieces we only get one face (the face we clicked over), it means that in each face its vertices are not connected with the vertices of their neighbour faces, it will require some modeling to weld all those vertices together and separate the pieces. If we put this model in the game as it is we would see a seam around each face.
3.2 Basics of Modeling.
Once we have some element selected (i.e. vertices, edges, face, polygon or elements) we can move, rotate or scale them, using the appropriate icon from the upper toolbar.
With some element selected we activate the “Select and Move” (cross arrows) icon, clicking and holding on the selected element and moving the mouse we can move the selected element.
If you want more control over the movement, like controlling in which axis or plane to move, you can use the the icons “X” (shortcut key F5), “Y” (shortcut key F6), “Z” (shortcut key F7), to restrict the movement on those axis, or use “XY” icon and all the plane options from the “XY” icon to restrict the movement on the planes (the shortcut key F8 will cycle through all the plane restrictions) after the element you want to move is selected and the “Select and Move” icon is activated.
Instead of using the axis and planes restrictions we can use the “Transform Gizmo”, if it is not activated yet you can activate it selecting the menu “Customize” and “Preferences”, it will open the “Preferences Settings” dialog box, select the “Viewports” tab and in the bottom check the “On” in the “Transform Gizmo”. Now you will see a XYZ colored axis when you select something, and now when you put the mouse over one of the axis it will turn orange and if you click and move the mouse the selection will move only on the orange axis direction.
You can restrict the gizmo by the planes too, by passing the mouse over the corner of the plane formed by two axis it will turn orange and then you just hold the mouse button and move. Even using the gizmo you can still call the restrictions using the icons or shortcuts.
To do a rotation you need not only select the element but define around what it will rotate, it is defined by the icon on the left of the “X” axis restriction icon. The default is “Use Pivot Point Center”, it will rotate using the center point of each element selected, if they are connected they will behave as one big block.
But you have more options when clicking on the icon and holding it a little, “Use selection Center”, that will use the center of all the selections as a rotation point, and “Use Transform Coordinate Center”, that will use the pivot of the model as a rotation point, but as it is parented to the big helper on the floor it will be big helper's center, on the 0, 0, 0 coordinate. Once the rotation point is selected, it works the same way as moving, you select the element, select the restriction by using the icons, shortcut, or the gizmo and click move the mouse, it will rotate around the axis/plane selected.
To scale the elements you need to specify again define the point around which it will happen, using the same icons we used for the rotation, then you will be able to scale the elements as separated entities using the “Use Pivot Point Center”, approach or keep them away using the “Use selection Center”, or approach or keep them away from the model pivot point using the “Use Transform Coordinate Center”.
The scaling tool has some options, the default is the “Select and Uniform Scale”, that will scale the same amount to all axis direction, once this option is selected you can not restrict any axis or plane. The “Select and Non-Uniform Scale” that works like restricting one axis, it will scale on only one this axis direction, and you select the axis using the restriction icon, shortcuts or the gizmo . And the “Select and Squash”, that works like restriction on a plane the scale will happens only on the plane directions, and you select which plane by the restriction icon, shortcut or gizmo.
Only by selecting and moving vertex you can make some small changes on the model, and if you do only that without changing the number of vertices you could use Taina's Replacer to export the model to the game. But to make bigger changes as we are going to do here we will need to know some modeling tools, so we are back to the modifier list and the “Selection” parameters.
Bellow the icons there are some selection parameters. When the “By Vertex” is checked means that when you are not using “Vertex” selection, if you select a vertex all the elements around it will be selected too, for example, you are on “Edge” selection and if you click on a vertex all the edges around that vertex will be selected. Remember to deselect it to be able to select only the edges...
When the “Ignore Background” is checked you can only select elements that you see, when it is not checked you can select elements that are behind the model too... we will be checking and unchecking this parameter a lot when modeling! The “Hide” and “Unhide All” are very useful too, it will allow you to model more freely without worry with selecting/moving/deleting parts of the mesh by mistake... just select the part of the mesh you don't want to see or manipulate and click the “Hide” button, to turn it back just click the “Unhide All”
The next is “Soft Selection” which we will not use here, when you activate it and select a vertex, all the vertices around it will be selected too, but by different weights that depends of its distance from the vertex selected, and when you move the selected vertex, the others will follow, depending of its weights.
Then we have “Edit Geometry”, we will use it a lot for modeling, and because it changes the number of vertices we won't be able to use Taina's Replacer, but MDLops.
Another thing that happens when changing the number of vertices is that some bone information is recalculated and most of times it doesn't work good, but we will be able to fix it.
The tools that are enabled and disabled depends of the selection mode we are using, some tools only works for “Vertex” others only for “Edge”. “Create” and “Delete”... well... it creates and deletes elements we are working with. To create a vertex, in the “Vertex” selection, you need just activate the “Create” button and click on the 3d scene.
To create a face in “Face” selection, you need to click on the 3d scene two times to make a triangle, and to create a polygon, in “Polygon” selection, you need to place the last vertex in the the same place as the first to close it, when you are closing a hole on the mesh using a polygon you need to build it anti-clockwise.
To delete you first select what you want to delete and click the “Delete” button.
The “Weld” is only enabled when we have vertex selected, it is used to glue vertices together, first we select the vertices we want to glue, then we click “Selected”.
f the Weld warning appears it is because the vertices are not within the range of 0,1 that is the default for Gmax.
Let's change it to 3, and try again, now our vertices are glued together. Be careful though, it can remove details of the mesh if you don't notice that you have selected them, or put a high value here.
The “Target” is another way to glue the vertices together, here you have more control of the vertex position, as you will move one vertex over the other, the number beside the “Target” button specify the distance in pixels between the two vertices for they to be glued. So to use it just enable the “Target” button and move one vertice over the other.
As I said before our new mesh doesn't have all the faces connected, so if we select one vertex and move it there will be another one behind it
And if we move all of them we will end with as many vertices as the number of faces around it.
So we need to merge all those vertices together, I've selected all the vertices of the mesh and click the “Selected” button with the range of 0,1, because we want only glue together the overlapping vertices.
Once it is done we go to Element to see if it is only one whole mesh. When we select the mesh it appears as one, but if we hide it, using the “Hide” button in the Selection roll-up menu, we see that many faces are left behind, and we can not even select the vertices of those faces... don't know how this happened, but we will need to fix it.
So what I'm doing here is keep the one element mesh I've just hide, and delete those faces that were left behind, and them fill the holes on the mesh creating new faces. With the Element enabled we select all the faces them press the “Delete” button.
Now we unhide the mesh pressing the button “unhide” in the Selection roll-out menu.
Now with the Face selected and the “Create” button enabled we create faces on all the holes in the mesh, remember to build the faces anti-clockwise.
All this should be done with the other meshes too, feets and hands. It appears Lord Spartan and me have some homework to do. :D
That is it for now, next part we will add it to the base mesh, and we will see how to merge pieces of different models together to have a body model, so a little more of modeling.
As I was filling the holes from the robe mesh I've noticed that some faces was modeled with both sides, the inside and outside, so the inside faces should be deleted too, because it will not be seen by the player and the game will have to spend time to render it.
When you create faces in Gmax it only gives the outside face, if you look inside the model the mesh appears to be transparent, you only see the border of the separated elements.
That is why you have to create it anti-clockwise. If you create a face clockwise it will build the face inside the mesh.
This is the modeled mesh and the original one from the game and we are looking inside their arms, in the modeled I need to remove all the faces inside, and leave only those that we want to be seen, like those near the glove. And because it will take time we are going to see how to put together pieces of different models.
3.3 Merging pieces of different models
Jolly Boots asked once how he could remove Atton's jacket and give him the torso of the underwear's male, so that is what I'll explain here in more detail. The first thing I'm going to do is create a folder called “Atton” and using “Kotor Tool” we will extract the files of the male underwear pmbam, and Atton's cloths P_AttonBB:
KotorII->BIFs->models.bif->Aurora Model Extension->pmbam.mdx
KotorII->BIFs->models.bif->Aurora Model Extension->p_attonbb.mdx
Now using “MDlops” we press the “Select file” button, select pmbam.mdl file and with “Kotor 2” button enabled we press the “Read and write button” we do the same with p_attonbb.mdl file.
Start Gmax using the Nwmax icon, and import the model P_AttonBB-ascii.mdl.
We call the “Select Object” window using the “Select by Name” icon, and now we select all the meshs that have an _g in its name's end.
We name this selection Bones in the text field, and then we hide the selection pressing the right mouse button and selecting the “Hide Selection” from the menu.
We create another selection called Meshes selecting eyeLA, eyeLid, eyeRA, eyeRlid, teethDWN, teethUP, JacketFlapNew, ShirtFlapNew, LArm_Geo, RArm_Geo, Head_Geo, and we hide those too. Then we select all the boxes left and name it Helpers.
Now we select the Meshes selection, say “yes” to the warning window and we will have only the meshes visible. We already have seen all this in my first post of this tutorial.
One important thing to remember is that the flap of his shirt and jacket will not move any more when we export it to the game using MDlops, if you select the flap you will see that there is an “AuroraFlex” modifier in it, only Taina's Replacer can export it back to the game, but then we will not be able to change the number of vertices of the model. But as we are not going to use his jacket we don't need to worry about it.
From this model we are going to use only its pants, shoes and belt, the arms and torso will be from the underwear model. Let's take a look on the underwear model to decide which model will be used as a base model, save this file as Attonbb_01.gmax and reset Gmax selecting in the menu “File->Reset” and “yes” in the warning window.
Now import the pmbam-ascii.mdl to Gmax, and create the Meshes, Bones and Helpers selections as we did with Atton's cloths model, for the Meshes selection select only RArm, LArm and Torso meshes, and make only this selection visible... in my model the texture didn't come with the model, in the pmbam-textures.txt file that MDlops created it says I should have used the pmbama01.tga texture and not the pmbamc01.tga that I extracted using Kotor Tool , but as the pmbama01.tga is the asian skin color I'm going to put the pmbamc01.tga texture in the model using Gmax.
To add the texture we press the “Gmax Material Editor” icon to call the “Material Editor” window.
In the “Material Editor” window we press the “New” button and it will open the “New Material” window, where we select “Standard” and press “OK” button.
Now we click in the grey color box beside the “Diffuse” name in the “Blinn Basic Parameters” rollout, it will call the “Color Selector” window and we change the color from grey to white.
Now in the “Maps” rollout we check the “Diffuse Color” and click in the “None” button beside it to call the “gmax Material Navigator”, here we press the “bitmap” and chose the file pmbamc01.tga.
Now we enable the “Show Map in Viewport” icon and with the mesh torso selected we press the “Apply” button.
Now we select the arms and press the “Apply” button for each one.
When you export the model the name of the bitmap file we used here will be exported with the model, this is a way to change the name of the model's texture without hexedit the model file. And if you want to change the name of the model you need to select the “Aurara Base” mesh and change its name in the modify rollout. Then you will need to change the name of the original pmbam.mdl and pmbam.mdx files to the name you want before compiling the new ascii file Gmax exported using MDlops.
To decide which model will be the base I usually use the one with the arm I need, here we want the underwear arms with the pants, shoes and belt from Atton's cloths, so we are going to use the underwear model as a base, because this way we won't need to bone weight the arms, it is already done and working, and weighting the hand and fingers is a tedious work. Let´s save this file as pmbam_01.gmax.
Hope someone is reading all this stuff... any feedback is welcome.
vBulletin®, Copyright ©2000-2016, Jelsoft Enterprises Ltd.