-
Notifications
You must be signed in to change notification settings - Fork 2
Replacing Simple Meshes
This article explains how to do a simple mesh replacement with the script.
For the sake of simplicity, we will assume that the mesh will replace something that does not need complex rigging (hat/hair/prop etc). If you want to modify the textures as well, you can check the Replacing Textures guide.
Before starting, make sure you have imported the XFBIN that has the mesh you want to replace, and that you have the new mesh already loaded in Blender.
To replace the old mesh, we will first add the new mesh, and then remove the old one.
First, you need to add the new mesh to the XFBIN hierarchy. To do that, drag the new mesh in the outliner and place it inside the collection (XFBIN). Next, click on the mesh again to drag it and hold Shift, then drop it on the Empty object (NUD) that you want to add the mesh to.
If done correctly, you will now have an extra mesh placed under the NUD.
If you had to transform/rotate the new mesh to align it with the old mesh, make sure to Apply All Transforms to the old mesh before exporting. To do so, press Ctrl+A
while in object mode with the new mesh selected, and click on All Transforms
. If done correctly, the mesh's Transform tab should have the location and rotation set to 0, and the scale set to 1, for all axes.
Now that the mesh is parented to the NUD object, we can start rigging it. Since this guide is about replacing simple meshes, we will rig the mesh to a single bone, which will make it move along with the body, but won't have extra animations. In case you want to more advanced rigging, you can check the Transferring Bone Weights guide.
In order to see the mesh properly move with the armature in Blender, you have to go to the Modifiers tab in the Properties Editor (located below the Object tab), and add a new Armature Modifier
. Select the correct armature (the one that the mesh is currently under), and remove any other armature modifiers that were present on the object.
Modifier Properties tab
Adding the new armature modifier
Selecting the armature
Next, to actually rig the mesh, you have to find a bone that is located near the mesh. Almost any bone will work, because we will only be assigning the mesh to the bone, which means the mesh will have exactly the same movement/animation as that single bone. In the case of hat/hair/head meshes, the head
bone should be fine. Find the exact name of the bone from the armature (in the case of 2nrtbod1
, it is 2nrt00t0 head
).
After deciding which bone to use, switch to Edit mode with the new mesh selected, and press A
to select all vertices of the mesh. Next, go to the Object Data tab in the Properties Editor, and then to the Vertex Groups panel. Click on the +
icon to add a new vertex group, and double click the new group and rename it to the name of the bone you chose earlier. Then, click the Assign
button below the vertex group panel.
Object Data tab
Vertex Groups panel
If everything was done correctly, the mesh will now be rigged and will move along with the rest of the model, when animated.
Now that we have the mesh properly rigged, the only thing left is to replace the old mesh and export the model.
To copy the properties of the original mesh, go to its Mesh Properties panel, and click on the Copy
button at the top of the panel. Next, go to the new mesh's Mesh Properties and click on Paste. This will make sure nothing breaks the model, as the new mesh will now be replacing the old mesh.
Now, you can just delete the old mesh and export. The mesh's exact name does not matter, as it is just a way of differentiating between meshes in the same NUD. However, it is recommended to rename the mesh to the old mesh's name, to make sure it stays in the same position, because the meshes are placed inside the NUD in an alphabetical order when exporting. The name will be generated each time the XFBIN is imported, so the new mesh's name will not stay the same.
Also, if you'd like to make sure you did everything correctly before testing in the game, you can try importing the modified XFBIN to Blender after exporting it. If it imports correctly and animates fine in Blender, then is should do the same in the game.