xander2077

KOTOR Modeling tips for Linux and Blender users

Recommended Posts


This will be a short tutorial, and I will add pictures later for clarity, but for now I want to just give some basic tips on modeling for kotor in linux and blender. Anything else related to script editing or database editing and whatnot is beyond the scope of this tutorial so I will not get into it. Maybe at a later date.



Anyway. For anyone using linux operating system there are a few tools that you need to begin.



1: Blender. I would suggest getting both the portable app and run it in wine (2.49) and the latest version from the linux repository which is at versions 2.7 or 2.8 depending on your  Distro.



2: a plugin for blender that can both import and export the nwn/bioware mdl file. It is called Neverblender and can be found on Neverwintervault.Net. It is still a public beta but it does work, just not sure how well it works on any models that are more complex like skinned character models and creatures. So for now we will focus on things like placeables, items, weapons and maybe droids which are unskinned trimeshes.



3: Mdlops 0.6 -- and this is the latest version I have gotten working on linux, and it can be found on the old Lucas forums download page, however I have to add a link later.



4: Xoreos tools. His is a set of command line tools that are cross platform (meaning they work in any operating system) but they are limited since they are still in the early stages of development. Basically they are what openmw is to morrowind. It is a set of tools to try and create a new engine for bioware games and a few other games. What is useful here is the extractors. Using Xoreos I can extract all the models from kotor successfully and only need to convert them with Mdlops after that.



These next two I will mention but texturing is another thread: also I am not sure how anyone in linux can get textures extracted without ktool since Xoreos wont convert them properly to tga every time. But it can be used on one texture at a time.



5: gimp: a pretty good image editing program. I learned on photoshop but once you get past the differences, there is a lot of potential in the program and once you learn how it works you can make it work for you instead of be at its mercy.



6: a series of brushes that you can find on deviant art called TextureBox. There are a lot of other brushes there too, and I would suggest being picky since your brush window can get overcrowded. But they can help out.



I probably wont really get into the texturing aspects of modeling much, because that is a thread all its own but these are the tools I use as of right now. What I will mention is how to export the UV layout of a model, which can act as a sort of template when you want to see where the model borders are on the texture file.



OK so lets get started

First you need to use Xoreos tools to extract the model files. So take all your archives from the data folder, and the chitin.key and place them in a separate folder. Then follow the instructions for extracting on Xoreos.org and you will be able to dump the whole archive worth of models or whatever you need to access.

Now the fun begins. Since linux does not recognize the .Mdl or .Mdx extension for some reason (it is unknown) the search function does not really work all that well to find the files you want. So do your best to isolate all the mdl and mdx files and cut/paste them to a new folder. You can call it maps like what ktool does just for simplicity.

Now you can use Mdlops to convert the mdl files to ASCII and the mdx to text. This will double the size of the content in the maps folder and I think the size of the ASCII file is also larger.

Now you have some models you can access with blender and the Neverblender plugin.


Before that, if you cannot get ktool to run in linux under wine, Xoreos can also extract the tcp files in batch and then covert them to tga, but it wont convert the tcp files in batch. They have to be done one by one. So open the text file from Mdlops conversion of the mdx, and look for the name of the texture. Use that in your commands to convert the tcp to tga and you will have to dig the converted file out of the texture folder. Place all the tga files into another folder called k1 tga or something.

I wont get into how to install the NeverBlender plugin, but it is pretty straight forward. Blender 2.7 and above have a nifty way to do this by installing from the user preferences and installing the plugin from a zip file, so it wont be that hard to install. You can find instructions on the blender website for your version. But do not forget to check the box to enable the plugin and then save your user preferences or you will not see it in blender.

Unlike NWNmax, you do not have to open blender with the neverwinter plugin, it is just a script in the drop-downs.

So go to import/neverwinter nights (.Mdl) and import the ASCII-mdl you generated with Mdlops. It must be an ASCII-mdl or it will not import. If it doesn’t import there are other workarounds, and this is why you need blender portable 2.49. But I will add those instructions later. It is too complicated a procedure to get into right now.

Importing can be tricky, and sometimes things will error but still import so I am not sure how that effects the model. For instance skinned models or more complex skinned models like some of the variations of Revan can error and wont import. I think this is due to the limitations of the plugin and it will be improved over time.

 

 

Once you have your model the first thing you notice is it sent you to the edit mode on an ngon you do not want to edit. It is a placeholder so ignore it and go back out to object mode.

Select all empties (helper objects) and move them to another workspace layer to reduce the clutter. Also select any trimeshes that wont appear in game. These act as bones for animation, so send them to a third workspace layer. You have to select those one by one since there is no easy way to do it, I would probably prefer to select all the actual model parts and send them to another layer first. Most bodies only have three parts so that is easier than 50 trimeshes. Once you have only the mesh for characters, and the mesh and the hooks for items/weapons in one layer, then you can work easier.

Select the mesh you want to alter or replace and open it in edit mode. By default it should select all the vertices, but before you get started, find the mesh drop-down, go to vertices, and then remove doubles. This will weld the mesh into one piece for easy adjustment. Also select all faces and convert them to quads. This will help for UV layout and editing as well. Now edit to your hearts content until the model is the way you want it to look. For kotor models they face away from the player, so look at the back side of it and work on the left half of the model only (as in if the model were referring to its own left hand or you were the model what would your left side be?) this will be good for symmetry later. (if your model is supposed to be symmetrical or was designed to be. If not then this wont do much good)

If you only want to smooth it out a little then you can use tools like bevel on selected edges to help round out the appearance, but this will create new geometry. Don’t go way overboard because it will clutter the UV layout. Small tweaks can go a long way.

Next you should select all faces and use the mesh/faces/set smooth on it to hide the sharp edges. Don’t worry it will make it look a lot smoother but we can address that later to balance it out with marking sharps.

 

 

OK, now that you have the model edited it is time to focus on the UV layout. So select all the faces on the mesh you want to put a texture on. Then open the UV window, it will be blank but the UVs will be there over a blank texture space. The imported UVs may have gotten screwed up by the editing so we will address that issue in a minute but don’t worry. It is not going to hurt anything. All we are doing here is seeing how the texture appears on the model. It should be OK for the most part. To get the texture to show, you go to image, open, and then migrate to the folder you have your textures for the models in. Open the appropriate texture that goes to the model. And then go down to the menu bar and choose to display it textured in the 3d window. Now you can see where the problem areas are.

If there are stretched UV faces between islands then go back to the 3d window and turn the display back to solid. Then go back into the UV window and try and separate the stretched UVs from the islands. You can do this by selecting faces and then splitting the selection from the main island.

Don’t mess with the main island, just the skewed UV faces between islands. Once they are split you can drag them off to the side for now.

OK so now that you have the stretched faces isolated, now it is time to find them on the 3d model. So if you have seams, then good, if not then select all faces in the UV window and mark seams from islands. This makes it really easy to find the bad UV faces. Especially in solid display.

There will be heavier edges marked in red or black or whatever color your settings have them at. Those are to mark the seams between islands. This is important for the rest of the process.

OK, now look around for the edges that the seams don’t connect and start to select the edges that don’t have a seam, and then mark the seams til the islands are all clearly marked as larger groups of faces on the mesh. You can find that in mesh, edges, mark seams. If you mark the wrong one then just either undo or select the seam you don’t want, and go to mesh, edges, clear seam.

Now that you have the seams properly carved up, you can isolate the faces on the model that are causing the stretched UVs between islands. Once you find them you will know because they wont be a part of the normal looking islands, they will be the faces you put to the side in the UV window.

OK, if you select some adjoining faces together on the model, then that is good. If they are not adjoining or a part of the good islands, then don’t select them. You only have to select faces on one half of the model if it is symmetrical, and then go to mesh, UVs, then unwrap. Only unwrap those faces that were stretched between island, nothing more. Once they are unwrapped they will take up the texture space, so now you have to resize, rotate, and move them to an appropriate spot on the texture. Once it looks good in the 3d window as texture display, then go back to the 3d window and select all faces again.

 

Now there is a trick to the next step. Sometimes the model does not import exactly on center, so make sure it is lined up and the middle seam of vertices and edges is along the y axis. You can zoom in to make sure this is the case, but make sure you can still move the model and can see the arrows.

Once it is lined up then go out to object mode, and then snap the cursor to the center this will help. Sometimes a left click will move the cursor by mistake so it is best to line it back up with center.

Go back into edit mode and make sure all faces are selected again. Ignore the UV window for now.

On the pivot center button choose the cursor for now. You can change the pivot back to medain point later.

 

With all the faces selected go to meshes, then symmetrize. This will make both sides identical. However it is not without its issues, so deselect all, and then look at the center seam on the mesh, switch back to solid display if you have not already, and look for an unclean seam between the halves. You might have to zoom in really far to see the unclean center seam.

If there is a gap or three vertices where there should be one, then select all the vertices on that segment where there would normally be one, and merge them all to center. This will place them at the midpoint and over the y axis and give you a clean seam between halves. Also look for vertices that should be connected to a corner but are not. I will post a pic of what I mean later.

Once you are done there then go back to the UV window and see where your islands are. Display the 3d window in texture mode again and adjust the UVs till any stretching or seams are gone. This is not very hard now that you have the model in symmetry.

 

Once that is all done and the model looks good, it is time to begin to prepare it for export. Switch it back to display solid.

 

So staying in the UV window we will select all faces. Then we will switch back to the 3d window and clear all seams. Why? I will explain in a minute but it is important, yes you marked them all before but this is to make things simpler for the next step. You have to mark seams twice, there is no way to do it better. So clear seams, then go back to the UV window and mark seams from islands again.

There, now you have fewer segments to work with. But we are not done yet. Mark a seam down the center of the model and connect any missing seams between islands til each group of faces is isolated. You can work on the left half of the model to speed it up. (as in its left not yours or if you were facing from the models point of view then that left)

Once all the seams are marked on that half, then symmetrize again. Double check to make sure the seam down the middle did not get removed. Then you want to select a group of faces that correspond to the UV island it goes to. This is done simply by selecting all the faces within a seam ring. So, if they are inside their own outline, select them on the mesh, and then go to mesh, vertices, split. This will put them in their own part. Do this with each island on the left half of the mesh. To check and make sure it split properly pick a face in the center of an island on the mesh and then press control++++ until all faces on that island are selected in the 3d window. If you get to the border/outline of the seam and it stops then its good. If not then undo until you get back to before the split you just did and try again.

Once all the islands are split on the left half in the 3d window, select everything on the mesh, then symmetrize again. This will transfer all the splits over to the other half as well. OK leave it that way for now. Save.

Once you have it that far then display the texture again. Now you can see the faces are smooth, but some need to be sharp. So on the left half, select any edges you want sharp, like corners that are supposed to be sharp, like a sword edge, and make those sharp. Once done select all and symmetrize again.

 

 

 

Now for the texture part of the tutorial. This is how you export the UV layout so you can make a new texture to replace the old one. Select all the UVs in the UV window. now go to UV, and scroll up to "export UV layout" and save it as a png file. You can use this on a top layer in Gimp to guide you on where the borders of islands are when you create a new texture for a modified model, or a completely new texture for a new model. The islands will be transluscent, so this is tons better than the old versions of Blender or some other modding tools for other games. Using it as a top layer is good so you can hide it if you need. I would also suggest making multiple layers of a vanilla texture to edit individually for each island and even different layers for details within an island. They can be merged prior to export to a tga file.

 

Another tip is to semi flatten the vanilla tga so you can see the details easier, and sizing it up to at least 512x or 1024x. i dont see a need for a texture to be larger than 512, but it is a good idea to size some of them up to 1024 for details sake and some filters, and it can be sized down again later to a 512 size or 1024 depending on what the texture goes to (some walls or bodies need a larger texture, items generally do not)

 

 

 

Ok almost ready for export. Once the texture is done and looks good on the model it is time to do final prep on the model for export.

Now go to the outliner and look at the outline tree. It should have some specific traits. It should have the base node which is the aurora object, or hook, or main bone. This will be the name of the model as it appears in the game.

Below that there is a hierarchy of branches in the tree, it will be as many parts of the model that there are, so if there are three objects then the main one will be a child of the base node, and the rest will be children of it or of the base node.

Make sure there is only one base node and not two or more. If there is a duplicate, then unlink it or delete it. Then if the nodes are misnamed by blender, then remove the decimal numbers from the names and use another name for the node if it is identical in name to another node next to it to avoid the numbering problem. It is just best not to have numbers unless those were included in the vanilla mesh. For textures this can be tricky but that is something I cant really explain here. But usually that is not an issue.

OK once the nodes look good compared to a vanilla model, then get ready for export.

Go back out to the viewport windows of blender, change the UV view to 3d view and choose to view the right side of the model, then zoom in or out til it is not touching the edges of the window but the model is the only thing there, no lights or cameras. Make sure this window is switched to wire-frame display. Then select all objects in object mode that belong to that model by using border select and drag a box around the objects. This will select the model parts and the base aurora object ngon.

Now go to file, export, neverwinter nights (.Mdl) and it will open a folder view and at the bottom of the window on the left sidebar there will be options. You do not have to change them for items, but I am not sure yet for skinned models or anything else. I suppose the smooth groups refers to the chunks of mesh and the apply modifiers is the equivalent of reset xform in max. You wont have to worry about clicking on the animations or walk-mesh button for most things so don’t worry about those, just leave them be.

Then choose a file name, probably the same as the vanilla model or a variation if you want. Or if it s a new model you made pick your own name. I usually use the naming convention of kotor, so items start with i_name_00number. Weapons w_name_00number.

Then click the button in the upper right that says "export aurora mdl" and it does it in the blink of an eye.

 

The rest you have to do with Mdlops, and there are plenty of tutorials on that. I would just suggest having a few folders lined up in tabs to move copies from one to the next as you rename them and convert them, and to keep from overwriting anything you don’t want to mess up. That way you have a chain of progress and you can go back to the first folder and start over if you lose your place.



For bulk renaming I would recommend using metamorphose2, especially in linux. This is a huge life saver if you make multiple models and want to copy them to a new folder to rename as ASCII-mdl before dropping them into your output with the original binary mdls and mdx. And it makes them easier to identify. You can also choose to name the exported blender model as ASCII-out, and the Mdlops ASCII as ASCII-in. That way you know what step that model was in and wont try and convert a vanilla model back to binary and wonder why your cool new model you spent hours on looks the same as the old one.



OK, that concludes this tutorial for now. Later i will expand information in this first post to include some pictures and a second tutorial on how I force some mdl models to import with Blender 2.49b portable that will not normally import using the NeverBlender plugin. I also plan on writing a tutorial on texturing in Gimp and some of the brushes, plugins, and techniques i use to update the vanilla textures or create details i want on a model with the texture.

 

Thanks for reading and hope this helps other Linux users that want to mod Kotor.

 

Xander.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.