Extract GR2 to Blender with mesh AND skeleton and re-export to GR2

Right snafusmith, here is the process I used to sucessfully reposition the rotors while keeping the vanilla animations working properly.

In Blender using the attached helicopter_gunship_repositioned_rotors.blend:

1. Select the Armature
2. Switch into Pose Mode
3. Select and reposition ADJ_MAIN_ROTOR/ADJ_TAIL_ROTOR bone to where you want them. All the child bones and parts of the mesh that are rigged to those bones should move as you reposition the ADJ bone
4. Now we need to 'burn' the position of both mesh and armature to this new pose. First RMB to select the mesh and under Modifiers click Apply for the Armature modifier. Now if you TAB into Edit mode you should see the rotor meshes are burned in their new position.
5. Next select the Armature (still in Pose mode) and do Ctrl-A for Apply Pose as Restpose (you can use the Pose menu instead if you want). Now if you TAB into Edit mode you should see that the bones are also burned into the new pose.
6. Finally we need to re-create the Armature parent modifier for the mesh. Ensure Armature is in Object mode rather than pose mode. RMB the Mesh and then shift-RMB the Armature to select both. Now Ctrl-P for Make Parent to - selecting Armature and Don't Create Groups. Selecting the mesh again under the Modifiers properties click 'Make Real' and then deselect 'Envelopes' so that only 'Vert Groups' is selected.
7. Now we have reposited the rotors so that the rotors will continue to animate in their new positions using the vanilla helicopter animations. Export to both FBX (without animation) and BR2. Open the FBX in Nexus Buddy 2 (I advise using 2.3.3 the latest version), and then overwrite the BR2. Test the resulting .gr2 in Granny Viewer by loading the vanilla idle animation and you should see the rotors animate correctly in their new positions.

helicopter_rotor_repositioning.jpg


ADJ_MAIN_ROTOR was created by making a duplicate of the 'Fuselage' bone and inserting it into the bone hierarchy under Fuselage, and similar process for ADJ_TAIL_ROTOR except with the 'Airplane tail' bone. This works because the relative position of the main rotor set of bones to ADJ_MAIN_ROTOR is the same as it's previous relative position to 'Fuselage' so we can reposition the rotor without animations being affected.

Obviously you will need to incorporate your new helicopter mesh into the process. If you get stuck or the above doesn't make sense I'm happy to help out with the rigging myself.
 

Attachments

  • Helicopter Gunship Rotor Repositioning Template.zip
    390.8 KB · Views: 326
Last edited:
Ok, so I've been trying for a while and I can't seem to get things to work. A couple questions:

1. What's the best way to import my model's mesh into your template? Should I join the mesh or use the parent method?
2. Once I have the mesh in, should I setup the new pose before or after I assign the mesh to the skeleton?

Thanks for your help!
 
Ok, so I've been trying for a while and I can't seem to get things to work. A couple questions:

1. What's the best way to import my model's mesh into your template? Should I join the mesh or use the parent method?
2. Once I have the mesh in, should I setup the new pose before or after I assign the mesh to the skeleton?

Thanks for your help!

It is a bit of a fiddly job so I'm not surprised that you have questions!

1. Join mesh is a good method as it should mean that the new mesh should keep its position and will get the parent association to the armature for free. All you need to do assign to vertex groups to set up the rigging. What I would do is to use Materials or additional Vertex Groups to mark all of each mesh before doing the join. This way you can position your new mesh before easily selecting the vertices belonging to the old mesh and deleting them when you're done even though both meshes have been joined into one. (Parenting should also works but you may need to do Ctrl-A to apply the visual position to the mesh before you parent it to the armature.)

In your case I would get your new mesh positioned, do the join and then remove all the parts of the vanilla mesh apart from the rotors and make sure everything is rigged (all of new mesh assigned correctly to vertex groups) BEFORE starting the process outlined in my previous post.

2. Moving a bone in pose mode will move any parts of the mesh that are rigged to that bone or child bones. So you generally want to assign the mesh to the skeleton before setting the pose. However the process I described in the previous post you should follow in the order I described it, because in this case we are using the pose to alter the resting positions of both skeleton and mesh.
 
I'll give that a shot. I think my problem was that I would put the model in, repose everything, and then join the meshes. When I did that everything would be off once I went through the rest of your steps.

My models often include different rotor meshes from what the Civ5 model has. How would you recommend I use my rotors?
 
So I made it through your tutorial but I'm having issues still. I made it upto step 6, but then had issues with the parenting. It gave me the error "loop in parents".

Also, just out of curiosity I went back to your original file and found that the gr2 you posted looks funny in Civ5.
 

Attachments

  • Civ5Screen0132 copy.jpg
    Civ5Screen0132 copy.jpg
    226.5 KB · Views: 349
My models often include different rotor meshes from what the Civ5 model has. How would you recommend I use my rotors?

The actual outer rotors in Civ V seem to be a effect rather than part of the model. I haven't really dug into to how they work. I guess if you wanted to use your own rotor blades you'd have to rig your rotors to the rotor bones and then remove the rotor effect in the XML. If it was me I'd just use the Civ V rotor effect for everything as I think it will look better.

I made it upto step 6, but then had issues with the parenting. It gave me the error "loop in parents".

This means that you are trying to parent the mesh to the skeleton (the correct way around) when the skeleton has already been parented to the mesh (incorrect). When you multi-select objects for parenting mesh to skeleton the order matters. First select the mesh then select the skeleton then do Ctrl-P to parent IIRC.

Also, just out of curiosity I went back to your original file and found that the gr2 you posted looks funny in Civ5.

Mmmm. I didn't test in game. It looks like the rotors are working OK but part of the body is being rotated for some reason. Possibly something in my template is not quite right. I briefly described how I made the template above: "ADJ_MAIN_ROTOR was created by making a duplicate of the 'Fuselage' bone and inserting it into the bone hierarchy under Fuselage, and similar process for ADJ_TAIL_ROTOR except with the 'Airplane tail' bone."

The steps were:
1) Convert helicopter_gunship.gr2 to .nb2 in Nexus Buddy 2.
2) Import helicopter_gunship.gr2 into Blender 2.7 (I use this version to make sure the skeleton comes in correctly).
3) Save as .blend with "Legacy Mesh Format" checked.
4) Reopen .blend in Blender 2.49.
5) Duplicate the bone 'Fuselage' and rename to ADJ_MAIN_ROTOR.
6) Switch the bone parent of ADJ_MAIN_ROTOR to 'Fuselage'.
7) Make the rotor bone that is a child of 'Fuselage' a child of ADJ_MAIN_ROTOR instead.
8) Repeat steps 4-6 for ADJ_TAIL_ROTOR with 'Airplane tail' instead of 'Fuselage'.

I'd suggest uploading your new mesh so I can get it completely working in game and then document the process. Unfortunately I don't have the chance to do any modding for a couple of weeks now, but I'm happy to keep trying to answer any questions you have in the meantime!
 
This is a tutorial on how to:
A) Extract 3D models, including their meshes AND skeletons, from the GR2 format used in Civ 5 into Blender.
B) Get 3D models from Blender back into the GR2 format so that they can be used in Civ 5.


Background

These methods have great potential for Civ 5 unit graphics and potentially other graphics such as leaders, buildings and improvements. The vast majority of community made unit art for Civ 4 was done by rigging custom meshes to vanilla animations. Until recently this has been a really difficult pattern to follow in Civ 5 because it hasn't been possible to extract the skeletons and the meshes of vanilla units. Some people such as danrell have had some success copying skeletons by hand but this is very slow and un-fun work. Now it is simple and quick to create precise Blender templates direct from vanilla GR2 files via the NB2 format. :)


Required Software Setup

For these processes you will need to unpack the Civ 5 art resources and have the following software installed:

Nexus Buddy 2
Blender 2.49b OR Blender 2.7+
Deliverator Blender Scripts

(Optional) Civ 5 SDK Old Version with working Nexus 3D Viewer *

* This folder can be unzipped anywhere and sid meier's civilization v sdk/Nexus/x86/Nexus.exe will still work.

These processes have been tested on Windows 7, 8 and 10.
__________________________________________

For my example case I am going to export and re-import archer.gr2, one of the Archer models. My complete working directory at the end of the process is uploaded here so you can play along at home.

Extracting Civ 5 GR2 into Blender

A1. Copy all files relating to the unit to a working folder. The simplest way is to do a file search within your unpaked resource directory (in my case C:\Program Files (x86)\Steam\steamapps\common\sid meier's civilization v\resource) for the name of the unit and just copy everything. In my case I searched resource for "archer" and copied everything to a folder called UnitWork_archer - it picks up Horse Archer and Camel Archer files too but that's not important. It helps to have everything in one place before you start. For the next step to work properly your working directory should include no spaces in the path.

A2. Nexus Buddy 2: Open the .gr2 file, switch to the Advanced Tab and click Export to NB2. If you have a file that contains multiple Models such as a Wonder graphic you can switch which one you want to export or just export all.

A3.
Blender 2.49b: Import the NB2 file using my the import script: Scripts -> Import -> Nexus Buddy 2 (.nb2).
OR
Blender 2.7+: Import the NB2 file using my the import addon script: Import -> Nexus Buddy 2 (.nb2).

From Blender to Civ 5 GR2

For getting graphics from Blender back into Civ 5 gr2 there are two formats available, BR2 and FBX, but both have some issues.

The FBX import is reliable for skeleton and animation data but often corrupts mesh data particularly for models with multiple meshes involved.

The BR2 is reliable for mesh data but there can be issues with the bone rotation in skeletons (Note: this is much more reliable with Nexus Buddy 2.3.3)

For these reasons the best techniques for getting graphics from Blender in .gr2 format are:


If you are rigging custom or converted meshes to a Civ 5 skeleton and animations use the following process:

B1. Export the unit to BR2 format.

B2. Make a copy of the original .gr2 file you are using the skeleton from - giving it a new name e.g. warrior_target.gr2.

B3. Open the copied file in Nexus Buddy 2 and select Overwrite Meshes from BR2 in the Advanced tab. Select the .br2 files you exported from Blender. This will keep the skeleton in the .gr2 completely unchanged but will completely replace the meshes with the data from the .br2 file. It doesn't matter if the .br2 file has more meshes than the original .gr2 had - it will still add them into the file. Following this, you will have a .gr2 with the original units skeleton but with your meshes from Blender.

B4. Use Nexus Buddy 2 to fix up your materials and textures - you'll probably need to remove the existing materials first before creating new ones.

This process allows custom multi-mesh units to made in a reliable way with none of corruption issues of using FBX. Exactly the same method also works for 3D Leaders. For Wonders, Improvements, etc you can select the model whose meshes you want to overwrite - more info here.


If you have custom or converted skeleton and animations then do the following:

C1. Export from Blender to both FBX and BR2 using the scripts in Deliverator Blender Scripts.

C2. Open FBX in Nexus Buddy 2.

C3. Use Overwrite Meshes from BR2 to make sure your meshes are uncorrupted.

C4. Use Nexus Buddy 2 to fix up your materials and textures.

This technique can be used when doing full conversion from Civ 4 - see here.


Hello,

First I would like to say thankyou for the brilliant editing programs. May I ask if anyone could help us out here please regarding importing a group of resource sprite placements (ie Wheat) from a farm .gr2 and imported to a lumbermill.gr2.

I have followed all instuctions regarding converting the .gr2 to a .br2 and importing the .br2 into blender.

So basically I have imported the Lumbermill model into blender, and then imported a wheat_group model from converting the farm .gr2.

Unfortunately upon exporting the file, there's an error stating mesh has unweighted vertices? I have assigned a vertex group to the following meshs but I'm sure if I have wrote the incorrect strings? I have followed this thread also regarding importing and editing improvements and wonders.

https://forums.civfanatics.com/thre...-for-wonders-buildings-citystyles-etc.519418/

Thankyou for your time and hope to speak soon.
 
Managed to allocate sprite placements around the lumbermill.

Thankyou very much for providing the tools and tutorials, much appreciated.
 
If anyone out there still knows how to do this sort of work, I need a wee bit of help. I made some models on .nb2 meshes, but they drop errors when exporting as .gr2, and don't contain bones when exporting as .fbx. I'm quite confused.
 
The BR2 is reliable for mesh data but there can be issues with the bone rotation in skeletons (Note: this is much more reliable with Nexus Buddy 2.3.3)

For some reason I have the opposite issue; .fbx is fine for meshes (but doesn't render in-game--just...nothing there, aside from particle effects), but .br2 corrupts them horribly. See my post in the civ 5 C&C forum if you think you might have a clue as to what I've done badly.
 
Unfortunately upon exporting the file, there's an error stating mesh has unweighted vertices? I have assigned a vertex group to the following meshs but I'm sure if I have wrote the incorrect strings? I have followed this thread also regarding importing and editing improvements and wonders.

Unweighted vertices means that you have vertices in a mesh that have not been assigned to any vertex group. The vertex groups are how mesh are weighted or rigged to bones so that they move when the bones move. Even un-animated meshes need to have their vertices assigned to vertex groups.
 
For some reason I have the opposite issue; .fbx is fine for meshes (but doesn't render in-game--just...nothing there, aside from particle effects), but .br2 corrupts them horribly. See my post in the civ 5 C&C forum if you think you might have a clue as to what I've done badly.

Trust me, FBX is a bad way to go for mesh data it will frequently corrupt in random ways. You need to figure out the reason for the BR2 error and resolve that in your Blender session.
 
Unweighted vertices means that you have vertices in a mesh that have not been assigned to any vertex group. The vertex groups are how mesh are weighted or rigged to bones so that they move when the bones move. Even un-animated meshes need to have their vertices assigned to vertex groups.

Ah. I'll see if the weighting has something to do with it... I could swear I transferred weight by name from another civ 5 tank-ish model.
 
Ah. I'll see if the weighting has something to do with it... I could swear I transferred weight by name from another civ 5 tank-ish model.

You can use the Weight Paint mode to help discover which vertices are unweighted.
 
And that could be the source of the mesh problems?

You have to use BR2 export to get the mesh data as I've explained. If you get an error attempting to export to BR2 then post the error. I saw something about parent bone somewhere which means that your Mesh object isn't parented to an Armature (Skeleton) object. You need to get an export to BR2 without error to get a clean mesh import. So it's probably a case of learning how to resolve the different BR2 export errors that can occur.
 
You have to use BR2 export to get the mesh data as I've explained. If you get an error attempting to export to BR2 then post the error. I saw something about parent bone somewhere which means that your Mesh object isn't parented to an Armature (Skeleton) object. You need to get an export to BR2 without error to get a clean mesh import. So it's probably a case of learning how to resolve the different BR2 export errors that can occur.

A night or two ago, I figured out how to resolve all the various errors that prevent the export of a readable .br2. The current issue is that I am getting a readable .br2 from a blender modification of a .nb2 (made from an original .gr2), but the mesh is beyond unrecognizable. I managed to get it to export a workable .br2 when I first figured out the error prompts, but since then have been unable to get a clean .br2 from the file.

Edit: make sure all faces are triangles.
 
Last edited:
Unweighted vertices means that you have vertices in a mesh that have not been assigned to any vertex group. The vertex groups are how mesh are weighted or rigged to bones so that they move when the bones move. Even un-animated meshes need to have their vertices assigned to vertex groups.

Thankyou very much for your expertise, yes indeed we managed to figure it out in the end, we have some new buildings in the DLC thanks to the programs used here.

Brilliant work as always!

Thanks again.
 
Ok. I've read the 27 pages of this thread. I'm still lost.
I feel like I need an ELI5 ...

Starting with the basic, I wanted to remove minor parts of a Rifleman. In theory, it should be simple. Get the blend file into Blender, export from Blender, import into NexusBuddy, play into Civ.

The reality:
1. Opened in Blender Bernie's .blend file of a Rifleman
2. Removed feathers and decorative sword.
3. Exported in BR2
4. Imported GR2 of original Rifleman
5. Overwrite with my exported BR2
6. Inserted into mod

Result: the Rifleman was totally twisted. Could see it. Could move. But was a monster from hell with feet and hands totally stretch out.

So I tried the same with an FBX instead of BR2
The game was glitching and the unit wasn't visible.

Why so much hate?

Also, is this line a secret code because I can't find the tutorial to "just open the BR2 to directly convert to GR2": Alternatively to steps B2-4, now that the BR2 import process has improved in reliability you can just open the BR2 to directly convert to GR2 and not use FBX at all.

And all of this is because I want to make more than just remove useless parts of units. I want to swatch heads and such but it includes bones and rigging, and I have way too many questions.
 
Top Bottom