Wednesday, September 11, 2019

NWN2: Importing a 3d model into the game: Part 1

For purposes of this tutorial I am going to use a 3d model from https://sketchfab.com. Sketchfab has lots of high quality models, often made from scanning real world objects, and the models they allow to be downloaded often use Creative Commons licensing. Their search function has a checkbox to restrict to downloadable models.

Specifically for this tutorial, I am using the Kiwano fruit from https://sketchfab.com/3d-models/kiwano-horned-melon-6ce07b8b2e654cde80eb5275842e5fe5

This tutorial assumes you have Blender, with the nwn2 .mdb import export scripts provided by rjshae from https://neverwintervault.org/project/nwn2/other/tool/blender-mdb-importexport-plugin . I personally also use gmax for fine tuning, so this tutorial will show that, but in principle the entire process can be done in Blender. gmax can be officially downloaded from https://www.turbosquid.com/gmax . To use gmax you will need the NWMax scripts from https://neverwintervault.org/project/nwn1/other/tool/nwmax-8. The download says it's for NWN1 but it works just fine for NWN2 as well.

Download the model. We always want to select the "original format", as the "autoconverted format" option produces a file in a format Blender and gmax can't handle. .obj and .fbx formats seem to be common, and those are good, Blender handles them without issues. Save your files somewhere. One peculiarity I've found is that the zip file you download often contains a zip file inside it with the model itself. This is the case with our example Kiwano, so you will need to extract the contents of that inside zip file.


We've extracted the contents now, here's what our folder looks like after I've placed all the files from the download into one folder for ease of use. There are two primary things to note here, the first is that there are more texture files than NWN2 can use. You will need the primary texture, and a normal map, plus a tintmap and a glowmap if you want tinting and for the object to glow, respectively.



Our Kiwano has both the main texture (highlighted in the image above, and a normal map included, the rest of the image files are files that NWN2 can't handle, so they can be deleted.

A word on filenames: Filenames need to be unique, otherwise NWN2 won't know for sure which file to use, and will just choose one. This will cause problems of course. I use the general naming convention of the stock game, with placeables files identified with the PLC_ prefix, then I have a short code for the given project I am working on (in this case I chose var_), then something identifying the object (food), and finally a numerical suffix (_02 in this case) as there will likely be more than one "food" item in the project. Altogether that means the files for the Kiwano will be named plc_var_food_02, plus any suffixes needed like identifying a tintmap with the _t (so plc_var_food_02_t for the tintmap for the Kiwano).

A word on filetypes and image sizes: While not strictly necessary, NWN2 prefers .dds files for textures. The Kiwano textures came in .jpg, so I used an image editing program to save them with the new filename, and also reduce the image resolution size. Sketchfab files generally include very large texture sizes. NWN2 generally uses 512x512 or 1024x1024 image sizes. Our Kiwano is a small object, so I went with 512x512.

Since there was no tintmap, I've created a basic one by making a copy of the image and then just painting it red.



Now to work with the object itself. In blender, import the object. Our Kiwano happens to be in .obj format.



And there it is. However, the object is far too complicated for NWN2 to deal with. Even feature objects should be 10k or less polygons. Small objects like our Kiwano will be are much less.



Fortunately, Blender can take care of that for us with the Decimate modifier ( https://docs.blender.org/manual/en/latest/modeling/modifiers/generate/decimate.html)



Sketchfab objects are normally much, much greater complexity than we want for NWN2, so we are going to decimate by a lot. In this case I've selected to keep only 2% of the polygons of the original.



For the rest of the process, I prefer to use gmax. You can do all the gmax things I am going to talk about in Part 2 of this tutorial in Blender if you prefer. Time to export from Blender so I can work with it in gmax.

 

One thing I've found is that Blender doesn't seem to like exporting to .MDB after doing a decimate. It produces a 1kb file. I have found that I often need to export the object to the original format, then open a new file and import the object I just exported, then export to .mdb.

No comments:

Post a Comment