Converting Civ V Units to Civ IV

Okay, so I've made some progress.

The model I want to convert doesn't line up with a standard civ 4 skeleton, so I needed to adjust my skeleton. Blender 2.49b is not very intuitive but there are loads of video tutorials out there. I found Ira Krakow's ones to be fairly clear.
Within Civfanatics, the most relevant tutorial for this reworking of the skeleton is @The_Coyote 's tutorial, which you can find through https://forums.civfanatics.com/threads/tut-animate-with-blender-and-nifscope.296286/.
To do the animation, you'll want to create your own kfm. To do this you'll want @esemjay 's KonverterFM utility. This is available at https://forums.civfanatics.com/resources/konverterfm.8747/.

Using the above I was able to create a number of kf animations, reference them in a kfm and they seem to work in game.

My main problem is that the skin texture isn't showing up in game.
I thought this would be the easy bit as the seams were all imported correctly into blender so that the existing dds file displays correctly on the unit in blender. The dds is 256*256, which I think should work fine in the game.
I expect that I'm not clicking one of the options that needs to be clicked when exporting the nif from blender.
When I try to reimport the nif back into blender, it's just the bare skeleton.
When I open it with nifSkope, there's nothing to see.

Can someone advise as to how I export a nif from blender 2.49b so that it has the correct texture?

---
On a separate note, can someone advise what settings I should use to import one of the kf I've created? I can create them from scratch but I expect that I may want to tweak some, when I see how they look in game.

I don't find his tutorial that welcoming to first comers , have you got any other source? I have been personally using Ira Krakow and he's been a great help to get started with Blender, managed to create an unrigged model
 
I don't find his tutorial that welcoming to first comers , have you got any other source? I have been personally using Ira Krakow and he's been a great help to get started with Blender, managed to create an unrigged model

I made a half-assed tutorial. Its a PDF and not a video. I think Louis has started making video tutorials if you scroll down the main page. Edit: :espionage: topsecret is the one making videos in the Modding & Tutorial forum.
https://forums.civfanatics.com/threads/video-tutorials-on-modding-civ4.662526/


https://forums.civfanatics.com/attachments/mightytoad_tutorial-rar.552960/
 
Last edited:
Thanks a lot! Your tutorial is just what I needed :) ; I do have a question though : easier or not to just import the skeleton? I will try by importing the skeleton of the original CIV4 marine and follow your tutorial

You could import only the skeleton. But I have found it is faster, and easier in the long run to just import the entire nif.
You will have to do that to use the bone weight copy script. I usually use that for non mech units like the marine.

Once the two meshes are joined. Go to edit mode and hopefully only the vanilla mesh vertices will be selected still. Delete them leaving only your new mesh.

Hope that makes sense.
 
You could import only the skeleton. But I have found it is faster, and easier in the long run to just import the entire nif.
You will have to do that to use the bone weight copy script. I usually use that for non mech units like the marine.

Once the two meshes are joined. Go to edit mode and hopefully only the vanilla mesh vertices will be selected still. Delete them leaving only your new mesh.

Hope that makes sense.

Yeah I got it! Sadly the unit I am trying to create is too bulky for any type of unit skeleton that I know, so I had to learn how to create a new skeleton from scratch..took all day but got it in the end :lol:, using vertex grouping and the disjointed bones method to animate separate parts of the model without touching the vertex of the main body.

Now I wonder if I will have to learn how to animate this rigged model from scratch or I can use the animation from another model ( which does sound strange to me at this point)...either way I am getting there, quite happy with my work up to this point, I had to watch dozen or so of tutorial videos,read notes etc etc but was all worth it
 
Okay, so I've made some progress.

The model I want to convert doesn't line up with a standard civ 4 skeleton, so I needed to adjust my skeleton. Blender 2.49b is not very intuitive but there are loads of video tutorials out there. I found Ira Krakow's ones to be fairly clear.
Within Civfanatics, the most relevant tutorial for this reworking of the skeleton is @The_Coyote 's tutorial, which you can find through https://forums.civfanatics.com/threads/tut-animate-with-blender-and-nifscope.296286/.
To do the animation, you'll want to create your own kfm. To do this you'll want @esemjay 's KonverterFM utility. This is available at https://forums.civfanatics.com/resources/konverterfm.8747/.

Using the above I was able to create a number of kf animations, reference them in a kfm and they seem to work in game.

My main problem is that the skin texture isn't showing up in game.
I thought this would be the easy bit as the seams were all imported correctly into blender so that the existing dds file displays correctly on the unit in blender. The dds is 256*256, which I think should work fine in the game.
I expect that I'm not clicking one of the options that needs to be clicked when exporting the nif from blender.
When I try to reimport the nif back into blender, it's just the bare skeleton.
When I open it with nifSkope, there's nothing to see.

Can someone advise as to how I export a nif from blender 2.49b so that it has the correct texture?

---
On a separate note, can someone advise what settings I should use to import one of the kf I've created? I can create them from scratch but I expect that I may want to tweak some, when I see how they look in game.

Do you mean how to import the nif into nifscope?
-In that case you need to select the correct path in nifscope, the location where the .dds file of the imported nif is located
-I applied the right texture to each material used by my model, the exported nif will only display the texture for the material used, evn if you ctrl+j a group of mesh, the end result will still have a group of different materials attached to it, so the texture must be applied to every single material if you want it to display in nifscope

...hope this is what you meant

About the animation part...just getting to it, created a custom skeleton for my model
 
Do you mean how to import the nif into nifscope?
-In that case you need to select the correct path in nifscope, the location where the .dds file of the imported nif is located
-I applied the right texture to each material used by my model, the exported nif will only display the texture for the material used, evn if you ctrl+j a group of mesh, the end result will still have a group of different materials attached to it, so the texture must be applied to every single material if you want it to display in nifscope

...hope this is what you meant

About the animation part...just getting to it, created a custom skeleton for my model

Hi,

2 steps forward, 2 back...
I managed to sort the texturing. At least now the texture is on the nif when I open it in NifSkope.
Unfortunately, something in the way I've done it means that the graphics no longer work in the game. If I click on the unit on the pedia screens, the game just freezes. If I try to world build the unit into a game, I hit a break with "[Frames below may be incorrect and/or missing, no symbols loaded for d3d9.dll]".
I had also corrupted something in the animations, as when I loaded up the nif with one of the kf (thanks to @MightyToad's post), I got what looked like a ball of corrupted, rotting flesh repeatedly stabbing itself.
I'm not too concerned about the animations. If I can get the textured unit back into the game, then I can recreate these.

For the moment I've created a simplified kfm, where guo_MD_idle.kf is used as the kf for everything. This is just a kf with the unit turning for the moment.
On testing the current nif and this kf by importing them into blender, they appear to work.

The art defines code I have is,
Spoiler :
Code:
        <UnitArtInfo><!-- Great Unclean One - Archdemon 2 -->
            <Type>ART_DEF_UNIT_ARCHDEMON_2</Type>
            <Button>Art/Units/Demons/guo/guobutton.dds</Button>
            <fScale>0.53</fScale>
            <fInterfaceScale>0.8</fInterfaceScale>
            <bActAsLand>0</bActAsLand>
            <bActAsAir>0</bActAsAir>
            <NIF>Art/Units/Demons/guo/guo.nif</NIF>
            <KFM>Art/Units/Demons/guo/guo.kfm</KFM>
            <SHADERNIF></SHADERNIF>
            <ShadowDef>
                <ShadowNIF>Art/Units/01_UnitShadows/UnitShadow.nif</ShadowNIF>
                <ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
                <fShadowScale>2</fShadowScale>
            </ShadowDef>
                <fBattleDistance>0.35</fBattleDistance>
                <fRangedDeathTime>0.31</fRangedDeathTime>
                <bActAsRanged>0</bActAsRanged>
                <TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
            <AudioRunSounds>
                <AudioRunTypeLoop/>
                <AudioRunTypeEnd/>
            </AudioRunSounds>
        </UnitArtInfo>

The nif, kfm and that test kf file are attached in the rar.
Does anyone know what I'm doing wrong now that's stopping the unit from being used in the game?
 

Attachments

  • nifskopeguo.PNG
    nifskopeguo.PNG
    122.2 KB · Views: 79
  • callstackerrorguo.PNG
    callstackerrorguo.PNG
    19.7 KB · Views: 79
  • guo.rar
    269.4 KB · Views: 56
Without looking at anything else... Your XML won't work.

<SHADERNIF></SHADERNIF>

This is needs to point to your nif. Its what the game uses. It uses the one above if you use low Graphic settings. Normally not used at all. So...

<SHADERNIF>Art/Units/Demons/guo/guo.nif</SHADERNIF>

Is what it should say.

I got what looked like a ball of corrupted, rotting flesh repeatedly stabbing itself.
I'm not too concerned about the animations. If I can get the textured unit back into the game, then I can recreate these.

This sounds similar to a shader problem. I've seen something similar when using skin partitions incorrectly. SaibotLieh is probably one of the more knowledgeable people that still post ATM. Hopefully he can chime in. :hammer2:
 
The shadenif bit is optional. My units newer use it at all and I just remove the tag from the XML entirely. It really only serves a purpose if you actually have a shader specific version of your nif file. But yes, it must not be empty. You can either have it and have content in it or not have it at all.
 


I tried rigging the beast to the warrior skeleton just to humor myself really. It sort of works... sort of. :wallbash:
I attached the blend file if you're interested.
 

Attachments

  • guo_warrior.rar
    269.4 KB · Views: 56
The Shadernif doesn't seem to be the issue. I tried with a different nif referenced with a blank shadernif row and a removed shadernif row and both times, the (applicable) model appeared in the pedia. It freezes at that point when I have the xml point to the guo.nif.

I've the <SHADERNIF></SHADERNIF> line used for a few other artdefines that I've copied from other mods and they appear fine both in the pedia and within the actual game.

---

Am I using the correct settings when exporting the nif and kf in Blender?

---
Nice to see them in game, even if they're not fully right yet.
Even using the files you uploaded, it's not working in my game:confused:.
 

Attachments

  • nifexportsettings.PNG
    nifexportsettings.PNG
    38.1 KB · Views: 62
  • kfexportsettings.PNG
    kfexportsettings.PNG
    38.5 KB · Views: 63
Last edited:
I think you will have a hard time trying to make a nif work in Civ4 which directly comes from Blender. What I would rather do is nifswap the model into an already existing vanilla nif.

Since you have a custom skeleton, you will have to do a bit more work than the standard nifswap though. Here is what I would do (I use the axeman_fx.nif as an example):

- First, make sure your custom model mesh is in the NiTriShape format. If it is a NiTriStrips, you can turn it into NiTriShape via right-click -> Mesh -> Triangulate

- Once you have a NiTriShape, right-click on it and go Mesh -> Make Skin Partition (change the 18 to 4 in the new window before Ok-ing). This will allow the unit to be shadered (If you want to make an unshadered unit, make sure the NiSkinInstance has no NiSkinPartition. If it has, just delete it).

- Now, open the vanilla nif and within the NiNode called "MD NonAccum", right-click -> block -> remove branch the NiNode called "BIP"

- Within the NiTriShape called "Axeman_body", remove branch the NiTriShapeData and NiSkinInstance nodes

- From your unit, find the NiNode called "BIP" and right-click -> block -> copy branch it. Then in the vanilla nif right-click -> block -> paste branch on the "MD NonAccum" NiNode

- In the vanilla nif, click on the NiMultiTargetTransformController and add in the "Extra Targets" in the Block Details all the numbers of the BIP tree you justed copied into the file
(the BIP tree is the skeleton of the unit, and by adding the bones to the NiMultiTargetTransformController, Civ4 can animated these bones via the kf file)

- Now that the BIP node is set up correctly, you can copy branch, paste branch the NiTriShapeData and NiSkinInstance of your custom model into the vanilla nif file. These nodes should appear all the way at the bottom of the node list, so you will still have to connect them to the Axeman_body NiTriShape. This you can do by going to the Block Details of the NiTriShape and enter the number of the NiTriShapeData into "Data" and of the NiSkinInstance into "Skin Instance"

- To have the unit show the right texture, change the entry in the NiTexturingProperty accordingly

- Since the vanilla nif is of a shadered unit, everything is already set up for that. If you want the unit to be unshadered, you will have to change in the Block Details of the NiTriShape the entry "Has Shader" to no.

That should basically be it. If you need more meshes than one, make a copy (via copy branch) of the Axeman_body NiTriShape within the MD NonAccum NiNode and replace the copy's NiTriShapeData and NiSkinInstance nodes with the nodes of the second mesh you want to transfer.

Hope this works for you. :)

P.S.: I tried this with your guo model by the way, but still could not get the texture to work. There might be a problem with the Blender export, since your model was missing a NiTexturingProperty node.
 
The Shadernif doesn't seem to be the issue. I tried with a different nif referenced with a blank shadernif row and a removed shadernif row and both times, the (applicable) model appeared in the pedia. It freezes at that point when I have the xml point to the guo.nif.

I've the <SHADERNIF></SHADERNIF> line used for a few other artdefines that I've copied from other mods and they appear fine both in the pedia and within the actual game.

---

Am I using the correct settings when exporting the nif and kf in Blender?

---
Nice to see them in game, even if they're not fully right yet.
Even using the files you uploaded, it's not working in my game:confused:.

You're right about the shadernif thing. I didn't know that.

Anyway, I got your nif to work after I deleted the skin partition, and deleted the extra (double) version of the mesh.

In the export settings in blender: Uncheck the "make skin partition" button.

EDIT:
I forgot. The nif I uploaded works. It must be your XML. Here is the (temporary) one I used:
Code:
<UnitArtInfo>
            <Type>ART_DEF_UNIT_WARRIOR</Type>
            <Button>,Art/Interface/Buttons/Units/Warrior.dds,Art/Interface/Buttons/Unit_Resource_Atlas.dds,2,1</Button>
            <fScale>0.44</fScale>
            <fInterfaceScale>1.0</fInterfaceScale>
            <bActAsLand>0</bActAsLand>
            <bActAsAir>0</bActAsAir>
            <NIF>Art/Units/guo/guo_Warrior.nif</NIF>
            <KFM>Art/Units/warrior/Warrior.kfm</KFM>
            <SHADERNIF>Art/Units/guo/guo_Warrior.nif</SHADERNIF>
            <ShadowDef>
                <ShadowNIF>Art/Units/01_UnitShadows/UnitShadow.nif</ShadowNIF>
                <ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
                <fShadowScale>1.0</fShadowScale>
            </ShadowDef>
            <fBattleDistance>0.35</fBattleDistance>
            <fRangedDeathTime>0.31</fRangedDeathTime>
            <bActAsRanged>0</bActAsRanged>
            <TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
            <AudioRunSounds>
                <AudioRunTypeLoop/>
                <AudioRunTypeEnd/>
            </AudioRunSounds>
        </UnitArtInfo>
 

Attachments

  • Exportsetting.jpg
    Exportsetting.jpg
    121.2 KB · Views: 66
Last edited:
I made a half-assed tutorial. Its a PDF and not a video. I think Louis has started making video tutorials if you scroll down the main page. Edit: :espionage: topsecret is the one making videos in the Modding & Tutorial forum.
https://forums.civfanatics.com/threads/video-tutorials-on-modding-civ4.662526/


https://forums.civfanatics.com/attachments/mightytoad_tutorial-rar.552960/

Ok late reply !

Took me some time to get the head around all the concepts and dozen or so videos but in the end I decided to go with a custom skeleton for my model, did everything by the book and managed to create working animations and nif/kf files, tested everything in nifscope and there also everything works fine
Gundam_20201129_14-36-07.jpg

The one above is the walking animation...kind of xd, will need some time to create fluid animations but hey they work at least in blender and nifscope. Moving forward I tried to use the KFM converter ( where I guess the mistakes have been made ), created a new unit in xml and tried it to run the game...

Civ4ScreenShot0007.JPG


Managed this much but then...no animations, I was expecting of having no sounds/effects because I don't know how to add them in nifscope but for now I was trying to make the unit work in game,can you help? I will upload full unit folder
 

Attachments

  • Gundam.zip
    973.7 KB · Views: 53
Ok late reply !

Took me some time to get the head around all the concepts and dozen or so videos but in the end I decided to go with a custom skeleton for my model, did everything by the book and managed to create working animations and nif/kf files, tested everything in nifscope and there also everything works fine
View attachment 576836
The one above is the walking animation...kind of xd, will need some time to create fluid animations but hey they work at least in blender and nifscope. Moving forward I tried to use the KFM converter ( where I guess the mistakes have been made ), created a new unit in xml and tried it to run the game...

View attachment 576837

Managed this much but then...no animations, I was expecting of having no sounds/effects because I don't know how to add them in nifscope but for now I was trying to make the unit work in game,can you help? I will upload full unit folder
Okay, so firstly your nif is missing most of the stuff a Civ4 nif needs (or at least should have). To get all that stuff, you can follow this procedure I posted earlier in this thread:
I think you will have a hard time trying to make a nif work in Civ4 which directly comes from Blender. What I would rather do is nifswap the model into an already existing vanilla nif.

Since you have a custom skeleton, you will have to do a bit more work than the standard nifswap though. Here is what I would do (I use the axeman_fx.nif as an example):

- First, make sure your custom model mesh is in the NiTriShape format. If it is a NiTriStrips, you can turn it into NiTriShape via right-click -> Mesh -> Triangulate

- Once you have a NiTriShape, right-click on it and go Mesh -> Make Skin Partition (change the 18 to 4 in the new window before Ok-ing). This will allow the unit to be shadered (If you want to make an unshadered unit, make sure the NiSkinInstance has no NiSkinPartition. If it has, just delete it).

- Now, open the vanilla nif and within the NiNode called "MD NonAccum", right-click -> block -> remove branch the NiNode called "BIP"

- Within the NiTriShape called "Axeman_body", remove branch the NiTriShapeData and NiSkinInstance nodes

- From your unit, find the NiNode called "BIP" and right-click -> block -> copy branch it. Then in the vanilla nif right-click -> block -> paste branch on the "MD NonAccum" NiNode

- In the vanilla nif, click on the NiMultiTargetTransformController and add in the "Extra Targets" in the Block Details all the numbers of the BIP tree you justed copied into the file
(the BIP tree is the skeleton of the unit, and by adding the bones to the NiMultiTargetTransformController, Civ4 can animated these bones via the kf file)

- Now that the BIP node is set up correctly, you can copy branch, paste branch the NiTriShapeData and NiSkinInstance of your custom model into the vanilla nif file. These nodes should appear all the way at the bottom of the node list, so you will still have to connect them to the Axeman_body NiTriShape. This you can do by going to the Block Details of the NiTriShape and enter the number of the NiTriShapeData into "Data" and of the NiSkinInstance into "Skin Instance"

- To have the unit show the right texture, change the entry in the NiTexturingProperty accordingly

- Since the vanilla nif is of a shadered unit, everything is already set up for that. If you want the unit to be unshadered, you will have to change in the Block Details of the NiTriShape the entry "Has Shader" to no.

That should basically be it. If you need more meshes than one, make a copy (via copy branch) of the Axeman_body NiTriShape within the MD NonAccum NiNode and replace the copy's NiTriShapeData and NiSkinInstance nodes with the nodes of the second mesh you want to transfer.

Hope this works for you. :)
There is a little bit more that you have to do though to have this work, and that is to rename your NiNode "Skeleton" to "MD" before doing the swap.

Also, it makes sense to have a NiNode between the the "MD NonAccum" NiNode of the Civ4 nif and the "Core" NiNode of your model, since you will have to correct the z-axis a bit.

That should take care of the nif file. Next, your kf files will need a bit adjustment. First, in all of the files, in the Block Details of the NiControllerSequence, you will need to replace the "Target Name" entry with "MD". Further, in the animations that should loop (idle and run animations), you need to change the "Cycle Type" to "CYCLE_LOOP".

This should result in a working unit (at least it did for me, I have attached the modified files to this post).

There are two further things I would change, but these are not strictly necessary:

- For units, I would not use dds files larger than 256*256 pixels. Your 2000*2000 pixels file is a bit of an overkill, and you will probably most of the time play on a zoom level where you cannot tell the difference anyhow.

- For naming the kf files, I would follow the Civ4 standard, so for example instead of "Walk.kf" I would rather use "Gundam_MD_Run.kf". This will help to avoid confusion later on.

Hope this works for you. :)
 

Attachments

  • Gundam_mod.zip
    488 KB · Views: 51
Okay, so firstly your nif is missing most of the stuff a Civ4 nif needs (or at least should have). To get all that stuff, you can follow this procedure I posted earlier in this thread:

There is a little bit more that you have to do though to have this work, and that is to rename your NiNode "Skeleton" to "MD" before doing the swap.

Also, it makes sense to have a NiNode between the the "MD NonAccum" NiNode of the Civ4 nif and the "Core" NiNode of your model, since you will have to correct the z-axis a bit.

That should take care of the nif file. Next, your kf files will need a bit adjustment. First, in all of the files, in the Block Details of the NiControllerSequence, you will need to replace the "Target Name" entry with "MD". Further, in the animations that should loop (idle and run animations), you need to change the "Cycle Type" to "CYCLE_LOOP".

This should result in a working unit (at least it did for me, I have attached the modified files to this post).

There are two further things I would change, but these are not strictly necessary:

- For units, I would not use dds files larger than 256*256 pixels. Your 2000*2000 pixels file is a bit of an overkill, and you will probably most of the time play on a zoom level where you cannot tell the difference anyhow.

- For naming the kf files, I would follow the Civ4 standard, so for example instead of "Walk.kf" I would rather use "Gundam_MD_Run.kf". This will help to avoid confusion later on.

Hope this works for you. :)

Everything works thx a lot!

Sure the only animation working smoothly is the walking animation but I was expecting that, will need to redo the other animations as simply speaking...they're horrible plus will have to add sounds and animation, regardless as far as nif creation and addtion in game ( including the KFM file creation ) everything is working now ^^ , although I did try to load more than 4 units and the game simply freeze and I suppose that is due to the large textures I am using
 
Yea, as far as DDS files go don't go above 256. Most of my units use 128 and it's just fine. Go to my art thread in the FFH section and try to guess which is which. You'd be surprised. Also try and trim away any excess vertices aggressively. CIV4 is a really old game and thus less really is more.
 
Trimmed my current mecha model down to 5230 vertex, anymore and I won't have joints near the pelvis and torso :undecide: , I have downscaled the dds file to 256*256, will redo the animations and see if the game holds up with several units on screen...also does the scale of the unit itself count that much at this point? I am using 1.60 which is double of any unit I ever used in game
 
Top Bottom