Weapon models

5 minutes read

Note

This section is valid for every item imported with Tarkin item exporter, but it is focused on guns, as they are composed of multiple parts.

Cleaning up the gun model

To learn how to import a gun model with Tarkin item exporter, see the mods section. We will continue from where we left off :

EFT gun imported in Blender

Notice the many empty objects(appearing as crosses). They are used to position in the in-game elements (camera, hands and fingers for animations, etc.), but are not useful in Blender.

To get rid of them, select all parts of the gun : press A if only the gun is present in your file, or go to the outliner and Right click/Select hierarchy. Then, get rid of the parenting : in the viewport, press Alt + P and select Clear and keep transformation.

Then, open the text editor, create a new file with a py extension, paste the following Python script, then execute it.

Warning

This script will delete all unused empty objects in the scene. Make sure you do not have any other empties besides the ones you want to delete !

import bpy

iteration = 1
print('Iteration {}'.format(iteration))
iteration = iteration + 1

# select empties
bpy.ops.object.select_by_type(extend=False, type='EMPTY')
empties = bpy.context.selected_objects

print('Total empties: {}'.format(len(empties)))

while len(empties) > 0:

    # deselect everyting
    bpy.ops.object.select_all(action='DESELECT')

    parents = []
    # select childless nodes and collect its parents to check in next iteration
    for obj in empties:
        if len(obj.children) == 0:
            obj.select_set(True)
            if obj.parent is not None:
                parents.append(obj.parent)

    count = len(bpy.context.selected_objects)
    if count == 0:
            break

    print('{} empties were selected'.format(count))
    bpy.ops.object.delete(use_global=True, confirm=False)
    
    empties = parents
    print('Iteration {}'.format(iteration))
    iteration = iteration + 1

print('Done')

You can also save this script as a .py on your computer and load it directly in the text editor instead of pasting it.

You should know have a gun made of multiple separated objects (we will join them later): EFT gun imported in Blender

Scope materials

All scopes are opaque when imported instead of being transparent. To fix this, select the scope, go to the material properties, and find the material corresponding the scope glass (it usually has “glass” in its name). Decrease the alpha value, which represents the transparency. Glass is not 100% transparent : if you want the reflections to be more visible, choose a higher value (between 0 and 0.1 should give a good result). To increase the reflections, you can also choose a white base color.

scope material setup
An example of glass material setup with high reflections.

The scopes also contain a mesh plane opaque from the only one side. I think it is used in-game to display the reticle. It is better to delete it if you have no use for it.

cutout view of two optics, with an inner mesh plane
An example of inner mesh plane in two optics.

Converting to a single object

This next step depends on what you intend to do with the gun :

Warning

To join the parts, an active object has to be selected. It is marked with a lighter orange color in the Blender interface.

If you have no active object despite all the parts being selected : Shift+Click any object makes it the active object.

After joining, the gun object takes the name of the previous active object : if needed, rename it to avoid confusion later.

Redundant vertices

I noticed that some vertices do not connect to the neighbouring ones.

a foregrip with some vertices selected
In edit mode, if you select a vertex and press L, you will select all adjacent vertices. Here, the grip is a single object, but only a part of it has been selected : this means some vertices are disconnected.

It might be due to how the game engine processes seams for UV unwrapping, according to this r/blenderhelp post about a similar issue (if you are not familiar with the topic, you can watch Ryan King’s tutorial about UV unwrapping).

Warning

Do not attempt to fix it by merging the vertices ! It can mess up the shading :

two holo sights, the one on the right has broken shading
The holo sight on the left has not been modified. The vertices of the sight on the right side have been merged : shading artifacts appeared.

If you want to edit the model or un-join the different parts of the gun, use Edit mode/Select/All, then Mesh/Separate/By Material. For most gun parts, there is only one material per part : this will separate the gun back into several parts. Some parts have several materials (scopes, transparent magazines) so they will be separated, and you will have to join them back manually.