Getting Civ 4 Units into Civ 5 - Full Conversion

Ah, well it's definitely not the first one since I have nowhere near 32 vertex groups (and deliberately avoided that), but the second one looks on the mark. I used the version of the export script from the first post in the thread, which I think is out of date since it clearly doesn't do what he says in the second post (and dates to February). I'll try rewriting to match his new version of the script and report back.

EDIT: Actually, it does look like I had the new version, since I do see something about 255. Doesn't seem to be working though after I rewrote for 2.71. Let me look through it...

EDIT2: Ah! No I didn't. There's several more lines in the new script that enforce the 255 weight that I didn't have before.

EDIT3: Well, progress. The warping is gone. However, something still appears wrong in Nexus:

It looks like the mesh is glitched such that there's a giant part of her back that's missing...but this doesn't show up if I open the gr2 in granny.

And if I try it in civ 5, giant glitch texture is still there:

I've tried playing with the scaling, to no avail, and direct size comparison between this unit and, for example, the antiaircraft gun, shows that she's about 1/2 the size of the gun, so there's no reason she should appear as some sort of full-screen giant.

EDIT4: And just to rule it out, I've tried scaling it down all the way 0.0001, and replacing the current 2048x2048 texture with a more typical 256x256 texture. Neither of those do anything. Having no texture at all just causes a giant red/white texture glitch. I'm going to take a break for now...

I didn't figure it was the first one since I only saw 3 vertex groups in the mesh, but not having a complete picture I didn't want to rule it out. I still have problem units myself, so this may be yet another unsolved anomaly.

I have one more suggestion, and it could be valid since a) you mentioned you worked on this in a later version of Blender and b) There are parts of the mesh missing in Nexus. Have you checked to verify that the mesh doesn't have any n-gons? Only quads and tri's can be converted, so if you have pieces of mesh that have more than 4 sides (including a tri or quad that has a vertex along an edge with no connecting edges) then I can see this problem occurring (this has happened to me before). Hopefully this is the culprit.

If not, this sounds like a job for: The Deliverator! :D
 
I didn't figure it was the first one since I only saw 3 vertex groups in the mesh, but not having a complete picture I didn't want to rule it out. I still have problem units myself, so this may be yet another unsolved anomaly.

I have one more suggestion, and it could be valid since a) you mentioned you worked on this in a later version of Blender and b) There are parts of the mesh missing in Nexus. Have you checked to verify that the mesh doesn't have any n-gons? Only quads and tri's can be converted, so if you have pieces of mesh that have more than 4 sides (including a tri or quad that has a vertex along an edge with no connecting edges) then I can see this problem occurring (this has happened to me before). Hopefully this is the culprit.

If not, this sounds like a job for: The Deliverator! :D

Thanks for the help, but I checked: It's all triangles.

But actually I ran across a major hint. I was fiddling with the display options in Nexus, and changed the "Z Mode" from the default "Write & Test (CW)" to "Write & Test" and now it looks like this:

attachment.php


or in other words, it looks right now. I can't get it to this in-game, so...what on earth does "Write & Test (CW)" mean?? Are my normals flipped or something?

EDIT: Yep, my normals were flipped. Looks correct in Nexus for the first time ever. Let's see how it looks in Civ 5.
 

Attachments

  • Capture5.PNG
    Capture5.PNG
    82.7 KB · Views: 579
Thanks for the help, but I checked: It's all triangles.

But actually I ran across a major hint. I was fiddling with the display options in Nexus, and changed the "Z Mode" from the default "Write & Test (CW)" to "Write & Test" and now it looks like this:

or in other words, it looks right now. I can't get it to this in-game, so...what on earth does "Write & Test (CW)" mean?? Are my normals flipped or something?

EDIT: Yep, my normals were flipped. Looks correct in Nexus for the first time ever. Let's see how it looks in Civ 5.

Don't quote me on this, but it looks to me like Z-Mode is the equivalent of Z-buffering when an object is rendered; CW may mean "color-write" or "clockwise," both of which are modes used when rendering. Apart from that, I have no clue how solve this to prevent how it is affecting your model in-game :sad: .
 
Don't quote me on this, but it looks to me like Z-Mode is the equivalent of Z-buffering when an object is rendered; CW may mean "color-write" or "clockwise," both of which are modes used when rendering. Apart from that, I have no clue how solve this to prevent how it is affecting your model in-game :sad: .

Flipping my normals around in Blender and reimported solved my problems with Nexus. Here's the idle pose:
attachment.php

This time, it's without messing with any of the render settings. I have no animations at the moment, so all my animations are just set to the same pose.

This is how granny looks:
attachment.php

Apparently, the way it looked so black before was a big hint. It looks normal now.

This is how granny looks with both her and the anti-aircraft gun loaded (you can see her feet sticking out of the bottom of the gun-this is just to check size and orientation):
attachment.php


EDIT: So I also discovered that my bone weights were wrong and I had unassigned vertex weights. So I fixed all of that, and have the correct number of bones now (21). It doesn't fix it. FML

Everything I can possibly think of checks out, BUT IT STILL MAKES A GIANT GLITCH IN-GAME.

Ugh, I'll go do something else for a while. Save me, Deliverator. :help:
 

Attachments

  • Capture7.PNG
    Capture7.PNG
    91 KB · Views: 583
  • Capture9.PNG
    Capture9.PNG
    80.1 KB · Views: 588
  • Capture8.PNG
    Capture8.PNG
    172 KB · Views: 562
I'm two steps from releasing a new fantasy unit. It actually is playable and all, but the animations are a bit off:
1) He is walking sideways.
2) It takes too long for the death/attack animation to happen, how can I shorten it?

Do you mean sideways as in to the side vice forward or is it's orientation off 90 degrees?

The animations work on animgraphs (.dge files referenced in the .fxsxml), so an attack actually consists of multiple animations. You can get a better understanding of animgraphs by viewing their flowcharts in Nexus.

The death animgraph consists of an idle at the end. So, if you only have a death animation but not a death_idle animation and you have not referenced it properly in the .fxsxml file than it may stall while looking for a referenced file that doesn't exist.

You must reference every event code to an animation. Event codes vary by unit so if you are using warrior animations for your template only use those event codes from it's .fxsxml file. Here is a sample .fxsxml with very minimal custom animation event codes (only 6):

Spoiler :
<Animation file="IdleA_anim.gr2" ec="1000, 1440, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 2000, 2440"/>
<Animation file="FidgetA_anim.gr2" ec="1020, 1040, 1800, 2020, 2040"/>
<Animation file="Run_anim.gr2" ec="1120, 1140, 1400, 1450"/>
<Animation file="AttackA_anim.gr2" ec="1100, 1160, 1180, 2100"/>
<Animation file="HurtA_anim.gr2" ec="1280, 1285, 1290"/>
<Animation file="DeathA_anim.gr2" ec="1200, 1220, 2200, 2220"/>


Even though I only have 6 animations, all 32 event codes are referenced.

Not sure if that is your problem or not, but if your animations look correct in Granny but not in the game it is the .fxsxml that is usually the culprit.
 
He turns to it's left to start the walking animation.
You click at one plot, he goes there, but 'looking' at another...
{ . } { . }
{ H> } { . }
{ . } { . }
becomes
{ . } { . }
{ . } { H\/ }
{ . } { . }

If the diagnostic is hard - it probably is, there is a huge lack in the information you may need, as I can't give much since I don't know much - I can simply remake all the animations and see if something goes wrong this time.

====

They work, they were designed in the original game with that 'delay', the unit is that 'tank' type, while it's animation is 'charging' it is getting hit and all that, which is not a problem in RTS, but a huge down in TBS, where all warriors already ended their attack, went back to their tile and the hulk is just starting to raise his hands.
I want to edit the animation and cut down the slow start, and/or speed up the animation.
 
He turns to it's left to start the walking animation.
You click at one plot, he goes there, but 'looking' at another...
{ . } { . }
{ H> } { . }
{ . } { . }
becomes
{ . } { . }
{ . } { H\/ }
{ . } { . }

If the diagnostic is hard - it probably is, there is a huge lack in the information you may need, as I can't give much since I don't know much - I can simply remake all the animations and see if something goes wrong this time.

====

They work, they were designed in the original game with that 'delay', the unit is that 'tank' type, while it's animation is 'charging' it is getting hit and all that, which is not a problem in RTS, but a huge down in TBS, where all warriors already ended their attack, went back to their tile and the hulk is just starting to raise his hands.
I want to edit the animation and cut down the slow start, and/or speed up the animation.

It's definitely a problem with the animations, then. For that, you will need to edit them before you export them to .fbx. The delay is easy enough to fix, you may be able to adjust the animation start frame to begin after the delay. I am not sure if that will translate into the .fbx file or not, so if that doesn't work just delete them altogether. If it is still too long of an attack you can also adjust the framerate (FPS) to speed it up a bit. I'd recommend looking at an animation tutorial first; here is a good one to get you started, which also explains the basics of modeling as well.
 
After several times of giving up on it and giving it another go, I'm finally beginning to get the hang of getting Civ4 units into Civ5. Thanks muchly for everything you've written on it. Unfortunately I'm now running into an odd glitch in the rotation correction in the .fbx animation export.
With some animations, the correction factor seems to get progressively bigger where it should stay the same, so that the unit appears to be tipping over forward into the ground. (I know this has to do with the correction in the .fbx export because when I turn that off it doesn't happen.) I can't figure out what property of the animation causes this (they work fine in nifscope) and I haven't found a way to work around it either.
In the zip file I'm attaching, the fidget animation converts fine and the ranged attack animation gives the glitch.
 

Attachments

I have come across this as well where animations work fine in blender and nifscope but as soon as they are exported to granny they tip over. Sorry but I was never able to come up with a solution and would also be keen to find one.
 
It definitely has something to do with the fbx export. After doing the export, you can actually see the issue in Blender by looking at the frames beyond the first one (press right arrow key).
Following a hunch, I discovered something potentially useful: it seems the amount of extra rotation per frame is 90/(n-1), where n is the total number of frames (you can figure out n by telling blender to go to the end frame). In other words, the added rotation is such that the end frame would be rotated an extra 90 degrees, were it affected. (Oddly though, the end frame is not affected.)
 
Something I found when making custom animations: do not use the Animation Fix: Rotate Y-90. This rotates only the first frame for me, so when I made a flapping animation for an Eagle unit and checked that, the eagle rotated to a correct position for the first frame only, then swung back to being face-down... I had to rotate every keyframe's pose so that in Blender it appears to be lying on it's back before it would appear correctly in Granny even.
 
How do you rotate the poses in individual frames without applying the same rotation to all other frames? If I could do that I might be able to work around the issue at least.
 
Yes! It took a while before I got what you were saying, but I now have a good workaround: Select the armature, go into edit mode, use the menu to select all, then rotate to the position you need (press R X -90). If the center of rotation is off, set it to the 3d cursor using the dropdown menu before rotating.
141kt2c.png

You can then export to fbx without the fix and it will work. And the best part is that you don't have to it separately per frame.

The meshes will look terrible now, but that doesn't matter here. You can rotate them to pretty things up if you want, but be careful not to do anything else with the armature inside edit mode. Everything should sort itself out in granny.
 
Yes, they look right in granny. Some do seem higher above ground than others, so I have to hope that doesn't carry over into the game.

edit: Further experimentation shows that the height difference is due to my moving the center of rotation of the armature elements in edit mode. So don't do that. The results may look a bit iffy in blender, but it will work out in granny.

edit2: More good news: you don't have to actually touch the meshes at all.
 
A little bump because important edits just keep stacking up unseen otherwise. After finally testing in-game, I noticed the proper center of rotation does matter. I also noticed an easy way to rotate properly, right there in blender. Post updated with a picture.
 
Hey, can you help me? I use this tutorial to import unit to civ5, but in game cant see the mesh of model:
its unit:
http://forums.civfanatics.com/downloads.php?do=file&id=23934
thats xml of my mod:

Spoiler :

<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 30.08.2015 23:55:00 -->
<GameData>
<UnitClasses>
<Row>
<Type>UNITCLASS_SU_34</Type>
<Description>Su 34</Description>
<DefaultUnit>UNIT_SU_34</DefaultUnit>
</Row>
</UnitClasses>
<Units>
<Row>
<Class>UNITCLASS_SU_34</Class>
<Type>UNIT_SU_34</Type>
<!-- <PrereqTech>TECH_LASERS</PrereqTech> -->
<RangedCombat>60</RangedCombat>
<Cost>425</Cost>
<Moves>2</Moves>
<Immobile>true</Immobile>
<Range>10</Range>
<Special>SPECIALUNIT_FIGHTER</Special>
<CombatClass>UNITCOMBAT_FIGHTER</CombatClass>
<Domain>DOMAIN_AIR</Domain>
<DefaultUnitAI>UNITAI_DEFENSE_AIR</DefaultUnitAI>
<Description>su-34</Description>
<Civilopedia>NONE</Civilopedia>
<Strategy>NONE</Strategy>
<Help>NONE</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<Mechanized>true</Mechanized>
<AdvancedStartCost>70</AdvancedStartCost>
<AirUnitCap>1</AirUnitCap>
<RangedCombatLimit>100</RangedCombatLimit>
<CombatLimit>0</CombatLimit>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>2</XPValueDefense>
<UnitArtInfo>ART_DEF_UNIT_SU34</UnitArtInfo>
<UnitFlagIconOffset>78</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_2</IconAtlas>
<PortraitIndex>31</PortraitIndex>
<MoveRate>AIR_REBASE</MoveRate>
</Row>

</Units>
</GameData>



Spoiler :

<?xml version="1.0" encoding="utf-8"?>
<GameData>
<ArtDefine_UnitInfos>
<Row>
<Type>ART_DEF_UNIT_SU34</Type>
<DamageStates>1</DamageStates>
<Formation>FighterWing</Formation>
</Row>
</ArtDefine_UnitInfos>
<ArtDefine_UnitInfoMemberInfos>
<Row>
<UnitInfoType>ART_DEF_UNIT_SU34</UnitInfoType>
<UnitMemberInfoType>ART_DEF_UNIT_MEMBER_SU34</UnitMemberInfoType>
<NumMembers>1</NumMembers>
</Row>
</ArtDefine_UnitInfoMemberInfos>
<ArtDefine_UnitMemberInfos>
<Row>
<Type>ART_DEF_UNIT_SU34</Type>
<Scale>100</Scale>
<Domain>Air</Domain>
<Model>Su-34_Cam1.fxsxml</Model>
<MaterialTypeTag>METAL</MaterialTypeTag>
<MaterialTypeSoundOverrideTag>METALLRG</MaterialTypeSoundOverrideTag>
</Row>
</ArtDefine_UnitMemberInfos>
<ArtDefine_UnitMemberCombats>
<Row>
<UnitMemberType>ART_DEF_UNIT_SU34</UnitMemberType>
<EnableActions>Idle Attack Bombard Death Run</EnableActions>
<AttackRadius>135.0</AttackRadius>
<MoveRate>2.0</MoveRate>
<TurnRateMin>0.25</TurnRateMin>
<TurnRateMax>0.5</TurnRateMax>
<HasRefaceAfterCombat>0</HasRefaceAfterCombat>
</Row>
</ArtDefine_UnitMemberCombats>
<ArtDefine_UnitMemberCombatWeapons>
<Row>
<UnitMemberType>ART_DEF_UNIT_MEMBER_SU34</UnitMemberType>
<Index>0</Index>
<SubIndex>0</SubIndex>
<ProjectileSpeed>3.0</ProjectileSpeed>
<HitEffect>ART_DEF_VEFFECT_FIGHTER_MACHINE_GUN_HIT_$(TERRAIN)</HitEffect>
<HitRadius>15.0</HitRadius>
<WeaponTypeTag>BULLETHC</WeaponTypeTag>
<WeaponTypeSoundOverrideTag>BULLETHC</WeaponTypeSoundOverrideTag>
</Row>
<Row>
<UnitMemberType>ART_DEF_UNIT_MEMBER_SU34</UnitMemberType>
<Index>1</Index>
<SubIndex>0</SubIndex>
<VisKillStrengthMin>1.0</VisKillStrengthMin>
<VisKillStrengthMax>1.0</VisKillStrengthMax>
<HitEffect>ART_DEF_VEFFECT_FIGHTER_MACHINE_GUN_HIT_$(TERRAIN)</HitEffect>
<HitRadius>15.0</HitRadius>
<WeaponTypeTag>BULLETHC</WeaponTypeTag>
<WeaponTypeSoundOverrideTag>BULLETHC</WeaponTypeSoundOverrideTag>
</Row>
<Row>
<UnitMemberType>ART_DEF_UNIT_MEMBER_SU34</UnitMemberType>
<Index>1</Index>
<SubIndex>1</SubIndex>
<ID>PROJECTILE</ID>
<VisKillStrengthMin>25.0</VisKillStrengthMin>
<VisKillStrengthMax>50.0</VisKillStrengthMax>
<ProjectileSpeed>3.0</ProjectileSpeed>
<WeaponTypeTag>EXPLOSIVE</WeaponTypeTag>
<WeaponTypeSoundOverrideTag>EXPLOSION200POUND</WeaponTypeSoundOverrideTag>
</Row>
</ArtDefine_UnitMemberCombatWeapons>
<ArtDefine_StrategicView>
<Row>
<StrategicViewType>ART_DEF_UNIT_SU34</StrategicViewType>
<TileType>Unit</TileType>
<Asset>Su-34_Cam1_diff.dds</Asset>
</Row>
</ArtDefine_StrategicView>
</GameData>





In game I have than new unit to build, its can use, but I cant see the mesh, but I see icon of it, I can click it.



p.s. sorry for my english.:)
 
Back
Top Bottom