Getting Civ 4 Units into Civ 5 - Full Conversion

Deliverator

Graphical Hackificator
Joined
Feb 12, 2008
Messages
4,812
Location
London, UK
Updated 11th February 2014

There are two ways of taking a Civ 4 unit graphic and bringing it into Civ 5:

A) Take Civ 4 unit mesh and rig it to a Civ 5 skeleton so that Civ 5 animations are used.
B) Do a full conversion converting the Civ 4 animations so that they work in Civ 4.

A is preferable in most cases because the quality of the resulting unit will be better. The list of event codes for Civ 4 and Civ 5 do not match up perfectly, and the timings are different even where the events match up. Any unit that has animations converted from Civ 4 will effectively have gaps for some Civ 5 events where no equivalent Civ 4 animation exists.

B is worth doing if there is no equivalent unit in Civ 5, for example there is no Lion unit graphic in Civ 5 so if I want to convert the Lion Unit I need to convert the animations from Civ 4.

This tutorial describes the process for B above, fully converting a unit with its animations from Civ 4 to Civ 5.

For option A - Wolfdog has put together a tutorial here and here for Blender 2.7x.

In this tutorial we are going to convert the Lion unit including its animations from Civ 4 to Civ 5.

All the files used during this tutorial are available here for reference.

You can also download the Lion unit made using this process here.

Software Tools Used

Nifskope
Blender 2.49b and the Blender Nif Scripts - follow the download instructions from here
Nexus - Old Version with functioning 3D Viewer
Nexus Buddy 2
FBX Export script and BR2 Export script from Blender Scripts for Civ 5
PakBuild (http://www.civfanatics.net/downloads/civ4/utility/PakBuild.zip) to unpack any Civ 4 art you might want to convert (a lot of big mods pack their art too)

Steps:

A. Converting our Model from .nif to .gr2


1. First copy the files from the vanilla Civ 4 Lion unit directory to a working directory.

download1.png


2. Next import lion.nif into Blender with the following settings. The Scale Correction value should be set so that the imported model is an equivalent size to the vanilla Civ V models if you want attached visual effects to be properly scaled. For more on this see the third post.

download2.png

Send Bones to Bind Position should be de-selected and Apply Skin Deformation should be selected. This is to ensure that the mesh and skeleton are in the same positions in Blender as there are in the source NIF.

3. If we use Shift-Numpad-3 to view the Lion side-on and compare with the side view of lion.nif in Nifskope we should see the bones and mesh are in the same positions relative to each other. This is a good thing to check if we want the conversion of animations to work properly.

download3.png

download4.png


4. Now right click to select the skeleton in the 3D View. Now press Ctrl-A and select Scale and Rotation to ObData. Next right click the mesh and repeat Ctrl-A > Scale and Rotation to ObData. This ensures that any scale or rotation transformations are written into the mesh and skeleton data.

download5.png


5. With the mesh still selected, right click the skeleton to select it. Then press Ctrl-P > Make Parent To and select Armature then Don't Create Groups. This ensures the Lion mesh is parented to the skeleton in the right way.

download6.png


6. Export the updated Lion as a NIF - I used the name lion_blend_clean.nif with the following settings:

download7.png


You can now check that the exported NIF file looks OK in Nifskope. This is the NIF we will use when converting our animations.

download8.png


7. Now save your Blender session as a .blend file. This can be used as a template for rigging other meshes to the Lion's animations if we wish in the future.

8. Export the model to both FBX and BR2 formats. The FBX file will provide the skeleton for our finished unit, while the BR2 will provide the mesh. This is done because the FBX into BR2 randomly corrupts mesh data whereas the BR2 mesh import is reliable.

download9.png


The FBX settings should be as shown:

download10.png


I used the predictable filenames lion.fbx and lion.br2.

9. Open lion.fbx that we just exported in Nexus Buddy 2. Now under the Advanced tab pick Overwrite Meshes from BR2 and select lion.br2. Once the overwrite is complete you can click view to view the .gr2 file in Granny Viewer. The Lion is rotated forward by 90 degrees about the X-axis, seeing as we have switched from Blender where Z-axis is up to Granny where Y-axis is up. However, this is fine as the converted animations will correct the rotation.

Why do the BR2 Overwrite? Well, if you're lucky and your model only uses a single mesh then you may get clean meshes when you import from FBX, but if you are unlucky or your model contains multiple meshes then the mesh data will almost certainly be corrupted. The BR2 overwrite is reliable for mesh data so you will get clean meshes even if your model contains many different meshes.

download11.png



10. To complete our model .gr2 we only need to add a Material under the Edit Model tab, assign the Material to our mesh and assign textures. For the BaseTextureMap assign the vanilla lion.dds and for the SREFMap I've assigned a 4x4 pixel black square DDS that I made in Paint.NET. The SREFMap is the specular layer and controls how shiny and reflective parts of the model look. This is useful for metallic units but we want our Lion to be completely unshiny.


download12.png



B. Converting the animations from .kf to .gr2

11. The step for converting each animation is as follows:

a) In Blender select File > New to clear the session.
b) Load the lion_blend_clean.nif together with the animation .kf file you want to convert. It makes sense to start with the Idle position lion_md_idle.kf.

download13.png


Your import settings should look like this - don't worry if your Scale Correction is different:

download14.png


c) Make sure the model and animation have properly loaded by quickly checking the 3D window then export to FBX format with the following settings:

download15.png


The "Animation Rotation Fix - Rotate Y -90" option inserts an extra rotation key at the start of the animation for the skeleton root bone - in our case the bone "MD". This has the effect of rotating the animation 'back' 90 degrees and will mean that our finished unit appears upright in the game.

Give the FBX the name of the animation in question e.g. lion_idle.fbx.

Note: The Animation Rotation Fix will actually update the animation in your Blender session prior to exporting, but you can use Ctrl-Z to undo this after the export is done.

d) Click Open FBX in Nexus Buddy 2 and open the animation file.

e) Click Save Animation and save the animation as a .gr2 file.

download16.png


These steps, (a) to (e) should be repeated for each animation file you need to convert. The only thing that will change each time is the source .kf file.

To get a basic set of animations for the Lion I repeated these steps for:
lion_md_idle.kf
lion_md_run.kf
lion_md_fidget.kf
lion_md_fortifya.kf
lion_md_fortifya_idle.kf
lion_md_strikea.kf
lion_md_strikeb.kf
lion_md_diea.kf
lion_md_diea_fade.kf
lion_md_hurta.kf

You could convert more of the reusable animations if you want. For example, there are two Die animations for most units A and B - I have only converted the A one here.

download17.png


If we want we can test all our convert animations at once by opening our model .gr2 in GrannyViewer then selecting all the animation .gr2s and dragging and dropping them into GrannyViewer. Despite the fact that the unanimated model is face down the animations should be in the correct upright position.

download18.png



C. Create FXSXML and test in Nexus 3D Viewer

12. Now that we've created all our .gr2 files we can create an FXSXML file and quickly test the model in Nexus 3D Viewer. After that it is a simple matter to create a mod and test our conversion in Civilization 5.

Looking at an .FXSXML file for an existing unit we can see the mappings between animation .gr2 files and individual event codes:

Code:
<Animation file="Barbarian_EURO_Alpha_IdleA.gr2" ec="1000"/>
<Animation file="Barbarian_EURO_Alpha_FidgetA.gr2" ec="1040"/>
<Animation file="Barbarian_EURO_Alpha_IdleA_Trans_IdleB.gr2" ec="1020"/>
<Animation file="Barbarian_EURO_Alpha_IdleB.gr2" ec="2000"/>
<Animation file="Barbarian_EURO_Alpha_FidgetB.gr2" ec="2040"/>
<Animation file="Barbarian_EURO_Alpha_IdleB_Trans_IdleA.gr2" ec="2020"/>
<Animation file="Barbarian_EURO_Alpha_Fortify.gr2" ec="1500"/>
<Animation file="Barbarian_EURO_Alpha_Fortify_Idle.gr2" ec="1520"/>
<Animation file="Barbarian_EURO_Alpha_Fortify_Idle_Fidget.gr2" ec="1540"/>
<Animation file="Barbarian_EURO_Alpha_Fortify_Idle_Trans_Combat_Ready_Idle.gr2" ec="1560"/>
<Animation file="Barbarian_EURO_Alpha_Fortify_Idle_Trans_IdleA.gr2" ec="1580"/>
<Animation file="Barbarian_EURO_Alpha_Combat_Ready.gr2" ec="1600"/>
<Animation file="Barbarian_EURO_Alpha_Shuffle.gr2" ec="1450"/>
<Animation file="Barbarian_EURO_Alpha_Combat_Ready_Idle.gr2" ec="1620"/>
<Animation file="Barbarian_EURO_Alpha_Combat_Ready_Idle_Trans_IdleA.gr2" ec="1640"/>
<Animation file="Barbarian_EURO_Alpha_Run.gr2" ec="1400"/>
<Animation file="Barbarian_EURO_Alpha_Stop_Run.gr2" ec="1440"/>
<Animation file="Barbarian_EURO_Alpha_Stop_Run_IdleB.gr2" ec="2440"/>
<Animation file="Barbarian_EURO_Alpha_Charge_Run.gr2" ec="1120"/>
<Animation file="Barbarian_EURO_Alpha_Charge_Attack.gr2" ec="1140"/>
<Animation file="Barbarian_EURO_Alpha_AttackA.gr2" ec="1100"/>
<Animation file="Barbarian_EURO_Alpha_AttackB.gr2" ec="2100"/>
<Animation file="Barbarian_EURO_Alpha_Attack_City.gr2" ec="1160, 1180"/>
<Animation file="Barbarian_EURO_Alpha_Victory.gr2" ec="1800"/>
<Animation file="Barbarian_EURO_Alpha_Bombard_Defense.gr2" ec="1280"/>
<Animation file="Barbarian_EURO_Alpha_Bombard_Defense_Idle.gr2" ec="1285"/>
<Animation file="Barbarian_EURO_Alpha_Bombard_Defense_Idle_Trans_IdleA.gr2" ec="1290"/>
<Animation file="Barbarian_EURO_Alpha_DeathA.gr2" ec="1200"/>
<Animation file="Barbarian_EURO_Alpha_DeathA_Idle.gr2" ec="1220"/>
<Animation file="Barbarian_EURO_Alpha_DeathB.gr2" ec="2200"/>
<Animation file="Barbarian_EURO_Alpha_DeathB_Idle.gr2" ec="2220"/>

As far as I know there isn't a comprehensive list of Civ 5 animation event codes anywhere, but it should be fairly easy to work out looking at the vanilla files.

For our Lion conversion we have much fewer animations than this but we can re-use some animations for multiple event codes.

Here is the complete lion.fxsxml I created which you can use as a start point:
Code:
<Asset>
<Mesh file="lion.gr2"/>
<Animation file="lion_idle_anim.gr2" ec="1000, 1020, 1450, 1800, 2000, 2020, 1440, 2440" />
<Animation file="lion_run_anim.gr2" ec="1120, 1140, 1400" />
<Animation file="lion_fidget_anim.gr2" ec="1040, 2040" />
<Animation file="lion_fortifya_anim.gr2" ec="1500" />
<Animation file="lion_fortifyidlea_anim.gr2" ec="1520, 1540, 1560, 1580, 1600, 1620, 1640, 1285, 1290" />
<Animation file="lion_strikea_anim.gr2" ec="1100, 1160, 1180" />
<Animation file="lion_strikeb_anim.gr2" ec="2100" />
<Animation file="lion_diea_anim.gr2" ec="1200, 2200" />
<Animation file="lion_diea_fade_anim.gr2" ec="1220, 2220" />
<Animation file="lion_hurta_anim.gr2" ec="1280" />
<AnimGraph file="SHUFFLE_STOP_GRAPH.dge"/>
<AnimGraph file="START_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="ATTACK_CITY_TO_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="ATTACK_TO_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="RUN_CHARGE_SHUFFLE_LOOP.dge"/>
<StateMachine file="1_OMNI_STATE_01.fsmxml"/>
<AnimGraph file="RUN_CHARGE_SHUFFLE_TO_SHUFFLE_RUN_CHARGE.dge"/>
<AnimGraph file="MELEE_ATTACKS.dge"/>
<AnimGraph file="FIDGETS_GRAPH.dge"/>
<AnimGraph file="IDLE_GRAPH.dge"/>
<AnimGraph file="STOP_RUNNING.dge"/>
<AnimGraph file="TRANSITIONS_FOR_IDLES.dge"/>
<AnimGraph file="FORTIFY_GRAPH.dge"/>
<AnimGraph file="COMBAT_READY_GRAPH.dge"/>
<AnimGraph file="FORTIFY_LEAVE_GRAPH.dge"/>
<AnimGraph file="ENTER_COMBAT_READY_GRAPH.dge"/>
<AnimGraph file="LEAVE_COMBAT_READY.dge"/>
<AnimGraph file="DEATH_GRAPH.dge"/>
<AnimGraph file="ENTER_BOMBARD_DEFEND_GRAPH.dge"/>
<AnimGraph file="BOMBARD_DEFEND_LOOP_GRAPH.dge"/>
<AnimGraph file="DEATH_FINAL_GRAPH.dge"/>
<AnimGraph file="LEAVE_BOMBARD_DEFEND_TRANS_IDLE_A_GRAPH.dge"/>
<AnimGraph file="ENTER_FORTIFY.dge"/>
<AnimGraph file="FORTIFY_FIDGET_GRAPH.dge"/>
<AnimGraph file="IDLE_OFFSET_CONTINUE_TRUE_GRAPH.dge"/>
<TimedTrigger file="FX_Triggers_Barbarian_EURO.ftsxml"/>
</Asset>

This file can simply created in any text editor. Name the file, for example, lion.fxsxml.

I'm not going into all the detail of what can be done with FXSXML and FTSXML files here - mostly because I've not investigated that much myself. If you want to add Lion sounds to the unit or custom effects such as smoke you would need to edit these further.

13. Now we can test out unit in Nexus 3D Viewer to make sure the animation is working correctly there. Our animation will look twisted in Granny Viewer because of the bone roll fix we did in step 7, but provided our animations look good in Nexus 3D Viewer they should be fine in game.

(a) Start up Nexus (make sure you are using the old SDK version otherwise the 3D Viewer won't work)

download19.png


(b) Open the asset viewer and open the lion.fxsxml file. Click the green box with red arrow icon to open the 3D Viewer.

download20.png


(c) Our Lion will be pointing downwards initially, but switch the top left drop down to State Machine it should appear in Idle pose in the correct orientation. LMB Drag can be used to rotate the view.



(d) If you double click on IDLE_GRAPH in the Asset Viewer window and then press play in the Animation Graph window you should see the Lion breathing nice and smoothly. The converted Idle animation is working nicely. Since all the animations are making the same way we can be pretty sure that if one animation works OK in the 3D Viewer they should all work.



D. Create a Mod and test in game

Now we are ready to create a simple Mod and test the unit in game.

14. In ModBuddy create a new Empty Mod:



15. Copy your model lion.gr2 and all your animation .gr2s, the DDS texture files and your lion.fxsxml file to a folder called Art.

16. Select all the files and set Import to VFS to true for all of them. For more on why this necessary see here.

17. Make Reload Unit System is checked in your mod info.



18. Create a folder called XML. Now we need one XML file for the Unit and one for the Unit Art Defines.

The XML for vanilla units under sid meier's civilization v\Assets\Gameplay\XML\Units in your game install location.

The Art Defines XML for all vanilla units including the two expansions can be found here.

My LionUnit.xml looks like this:
Spoiler :
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
    <UnitClasses>
        <Row>
            <Type>UNITCLASS_TEST_UNIT</Type>
            <Description>Test Unit</Description>
            <DefaultUnit>UNIT_TEST_UNIT</DefaultUnit>
        </Row>
    </UnitClasses>
    <Units>
        <Row>
            <Class>UNITCLASS_TEST_UNIT</Class>
            <Type>UNIT_TEST_UNIT</Type>
            <Combat>40</Combat>
            <Cost>1</Cost>
            <Moves>50</Moves>
            <CombatClass>UNITCOMBAT_MELEE</CombatClass>
            <Domain>DOMAIN_LAND</Domain>
            <DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
            <Description>Lion</Description>
            <Civilopedia>NONE</Civilopedia>
            <Strategy>NONE</Strategy>
            <Help>NONE</Help>
            <MilitarySupport>true</MilitarySupport>
            <MilitaryProduction>true</MilitaryProduction>
            <Pillage>true</Pillage>
            <ObsoleteTech>NONE</ObsoleteTech>
            <GoodyHutUpgradeUnitClass>UNITCLASS_SPEARMAN</GoodyHutUpgradeUnitClass>
            <AdvancedStartCost>10</AdvancedStartCost>
            <XPValueAttack>3</XPValueAttack>
            <XPValueDefense>3</XPValueDefense>
            <Conscription>1</Conscription>
            <UnitArtInfo>ART_DEF_UNIT_LION</UnitArtInfo>
            <IconAtlas>KAMEHAMEHA_UNIT_ATLAS</IconAtlas>
            <UnitFlagAtlas>KAMEHAMEHA_UNIT_FLAG_ATLAS</UnitFlagAtlas>
            <UnitFlagIconOffset>0</UnitFlagIconOffset>
            <PortraitIndex>0</PortraitIndex>
        </Row>
    </Units>
</GameData>

This creates a simply unit that can be built in a single turn to test the graphics.

My LionUnitArt.xml:
Spoiler :
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
    <ArtDefine_UnitInfos>
        <Row>
            <Type>ART_DEF_UNIT_LION</Type>
            <DamageStates>1</DamageStates>
            <Formation>Barbarian</Formation>
        </Row>
    </ArtDefine_UnitInfos>
    <ArtDefine_UnitInfoMemberInfos>
        <Row>
            <UnitInfoType>ART_DEF_UNIT_LION</UnitInfoType>
            <UnitMemberInfoType>ART_DEF_UNIT_MEMBER_LION</UnitMemberInfoType>
            <NumMembers>7</NumMembers>
        </Row>
    </ArtDefine_UnitInfoMemberInfos>
    <ArtDefine_UnitMemberInfos>
        <Row>
            <Type>ART_DEF_UNIT_MEMBER_LION</Type>
            <Scale>1.9</Scale>
            <Model>lion.fxsxml</Model>
            <MaterialTypeTag>CLOTH</MaterialTypeTag>
            <MaterialTypeSoundOverrideTag>FLESH</MaterialTypeSoundOverrideTag>
        </Row>
    </ArtDefine_UnitMemberInfos>
    <ArtDefine_UnitMemberCombats>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_LION</UnitMemberType>
            <EnableActions>Idle Attack RunCharge AttackCity Bombard Death BombardDefend Run Fortify CombatReady Walk AttackCharge</EnableActions>
            <ShortMoveRadius>12.0</ShortMoveRadius>
            <ShortMoveRate>0.349999994039536</ShortMoveRate>
            <TargetHeight>8.0</TargetHeight>
            <HasRefaceAfterCombat>1</HasRefaceAfterCombat>
            <ReformBeforeCombat>1</ReformBeforeCombat>
        </Row>
    </ArtDefine_UnitMemberCombats>
    <ArtDefine_UnitMemberCombatWeapons>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_LION</UnitMemberType>
            <Index>0</Index>
            <SubIndex>0</SubIndex>
            <WeaponTypeTag>METAL</WeaponTypeTag>
            <WeaponTypeSoundOverrideTag>SPEAR</WeaponTypeSoundOverrideTag>
        </Row>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_LION</UnitMemberType>
            <Index>1</Index>
            <SubIndex>0</SubIndex>
            <VisKillStrengthMin>10.0</VisKillStrengthMin>
            <VisKillStrengthMax>20.0</VisKillStrengthMax>
            <WeaponTypeTag>FLAMING_ARROW</WeaponTypeTag>
            <MissTargetSlopRadius>10.0</MissTargetSlopRadius>
        </Row>
    </ArtDefine_UnitMemberCombatWeapons>
    <ArtDefine_StrategicView>
        <Row>
            <StrategicViewType>ART_DEF_UNIT_LION</StrategicViewType>
            <TileType>Unit</TileType>
            <Asset>SV_Spearman.dds</Asset>
        </Row>
    </ArtDefine_StrategicView>
</GameData>


Under Actions in the Mod Info in ModBuddy make sure that your On Mod Activation - Update Database actions for your two XML files.

There are a lot of things that can be altered in the Art Defines to change the appearance of the unit. Existing 2D art assets are used as placeholders since the focus of this tutorial is the 3D assets.



19. Now Build LionUnitMod using the option under the Build menu. This will deploy the Mod so it can be played.

20. Start up Civilization 5. When you select Mods you should see LionUnitMod under the list of available Mods to load. Select the mod and start up a game. I usually start a game with Fractal map and Dual so that it starts quickly. Found a city and the Lion unit should be available to build. One turn later and you should be able to play with your converted unit!



 
Last edited:
Addendum - Avoiding issues when your model has more than 32 bones

This is the how to avoid your converting models having stretching-to-the-edge-of-screen type graphic glitches like this:


Key Point: The Granny format has a limit of 32 bone bindings (what Blender calls vertex groups) per mesh.This means that if you have a model with more than 32 bones in it you need to split your mesh into separate chunks each of which have no more than 32 bone assignments.

This makes sense of something I've always found puzzling with the vanilla models. Why, for example, are the War Chariots split into weird chunks where the back section of one of the horses is a separate mesh? Now, we know - its because Granny requires each mesh to have no more than 32 bone assignments. Presumably this helps the efficiency of the graphics engine.



Anyway, this discovery is VERY GOOD NEWS because it is very simple to take your mesh and lasso select chunks of it in Blender in Edit mode (Ctrl-LMB drag) and then press P to separate the selected chunk into a new mesh before exporting to BR2. The aim is make sure no mesh has more than 32 bone assignments (vertex groups).

I tested this by dividing the Centaur into 5 chunks (a bit excessive but I was testing the theory!) and now because none of the meshes now has more than 32 bone assignments the model works fine in game with no glitches! Happy days. :cool:



 

Attachments

  • download21.png
    download21.png
    161.4 KB · Views: 55
  • download22.png
    download22.png
    336.9 KB · Views: 54
  • download23.png
    download23.png
    75.7 KB · Views: 55
  • download24.png
    download24.png
    63.7 KB · Views: 56
  • download25.png
    download25.png
    21.2 KB · Views: 55
  • download26.jpeg
    download26.jpeg
    88.3 KB · Views: 57
  • download27.jpeg
    download27.jpeg
    113.5 KB · Views: 57
Last edited:
From Nomad or What:

Scale Correction is actually absolutely essential if you intend to use custom effects. If you do not originally import the .nif and animations using scaling proportional to a CiV unit then the effects will not appear correctly. CiV base human scale is roughly 0.14 when defined in the XML "<scale>" parameter, so if it is necessary to scale your custom unit to 1.4 (for example) in order to appear the proper size in the game, then your effects (city attacks, etc.) will be 10x their original size as well. The only way I have found to overcome this is to use proper scale correction when originally importing the .nif so that the scale is proportional to a base human model for the intended effects.

I had a terrible time importing the Bloodthirster unit from Civ IV to CiV because it was rife with all sorts of anomalies that prevented it from working properly. After this exhaustive trial and error I wrote a brief rundown of how I managed to convert it and referenced in the Bloodthirster thread. I will repeat it in the below spoiler for convenience:

Spoiler :
STEP I: Cleaning up the mesh
1. Import original .nif file (no anims) at scale 1.0 in a blank .blend file
2. Clean the mesh and vertex group assignments in a .blend (every vertex is assigned to a group, no more than 32 groups per mesh, etc.)
3. Delete the bones and all modifiers (nothing left but mesh and materials)
4. Save mesh data as a .blend file to import later

STEP II: Cleaning up the bones and exporting a clean .nif
1. Import original .nif file (no anims) at scale 1.0 in a blank .blend file (again)
2. Delete all mesh
3. Delete all non-object bones (effects, sound, cameras, etc. that are commonly used in other games, but are useless in CiV because they are defined elsewhere)
4. Object copy/paste clean mesh (should already have correct vertex group assignments from previous cleanup)
5. CTRL+A | Apply Scale and Rotation to object data for all objects
6. CTRL+P | Parent Armature to bones for all mesh objects
7. Save file as .nif to be used as a clean import

STEP III: Create the base files at proper scale correction (CiV human scale)
1. Create a new .blend file and stretch the default cube so that it's roughly the same size as a human warrior (approximately 120h x 60w x 40d, it doesn't need to be very precise as it is solely for reference)
2. Import newly-cleaned .nif file (no anims) at 1.0 into your existing .blend file with cube
3. Scale the .nif in object mode until it is the same size as the cube (particularly in height) and record the value that the .nif needed to be scaled in order to match the size of the cube
4. Once you have recorded the scale, close the .blend file
5. Import newly-cleaned .nif file (no anims) in a blank .blend file at a scale correction that is INVERSE of your recorded scale value (so if you had to scale the .nif 20x to match the cube you will now use a scale correction of 1/20 or 0.05 when importing the .nif). The imported .nif should be roughly 120 units high (base human scale)

IMPORTANT!!!: ALL .nifs should be imported to a scale correction matching base human scale (even monstrous units) because CiV effects scale based upon human scale, which is roughly 0.14 in the ArtDefines. If you make your final unit larger than 0.14 in the ArtDefines (like 0.20 for the Bloodthirster unit) then your effects will still scale properly if imported at base human scale originally. Effects in the game are scaled in the ArtDefines, not here!

6. Save the file as a .blend and export to .br2, .fbx. and .nif to be used for all animations
7. Create .gr2 from .fbx w/ .br2 overwrite and ensure that it appears properly in Granny Viewer

STEP IV: Creating the animations
1. In a blank .blend file, import the newly-scaled .nif file with the desired KeyFrame animation at the proper scale correction you just used to create the .nif (e.g., 0.05 or whatever)
2. Once imported, ensure that it is at proper scale and play the animation to ensure it moves properly. If it doesn't then the .nif probably has other issues that I will not discuss here
3. If it does, try to export it as an .fbx with the -90 rotation enabled
4. Create the .gr2 animation and apply it to the base .gr2 you just created. If it rotates back 90 (Blue "Z" axis horizontal and Green "Y" axis vertical) and animates properly then repeat for all animations
5. If the .gr2 animation DOESN'T animate properly or rotate back as it should, you will need to perform manual rotations for every animation before exporting. Repeat steps 1+2 then proceed to the following step
6. If your animation is correct in Blender but didn't export to .fbx properly you will need to manually rotate the animation before exporting
7. Ensure that your 3D Cursor is set to the origin point (0,0,0) and that your Rot/Scale Pivot is set to 3D Cursor
8. Go to View (NumPad) 3 (green "Y" axis visibly horizontal and blue "Z" axis vertical)
9. Select the bone object and switch to EDIT mode
10. Select all and rotate the bones in EDIT mode -90 degrees (Quick Keys: A, R, X, -90, Enter) and return to OBJECT mode. The mesh will most likely be wickedly deformed; that is OK
11. For each mesh object, select it, go to EDIT mode, select all and rotate -90 degrees just as you did with the bones
12. Once complete, your objects should all appear rotated in OBJECT mode 90 degrees backwards so that they appear to be lying on their back
13. Test the animation and ensure that it still animates properly. If it doesn't then the .nif has problems that I will not discuss here
14. If it does, export the animation to .fbx WITHOUT -90 Rotation enabled
15. Create the .gr2 animation and apply it to the base .gr2. It should now rotate back 90 (Blue "Z" axis horizontal and Green "Y" axis vertical) and animate properly. If so, then repeat for all animations as usual.
 
Thanks for putting together this tutorial and the tools, Deliverator!

I've been following this tutorial to try to get a personally (horribly) modified version of the Civ4 Panther into the game, but I've run into some issues.

1. Should the texture show up when viewing the model in Granny Viewer? Even after adding the material, setting the BaseTextureMap and SREFMap, and assigning the material to the mesh, it still doesn't show up on the mesh.

2. Is it normal for the Nexus viewer to be incredibly slow? For several minutes when it first loads, it slows down my machine to the point where Winamp starts skipping. It takes about 5 full minutes before I can actually try to load my fxsxml file. Which leads to my next issue...

3. Whenever I try to load my current fxsxml in the Nexus Asset viewer, the program crashes. Because of the aforementioned issue, trying to figure out why this is happening is incredibly frustrating.

The model does not load at all in-game, though that's not surprising if it can't load in the Asset viewer. I've attached my files if someone would be kind enough to take a look at it. It's an absolutely hideous model, but I'd still love to include it in my mod.
 

Attachments

  • incubator.7z
    84.2 KB · Views: 263
1. No. The only way to see the textures is the Asset Viewer (or the game). Even then, I've had the behavior where the textures don't load properly for certain units in the Asset Viewer until you load a base game unit first.
2. The graphics engine of Civilization V is actually loading in the background. If you have a slower PC, it seems to take almost as long as loading the full game.
3. Do other models load successfully? (Are you sure you're using the Nexus Viewer from the old SDK?)
 
3. Do other models load successfully? (Are you sure you're using the Nexus Viewer from the old SDK?)

I probably should have tried this earlier. But it turns out they, in fact, do not.

I'm using the SDK download which was linked in the OP. It seems that the super-long load times are gone after I put my computer to sleep and turned it back on later, bizarrely enough. I get several error messages when starting Nexus, though:

  • "Unknown argument type in message LoadAsset"
  • "The message LoadAsset can not be used unit [sic] the errors are resolved"
  • "Unknown argument type in message ng" (this one appears 5 times)

And then when I try to use Asset Viewer to open some of the .fxsxml files from the base game, it still crashes. I tried spearman.fxsxml, barbarian_swordsman_v3.fxsxml, and archer.fxsxml.

Here is the Firaxis Error Report.txt it generated:
Spoiler :
Application: Nexus
User: Unkown (Not an in-house user.)
Time: Wednesday 1/29/2014 11:30:03 AM

Runtime: 64 bit
OS: Windows 2008 (Service Pack 1)
Machine: VICE-PC

Exception: System.NullReferenceException
Source: FireGraphics
Thread: Main Thread
Description: Object reference not set to an instance of an object.

Stack Trace:
at FireGraphics.FGXCategory.FireGraphicsImpl.RequestShaderState()

at Civ5NexusModes.AssetViewer.AssetViewForm.LoadAsset(String pending_asset)

at Civ5NexusModes.AssetViewer.AssetViewForm.set_Asset(String value)

at Firaxis.Framework.ToolStripOpenButton.ToolStripOpenButton_ButtonClick(Object sender, EventArgs e)

at System.Windows.Forms.ToolStripSplitButton.OnButtonClick(EventArgs e)

at System.Windows.Forms.ToolStripSplitButton.OnMouseUp(MouseEventArgs e)

at Firaxis.Framework.ToolStripOpenButton.OnMouseUp(MouseEventArgs e)

at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ToolStrip.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
It sounds like you're still using the Nexus from the updated SDK. You want to launch the Nexus executable directly, rather than from the SDK launcher. (\Nexus\x86\Nexus.exe)

You probably also need to change this registry entry:
HKCU\Software\Firaxis\Nexus\Viewer\Executable
to the full path to the old SDK version of \Nexus\x86\Viewer.exe
 
I've just set up Nexus and the 3D Viewer on a new Windows 8 machine and it works fine. This is what I did:

1) Installed the latest Steam SDK.

2) Renamed the folder under C:\Program Files (x86)\Steam\SteamApps\common from Sid Meier's Civilization V SDK to Sid Meier's Civilization V SDK_steam_latest.

3) Downloaded the old version of the SDK with the working viewer.

4) Unzip the contents to C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization V SDK.

5) Start Nexus from the old sdk folder C:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v sdk\Nexus\x86\Nexus.exe

6) Set the Asset Path to C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization V.

Note - not the Assets subfolder.

7) Select the Viewer.exe from the same old SDK folder as the Viewer.

After this I was able to view the vanilla units.

If you go wrong with the paths they can be updated via the registry as Nutty says.
 
Thanks, now Nexus is working. Loading Firaxis units works fine.

I tried to load my unit, though, and it appears that it isn't loading all the necessary files with it. Clicking the Validate button notes that all of my .gr2 and .dds files are missing. All of the files are in the same directory as my .fxsxml file.

For this to work with Asset Viewer, do my files need to be in the game's Asset Path? Or is it supposed to automatically find the files if they're in the same folder as the .fxsxml file?

My .fxsxml looks like this:
Spoiler :
<Asset>
<Mesh file="incubator.gr2"/>
<Animation file="incubator_idle_anim.gr2" ec="1000, 1020, 1450, 1800, 2000, 2020, 1440, 2440" />
<Animation file="incubator_run_anim.gr2" ec="1120, 1140, 1400" />
<Animation file="incubator_fidget_anim.gr2" ec="1040, 2040" />
<Animation file="incubator_fortifya_anim.gr2" ec="1500" />
<Animation file="incubator_fortifyidlea_anim.gr2" ec="1520, 1540, 1560, 1580, 1600, 1620, 1640, 1285, 1290" />
<Animation file="incubator_strikea_anim.gr2" ec="1100, 1160, 1180" />
<Animation file="incubator_strikeb_anim.gr2" ec="2100" />
<Animation file="incubator_diea_anim.gr2" ec="1200, 2200" />
<Animation file="incubator_diea_fade_anim.gr2" ec="1220, 2220" />
<Animation file="incubator_hurta_anim.gr2" ec="1280" />
<AnimGraph file="SHUFFLE_STOP_GRAPH.dge"/>
<AnimGraph file="START_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="ATTACK_CITY_TO_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="ATTACK_TO_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="RUN_CHARGE_SHUFFLE_LOOP.dge"/>
<Texture file="Unit_Environment_Dull.dds"/>
<Texture file="Unit_Environment_Sharp.dds"/>
<Texture file="Unit_Irradiance.dds"/>
<Texture file="qbtexture.dds"/>
<Texture file="qb4x4black.dds"/>
<AnimGraph file="RUN_CHARGE_SHUFFLE_TO_SHUFFLE_RUN_CHARGE.dge"/>
<AnimGraph file="IDLE_OFFSET_CONTINUE_TRUE_GRAPH.dge"/>
<AnimGraph file="FORTIFY_FIDGET_GRAPH.dge"/>
<AnimGraph file="ENTER_FORTIFY.dge"/>
<AnimGraph file="LEAVE_BOMBARD_DEFEND_TRANS_IDLE_A_GRAPH.dge"/>
<AnimGraph file="DEATH_FINAL_GRAPH.dge"/>
<AnimGraph file="BOMBARD_DEFEND_LOOP_GRAPH.dge"/>
<AnimGraph file="ENTER_BOMBARD_DEFEND_GRAPH.dge"/>
<AnimGraph file="DEATH_GRAPH.dge"/>
<AnimGraph file="LEAVE_COMBAT_READY.dge"/>
<AnimGraph file="ENTER_COMBAT_READY_GRAPH.dge"/>
<AnimGraph file="FORTIFY_LEAVE_GRAPH.dge"/>
<AnimGraph file="COMBAT_READY_GRAPH.dge"/>
<AnimGraph file="FORTIFY_GRAPH.dge"/>
<AnimGraph file="TRANSITIONS_FOR_IDLES.dge"/>
<AnimGraph file="STOP_RUNNING.dge"/>
<AnimGraph file="IDLE_GRAPH.dge"/>
<AnimGraph file="FIDGETS_GRAPH.dge"/>
<AnimGraph file="MELEE_ATTACKS.dge"/>
<StateMachine file="1_OMNI_STATE_01.fsmxml"/>
<AnimGraph file="RUN_CHARGE_SHUFFLE_LOOP.dge"/>
<AnimGraph file="ATTACK_TO_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="ATTACK_CITY_TO_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="START_RUN_CHARGE_SHUFFLE.dge"/>
<AnimGraph file="SHUFFLE_STOP_GRAPH.dge"/>
<TimedTrigger file="FX_Triggers_Barbarian_EURO.ftsxml"/>
</Asset>
 
One issue is that your DDS texture files are saved without Mip Maps.

I opened them in Paint.NET and re-saved them with the options DXT5, Iterative Fit and Generate Mip Maps checked. I was then able to view your mesh with textures in Nexus 3D Viewer.

Apart from that I could see anything wrong with your files, but I could get the animations to play in Nexus Viewer either. Perhaps try in game with the corrected textures and see if you have more luck.

For this to work with Asset Viewer, do my files need to be in the game's Asset Path? Or is it supposed to automatically find the files if they're in the same folder as the .fxsxml file?

Any files from the vanilla resources will be found automatically but any custom files will need to be in the same location as the fxsxml. I've never used the Validate button.
 
Ok the rest of the problem was that your .fxsxml file had several issues.

1) It had duplicated AnimGraph rows - I used the same set as for the Lion instead. The Texture lines are redundant so I removed those.

2) The names of the animation .gr2s didn't match your actual files. I updated them and the model now animates fine in Nexus Viewer so I think it should be fine in game.

Here's the fixed .fxsxml.

Spoiler :
Code:
<Asset>
	<Mesh file="incubator.gr2"/>
	<Animation file="incubator_md_idle_anim.gr2" ec="1000, 1020, 1450, 1800, 2000, 2020, 1440, 2440" />
	<Animation file="incubator_md_run_anim.gr2" ec="1120, 1140, 1400" />
	<Animation file="incubator_md_fidget_anim.gr2" ec="1040, 2040" />
	<Animation file="incubator_md_fortifya_anim.gr2" ec="1500" />
	<Animation file="incubator_md_fortifya_idle_anim.gr2" ec="1520, 1540, 1560, 1580, 1600, 1620, 1640, 1285, 1290" />
	<Animation file="incubator_md_strikea_anim.gr2" ec="1100, 1160, 1180" />
	<Animation file="incubator_md_strikeb_anim.gr2" ec="2100" />
	<Animation file="incubator_md_diea_anim.gr2" ec="1200, 2200" />
	<Animation file="incubator_md_diea_fade_anim.gr2" ec="1220, 2220" />
	<Animation file="incubator_md_hurta_anim.gr2" ec="1280" />
	<AnimGraph file="SHUFFLE_STOP_GRAPH.dge"/>
	<AnimGraph file="START_RUN_CHARGE_SHUFFLE.dge"/>
	<AnimGraph file="ATTACK_CITY_TO_RUN_CHARGE_SHUFFLE.dge"/>
	<AnimGraph file="ATTACK_TO_RUN_CHARGE_SHUFFLE.dge"/>
	<AnimGraph file="RUN_CHARGE_SHUFFLE_LOOP.dge"/>
	<StateMachine file="1_OMNI_STATE_01.fsmxml"/>
	<AnimGraph file="RUN_CHARGE_SHUFFLE_TO_SHUFFLE_RUN_CHARGE.dge"/>
	<AnimGraph file="MELEE_ATTACKS.dge"/>
	<AnimGraph file="FIDGETS_GRAPH.dge"/>
	<AnimGraph file="IDLE_GRAPH.dge"/>
	<AnimGraph file="STOP_RUNNING.dge"/>
	<AnimGraph file="TRANSITIONS_FOR_IDLES.dge"/>
	<AnimGraph file="FORTIFY_GRAPH.dge"/>
	<AnimGraph file="COMBAT_READY_GRAPH.dge"/>
	<AnimGraph file="FORTIFY_LEAVE_GRAPH.dge"/>
	<AnimGraph file="ENTER_COMBAT_READY_GRAPH.dge"/>
	<AnimGraph file="LEAVE_COMBAT_READY.dge"/>
	<AnimGraph file="DEATH_GRAPH.dge"/>
	<AnimGraph file="ENTER_BOMBARD_DEFEND_GRAPH.dge"/>
	<AnimGraph file="BOMBARD_DEFEND_LOOP_GRAPH.dge"/>
	<AnimGraph file="DEATH_FINAL_GRAPH.dge"/>
	<AnimGraph file="LEAVE_BOMBARD_DEFEND_TRANS_IDLE_A_GRAPH.dge"/>
	<AnimGraph file="ENTER_FORTIFY.dge"/>
	<AnimGraph file="FORTIFY_FIDGET_GRAPH.dge"/>
	<AnimGraph file="IDLE_OFFSET_CONTINUE_TRUE_GRAPH.dge"/>
	<TimedTrigger file="FX_Triggers_Barbarian_EURO.ftsxml"/>
</Asset>

Here's your unit in Nexus Viewer - well done at following the tutorial - having the animations should speed up making/converting other units that use the Panther animations. :)

Spoiler :
 

Attachments

  • incubator.jpg
    incubator.jpg
    64.1 KB · Views: 5,418
Many thanks for the help! But it still seems like I can't quite get as far as you did. I re-exported my texture as a DXT5 with mipmaps, and now it looks like this on my Asset Viewer:

Spoiler :


Trying it in-game doesn't yield a much better result...

Spoiler :


I'm pretty sure the issue here is still the texture. I tried it both with my mainstay for .dds editing, GIMP, and then with Paint.net with the settings you said, and the issue happened both times. Does the 4x4 black texture need a mipmap?

I'll go ahead and upload the updated texture in case you'd be willing to look and see if I did it right. Thanks again for all your help!
 

Attachments

  • qbtexture.7z
    5.1 KB · Views: 168
I'm pretty sure the issue here is still the texture. I tried it both with my mainstay for .dds editing, GIMP, and then with Paint.net with the settings you said, and the issue happened both times. Does the 4x4 black texture need a mipmap?

Yeah, both textures need mip maps. Whenever you see the red and white checked pattern in Nexus Viewer it means there is an issue with your textures - they are either not mapped up properly, missing or in the wrong format.

Also from your in-game shot it looks like you might not have scale set to 1 in your ArtDefines XML. Check that first.

I need to investigate why this process is make .gr2s that don't scale properly.
 
Also from your in-game shot it looks like you might not have scale set to 1 in your ArtDefines XML. Check that first.

I must have missed that. That fixes it!

Spoiler :


It still shows up with those checkers in Asset Viewer, but if it shows up properly in-game, that's all that matters to me. I highly doubt anyone else will wanna use the model, haha.

I'll be watching the thread in case you find out what causes the scaling issues, because I did want the unit formation to have extra-small, extra-numerous units. But hey, what I've got already is great.

Thanks again for all your help!
 
I've attempted this tutorial with the Sea Dragon (a unit that has 3 meshes: front, middle, and back).

After re-export to NIF, the meshes become distorted when animated.

I can do the straight NIF to FBX, then brute force until I get an uncorrupted GR2. But although I have beautifully animated GR2s, after I export the animation using Nexus Buddy 2, the resulting file doesn't animate the non-animated GR2 conversion.

Any ideas?
 
Is the rotation correct in Nexus Viewer? Normally if the unit appears the correct way up when animated there it appears OK in game.

All I can suggest is try and adjust the rotate in Blender to compensate before exporting.
 
EDITED.

I DID IT. The problem was the following:

The overwritting of the meshes (point 10) corrupts my unit. I elapsed that point and transformed directly from FBX to GR2, and it worked perfectly.

I will upload the spider tomorrow, but I need to fix before why it appears fire arrows when attacking :)
 
EDITED.

I DID IT. The problem was the following:

The overwritting of the meshes (point 10) corrupts my unit. I elapsed that point and transformed directly from FBX to GR2, and it worked perfectly.

I will upload the spider tomorrow, but I need to fix before why it appears fire arrows when attacking :)

Well done! Unit conversion definitely needs you to be prepared to experiment sometimes to work around issues.

The flaming arrow attack is set in the Art Defines XML so it is simple to change or remove:

Code:
<Row>
<UnitMemberType>ART_DEF_UNIT_MEMBER_LION</UnitMemberType>
<Index>1</Index>
<SubIndex>0</SubIndex>
<VisKillStrengthMin>10.0</VisKillStrengthMin>
<VisKillStrengthMax>20.0</VisKillStrengthMax>
<WeaponTypeTag>FLAMING_ARROW</WeaponTypeTag>
<MissTargetSlopRadius>10.0</MissTargetSlopRadius>
</Row>
 
I've worked out what was causing the issue with scaling and bone roll.

The original units I converted back in 2010 used Nexus Buddy 0.1a which uses different code that creates the model gr2 from an animated FBX file. When I use this technique I don't have the bone roll issues or the issue with unit scaling. I've incorporated this code into Nexus Buddy 2 and will upload and update the tutorial when I have time.
 
Top Bottom