Blender adjusting and exporting weapon meshes

From Nexus Mods Wiki
Revision as of 15:31, 21 November 2018 by Zaldiir (talk | contribs) (Updated links.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This is a continuation of a tutorial series meant to adjust vanilla and custom weapons for RH_IronSights centered iron sights mod. The first part of the series, 'Adjusting Weapons for Iron Sights in NifSkope', can be found here: Link

In this tutorial Blender is used for 3D work. You will need the Blender nif Plugin, as well as NifSkope. Other downloads: RH_IronSights and GECK


First things first -why?

Why do we want to import .nif files into Blender? What will that do for us? How will it make Fallout 3 better?

Good questions! I find Blender to be an excellent way to edit 3D weapon models for Fallout 3. 3ds max is probably better for animations and clothing/monsters, but Blender is a great, free tool for weapon models.

To fit a weapon to a centered iron sights animation, you have to do a lot of adjusting. Some of these adjustments can be done directly to the .nif in NifSkope. But as many people have found, just moving the parts around isn't always enough to make the player's hands fit the weapon AND make the sights fit the reticule, all at the same time.

If you have to change the physical makeup of the weapon to get it to fit, you will need to edit the model in a 3D program. Many of the vanilla weapons have been changed in this way for RH_IronSights - for example, the Assault Rifle has had various parts moved and scaled, and the Laser Rifle was drastically altered!

So, if making centered weapons for Fallout 3 sounds like fun to you, then dig in.

Making blender your own

The Blender controls and hotkeys may take some getting used to. In case you can't see it, there is an options panel above the top menu. Pull the top menu down to see this panel completely. Here you can change several input options and the Blender color scheme, among other things.

I always choose 'Select with: Left Mouse'. This tutorial was written with this option selected!

Another important tip: Right-click the border of a Blender window to get a context menu allowing you to split the screen. I keep seven distinct panels open simultaneously: a large main screen for viewing the model; a smaller one off to the left for viewing the UV layout; four very small screens on the right for viewing the top, left, front, and perspective views in wireframe; and a runner at the bottom for the Buttons window.

Play with the setup until you get it looking how you want it. You need to have a work environment you're comfortable with.

Once you are satisfied, select 'File > Save Default Settings' or press Ctrl+U to make that the default view. Now whenever you open a new session of Blender, it will look like the way you set it.

Top menu vs. window menu

At various points in this tutorial I will probably reference the Top menu, which is the 'main' menu found in most programs at the very top of the screen. It contains the 'File', 'Add', 'Timeline', and other important submenus.

However, each window you create in Blender will also have its own menu, found either at the top or the bottom of the window depending on how you have things set up. These window menus contain options for 'View', 'Select', 'Object', and other functions.

This double-menu system can be just a little confusing at first, but it's very useful. If you can't tell which menu I'm referring to at any point, let me know and I'll try to clarify things.

Importing .NIf files into blender

If you have Blender and all of its scripts installed properly, then it's time to import the model to start editing it.

Select 'File > Import > NetImmerse/Gamebryo File (.nif)' from the top menu. If that option is not available to you, there may be a problem with your scripts installation.

Navigate to your target .nif file in the Blender Import window. On the left are a small up/down arrow button, which lets you see recently edited directories, and a 'P' button which lets you go to the previous folder (like the 'Up One Level' arrow button on a Windows window).

Select the .nif of the model you want to edit and hit 'Import'.

A new Import Options window will appear. At the bottom is a small white square that will make the window full-screen, in case you can't see all the options.

I use the following options for import:

Scale Correction: 1.00

Texture Search Paths: [YOUR FILE STRUCTURE]\Bethesda Softworks\Fallout 3\Data\Textures

'Import Animation'
'Combine Multi-Material Shapes Into Single Mesh'
'Realign Bone Tail Roll'
'Merge Skeleton Roots'
'Apply Skin Deformation'

Those last few options may not apply directly to weapons, but they work for me. Blender is sometimes like an idol in the jungle that brings sunshine when appeased but stormy weather when angered - in other words, I try not to mess with it unless absolutely necessary.

If you selected the fullscreen window, press the little white square button at the bottom again before proceeding! All good? Your Blender windows look the way you set them up? Great.

Select 'OK' to import the model.

Blender will read the file and import the data. Depending on the speed of your computer and the specifics of the model, this may take a while.

If the model appears in Blender's main render window with its textures applied, then you have successfully imported the mesh! Congratulations!

Planning the changes

What exactly do you want this model to look like? Fire the weapon in-game and take some screenshots. Does the rear-end clip? Is it too high or low? Is it crooked? Probably all of these things! Be sure you also pay attention to what the player's hand looks like when gripping the weapon.

Keep your reference screenshots open when working with the model in Blender. You can even have a background image, by selecting 'View > Background Image' and selecting 'Use Background Image' in the new window.

Moving the view vs. moving the model

Learn how to manipulate the view in Blender. With my configuration, I am able to hold the Middle mouse button to move the view camera, and Shift+Middle mouse to rotate the view. Scrolling the Wheel zooms in and out. NumPad 5 will switch between Orthographic (no distortion) and Perspective (distortion based on angle and distance) views. NumPad 1 sets the current window to the Front view; 3 sets it to the Right view; and 7 sets it to the Top view.

Your configuration may be different. Try to find a Blender hotkey reference online.

If you select part of the model and drag it, that part will translate depending on your view. If you haven't worked in a 3D environment before, getting the right perspective could be a challenge. Don't be afraid to experiment.

Object mode vs. edit mode

It is important to know which mode you are in when moving things around in Blender. If you see the weapon as it basically appears in-game - perhaps with all or some of its NiTriStrips outlined - then you are in Object Mode. There isn't much you'll want to change in this mode, as the changes will usually apply to NiNodes as opposed to NiTriStrips. Since we're aiming at NiTriStrips, get out of Object Mode. To do this, press Tab or select Edit Mode from the window's menu.

Next to the Mode selection option is a small icon that looks like a sphere or cube. This is the Draw Type menu. You can select from Textured, Shaded, Solid, Wireframe, or Bounding Box. Try Textured for now.

While in Object Mode, you can select a part of the weapon to highlight. Switching to Edit Mode with that part selected will allow you to alter the vertices, edges, and faces of the mesh.

This is the most important part of editing the model. The changes you make to the vertices will be reflected in the final mesh in-game.

Get comfortable switching between Object and Edit Mode. Note that unlike NifSkope, Blender has a long Undo/Ctrl+Z queue, but it doesn't work between modes (if you change something in Edit Mode, switch to Object Mode and change something, then switch back to Edit Mode and 'Undo', it won't let you).

Selecting vertices,edges,and faces

Move between the Front, Top, Side, and your own rotated views to see the model from all angles. Often if you are trying to raise up a model, you will be operating in only two as opposed to three dimensions. Again: this takes time and practice.

Depending on the size of your main render window, the options for selecting vertices, edges, faces, and occlusion may not be visible. You can drag a window's menu (my keyboard setup uses the Middle mouse button to drag, which is kind of odd) to see more options.

To the right of the Mode and Draw Type options are several symbols. Look for the collection of buttons featuring four dots, a line, a triangle, and a cube. These are the selection and occlusion buttons, and are quite important! They will only be available in Edit Mode.

With Vertex Select Mode (the four dots) active, your selection in the render window will influence the vertices or endpoints of the model's wireframe. You will do most of your work in this mode.

With the Edge Select Mode (the line) active, your selection will influence the edges or lines of the wireframe. This is useful for marking edges (necessary for unwrapping, covered later) and other functions.

With the Face Select Mode (the triangle with a dot in the middle) active, your selection will influence the faces of the wireframe. This has all kinds of applications, but use with care.

Finally, you can choose to Occlude the background, or not. If the background is occluded, then your selection will be exactly what you see. Anything not rendered to the screen will not be selected when you try to group-select.

If the background is NOT occluded, then the mesh will be slightly transparent. In this mode, selecting a group of vertices, edges, or faces will also select anything on the other side! You are kind of reaching through the model and grabbing all of its parts. Be aware of what occlusion you are using when you try to select something!

At last - adjusting the mesh

Compare how the player's hand rests on the gun and where the sights are. You can either line the sights up with the reticule and adjust the bottom of the weapon, or line up the grip and trigger and adjust the top of the weapon. It depends on your taste and judgment.

I tend to adjust the top of the weapon, though sometimes editing both is necessary.

Move the vertices of the weapon into position. That short sentence will probably encapsulate several hours of work.

What you have to do to each weapon depends on the weapon and what it looks like. Sometimes just raising or enlarging the sights slightly will be enough to make it fit, but usually, you will have to increase the size of the weapon part, shift part of it, etc. Be patient, but experiment. Try to have fun with it. This can be grueling.

When in Edit mode, you can select a group of pixels by pressing B. This will create a crosshairs that you can use to draw a box around the pixels you want. If you press B twice - B B - it will create a crosshair inside of a circle. Selecting with this will cause anything inside the circle to be selected. Increase or decrease the size of the circle by scrolling the mouse wheel.

Remember that putting the render window into Side, Top, and Front view will help you move the vertices where you want them. Working from a perspective can be very tricky, and sometimes cause the vertices to move in the 3rd dimension in a way that you haven't anticipated.

Switching to Object Mode (Tab) and looking around the model will give you a good idea of how your changes are coming along.

Exporting the mesh

When you have the model looking the way you want it, switch back to Object Mode. Press 'A' to select the entire model. Note that you can save a .blend file and come back to it later if you don't like the results of your export.

Choose 'File > Export > NetImmerse/Gamebryo (.nif & .kf)' from the Top menu. Navigate to your desired save location, type in a name, and select 'Export'. Do NOT use the same name as the final model in the game! For example, if I am working with the 10mmPistol.nif file, I will export as 10mmPistol_blend.nif.

As with importing, a new window will appear with many options available. I use the following:

'Export Geometry Only (.nif)'
'Force DDS extension'
'Stripify Geometries'
'Smoothen Inter-Object Seams'
'Flatten Skin'
'Export Skin Partitions'
'Combine Materials To Increase Performance'

From the group of games, select 'Fallout 3'.

Under 'Collision Options', select the type of object you are exporting. For weapons, 'Metal' or 'Wood', 'Solid', and 'Back' or 'Side' will be the most commonly used options.

Under 'Shader Options', I have:

'Default Type'
'Unknown 31'
'Export Dismember Body Parts'

Again, if you find a combination of settings that work better for your export, use those.

After working for a while, the mesh will export. If an error appears, check the log.

Straight export vs nitristrip swap

Okay, this is pretty important...

If you have Blender set up in some way that you can actually use an exported mesh directly from Blender, then congratulations! You know more than I do, and you just saved yourself some work.

If, like me, you have not found that magical combination, then you have a little more work to do in order to get your customized weapon into the game.

Bait and switch

Open two sessions of NifSkope. In one, open the model you have just exported from Blender. In the other, open the ‘target model’.

The target model is the model you will be pasting your edited parts onto. It must be a weapon that is already functional within Fallout 3. For example, if you are making a custom weapon with the same basic size and functions as a 10mm Pistol, you could open the 10mm Pistol as your target weapon.

On the editel model, find the NiTriStrip of the weapon part you want to transfer over to the target model. Expand its tree in the Block List window so that the Strip’s ‘NiTriStripData’ is visible. Right-click the NiTriStripData line and select ‘Copy’ (NOT ‘Copy Branch’!). Now go to the target model. Find the corresponding NiTriStrip and expand its branch so that its NiTriStripData is visible. Right click on the Data and select ‘Paste Over’.

This will transfer the vertex information of the edited model to the target model. If the new model part appears shifted incorrectly, the original NiTriStrips may have a translation already applied to them. Select the NiTriStrip line and look for the Strip’s ‘Translation’ and ‘Rotation’ fields in the Block Details window. Often, setting the Translation to 0 0 0 will move the edited model into the correct position.

Repeat this process with each part of the weapon you want to transfer over. Make any adjustments to Translation that are necessary.

Update your tangent spaces and save the target model using a new name (following the example of the 10mm Pistol, I would save the target model as ‘10mmPistol_IS.nif’ to signify that it has been adjusted for iron sights.

As with most things, this can all be a tricky process that takes some experimentation. Remember that NifSkope doesn’t make any permanent changes until you save your work.