1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Nif and shadernif question

Discussion in 'Civ4 - Creation & Customization' started by phungus420, Apr 29, 2009.

  1. phungus420

    phungus420 Deity

    Joined:
    Mar 1, 2003
    Messages:
    6,296
    I've noticed that if I use the NIF of the default unit that the kfm animation is used for in the modded unit I'm defining my art defines block for, and just use the modded nif for the Shadernif tag, the model works.

    This is what I mean. Doing this:

    Code:
    			<NIF>Art/Units/DefaultCivUnit/DefaultCivUnit.nif</NIF>
    			<KFM>Art/Units/DefaultCivUnit/DefaultCivUnit.kfm</KFM>
    			<SHADERNIF>Art/Units/ModdedCivUnit/ModdedCivUnit.nif</SHADERNIF>
    Does the same thing as this, at least on screen it looks the same:
    Code:
    			<NIF>Art/Units/ModdedCivUnit/ModdedCivUnit.nif</NIF>
    			<KFM>Art/Units/DefaultCivUnit/DefaultCivUnit.kfm</KFM>
    			<SHADERNIF>Art/Units/ModdedCivUnit/ModdedCivUnit.nif</SHADERNIF>
    In fact in some cases the top example is the only way to make the model work, but it seems this method always works, for any unit (as long as the moded nif is using the correct kfm). Am I correct here? Is there any substantive difference in the two XML examples above? Should I just start using the first example way to set up my Art Defines file, and always use a default civ unit for the NIF tag, unless the model comes with moded animations?
     
  2. Flintlock1415

    Flintlock1415 Emperor

    Joined:
    Feb 24, 2008
    Messages:
    1,057
    Location:
    MN
    I don't see why the second example wouldn't work where the first one might, unless you did something wrong. For people who cannot display shaders on their systems, they would see the original model instead of the modded unit.
     
  3. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    Yes, the ShaderNif displays on systems that support shaders. The Regular one displays when they cant.
     
  4. cool3a2

    cool3a2 Deity

    Joined:
    Mar 30, 2007
    Messages:
    2,177
    Just an addition. This is what usually causes problems for me (see red line):
    For me the kfm needs to be in the same directory as the modded unit. Otherwise the unit turns back into the unmodded version or something magente when turning off animations in civs menu (to enhance performance).
    Also, the nifs and the kfm need to have the same filename with the following exclusions:
    - ending can and should be different: nif for the model(s) and kfm for the animation; quite logical so far
    - _FX or _fx for one of the modells is allowed
    If it isn't done this way, the model doesn't appear at the lower left corner inside the game.
    Lastly, there should be no kfs, unless they have been modded. Caused the same thing as the kfm thing.
    I tried that on two different systems and had the same problems, so nothing too special, I guess.

    Just for the case you mind.
     
  5. ambrox62

    ambrox62 Emperor

    Joined:
    Mar 24, 2005
    Messages:
    1,294
    Confirmed :sad:

    I had to copy/paste the kfm and ALL the kfs into the custom folder in order to see the modded unit into the lower left corner AND into civilopedia.
    I think it's the same reason because regular ethnic firaxis units got plenty of kfs, kfm, freezes, nif and dds into the same folder.

    Anyone knows a workaround to solve this issue, when lots of custom units share the same animations?
     
  6. cool3a2

    cool3a2 Deity

    Joined:
    Mar 30, 2007
    Messages:
    2,177
    Finally someone who confirms that issue. So far I've never seen that any of the experienced modders considered that problem (or are even aware of that problem) although all their mods would be buggy for me, I guess. I think this is due to the fact that most people play it with animations switched on (freeze mode off) and thus don't recognize that problem. However, it would be a good idea to propagate that, for example by adding that information to a tutorial.

    Although a workaround would be great, I think this is not a so big problem. I decided to make my mod as bug free as possible (in other words I add those files to my mod). This increases its size drastically which ends in longer downloads. The alternative would be to ignore that issue and let noob users die stupid :) I think it is better to take the longer download as most people have access to fast internet (if not at home, then at school or by asking a friend or maybe at work) then to ignore the issue. I think it would be quite unfair to await that users with that problem unpack those archive files (in case of vanilla units based modded units) and to deal with the xml. Although none of them is a hard work for me, I can't await that others are happy to mess with that. And of course, even for me it would be time robbering. I have a lot of units. Finding the right animations, changing the animation, perhaps file names... it would took me 2 or 3 hours. So, in conclusion, I'd say it is better to deal with large mods then ignore that. A workaround would be nice, though. And please no "switch on animations". There is reason that we don't do it.
     
  7. The_Coyote

    The_Coyote Emperor

    Joined:
    Mar 1, 2008
    Messages:
    1,367
    Location:
    Europe
    more or less there are two problems:

    the biggest is the no animation option, because civ4 than uses the freeze nifs from the folder where the kfm is. Most [if not almost all] custom units have no own animation and if they have an own animation they will lack the freeze nifs. (including my models)

    The only real workaround would be to create (make a copy) for every unit an own animation and also create the freeze nifs. Without the nifs the unit will be animated and than the option no animation to save performance will be imo senseless (with lots of custom units almost every unit will be animated). Copying all animation files in the folder will at least remove the model switch (unselected it is the model of the animation, selected it is the custom model)

    the second problem is more or less no real problem, because it´s the way civ4 needs the files. A units has it´s nif(s) and it´s animations files (kfm and kfs). But there are certain rules. The kfm file is a kind of link file, in the file there is a link to a base nif (with the bone structure, which parts are animated, name of bones, etc) and links to the kfs for a certain animation sequence. All files, the base nif and the kfs must be in the same folder like the kfm. The base nif is in most cases the non shader nif. (simply open the kfm with nifskope, if you see a model the base nif is in the folder)

    If a model uses an animation the kfm must no be in the same folder like the model nif, but in the kfm folder the animation base nif and the kfs must be there. The only problem will be problem number one. You will see most of the time a different model with no animation. If you don´t want this you must copy all animation files (kfm and kf). Than there are two options, copy also the base nif of the animation in this folder or rename the model nif to the name of the base nif. If the base nif is missing, beside a lot of python exception (if activated) there is the pedia error (broken entry) and no model in the unit info (left corner)

    So saving space when you can life with problem one it´s easy, simply link in the xml to the kfm in the original folder, if you want to avoid this problem, you have to make copies of the animations for every unit
     
  8. ambrox62

    ambrox62 Emperor

    Joined:
    Mar 24, 2005
    Messages:
    1,294
    Hi Coyote, you always have a solution for my problems !!! :goodjob:

    Because of my poor english, if I've well understood what you wrote in your previous post, I've (probably) found a way to solve the issue in this manner:

    a) I made a "custom_anim_folder" containing:
    - the [my_unit].kfm
    - all the kfs
    - a [model].nif (where [model].nif is the base nif addressed by [my_unit].kfm)

    b) I made a "custom_unit_folder" containing:
    - a [my_unit].nif
    - a [my_unit]_fx.nif
    - all needed dds

    c) I set the artdef xml as:
    <NIF>custom_unit_folder/[my_unit].nif</NIF>
    <KFM>custom_anim_folder/[my_unit].kfm</KFM>
    <SHADERNIF>custom_unit_folder/[my_unit]_fx.nif</SHADERNIF>

    The result of my test is:
    - a correct animated unit
    - the unit showed right in the left corner and into pedia

    The drawback is:
    - no effect with animation yes/no button (i.e the unit is always animated)

    Is this what you stated above?
     
  9. The_Coyote

    The_Coyote Emperor

    Joined:
    Mar 1, 2008
    Messages:
    1,367
    Location:
    Europe
    not completly sure what happens, civ4 search for the files for frozen animation in the folder where the kfm is, but i would expect that it will work like you wrote

    you can also have your animation files in the folder of the unit [eg you have different archer animation [version 1 and version 2] and more custom unit using this two animation]. As long as you don´t care about the frozen animation problem you also could:

    have the animation [inlcuding base file] in one of the units folders, link all other units using the same animation to the kfm in this folder. lets say archer animation is used by the egypt and greek archers. Copy the animation files eg in the egypt folder, the xml entries for both archers would look like

    egypt:
    <NIF>egypt/archer.nif</NIF>
    <KFM>egypt/archer.kfm</KFM>
    <SHADERNIF>egypt/archer_fx.nif</SHADERNIF>

    greek:
    <NIF>greek/greek_archer.nif</NIF>
    <KFM>egypt/archer.kfm</KFM>
    <SHADERNIF>greek/greek_archer_fx.nif</SHADERNIF>

    with frozen animation this setting will result in model switches (the greek archer will be unselected the egypt archer, if in the egypt folder are frozen nifs for the egypt archer). If you want or need to avoid this, you must do it the way you posted. But it´s not necessary to have the model and the animation in different folders [custom_unit_folder and custom_anim_folder could be the same]
     
  10. cool3a2

    cool3a2 Deity

    Joined:
    Mar 30, 2007
    Messages:
    2,177
    Theoretically, how would it be possible to generate those freeze files? I mean, most of the units I am using are more then just reskins. So I doubt that copying those freezes would be enough. When taking a look at the original freezes I saw that there are only the meshes inside, but in different positions. Well, that sounds logical, but how to generate them? Would it be possible to open the nif in 3dsmax for example, then importing its kfm / kf, switching to the right frame and save that as nif? Could this be batched / automatized somehow?

    Also isn't it possible to tell the game, maybe per xml, "use frame x of animation y and unit z as freeze"? I mean, obviously not via the unitartdefines file, but maybe a more experienced coder could put something together...
     
  11. ambrox62

    ambrox62 Emperor

    Joined:
    Mar 24, 2005
    Messages:
    1,294
    I add another question:
    how those freezes might be generated in a quick way using nifscofe, instead?
    If it's possible, it might be a interesting addon to the Coyote nifscope tutorial, imo
     
  12. cool3a2

    cool3a2 Deity

    Joined:
    Mar 30, 2007
    Messages:
    2,177
    Hmmm... Played around with nifskope to find a way to create a freeze with nifskope. My idea was to attach a kf and let it handle the transformation. In my case I tried to get an idle freeze by the idle kf. Well, the mesh got transformed. The problem is, that the freeze only contains the meshs, thus no lights and bones. If I try to copy the mesh to the freeze nif, I get the error that the bones aren't there in the freeze nif and thus the mesh can't be copied. The solution would be to remove the SkinInstance, but then the transformation disappears. Don't know if nifskope is able to store the transformation somehow. At least I didn't find out how to do it...
     
  13. The_Coyote

    The_Coyote Emperor

    Joined:
    Mar 1, 2008
    Messages:
    1,367
    Location:
    Europe
    Not sure, but i think the only good way would be to transform the model in a 3D prog and export it without skeleton in the frozen pose for the animation

    i think this, because, while it would be possible to rotate all bones in nifskope (best open the nif 2 times, in one attach the animation, now adjust the rotation of the bones of the model to match the position of the other nif, save this one as frozen.nif [the numbers are the ids of the aniamtion sequence - look in the tutorial section for the firaxis unit tutorial]).

    But for me it seems not that useful. While you save the time for displaying the animation, the number of objects to drawn and calculated is when using this method not really reduced [all bones are still there, so the only difference is in one case they are aniamted, in the other they stand still - no idea how big the impact is, but for me it seems logical the the frozen nifs have no skeleton to reduce the number of objects [from 30 - 90 to 1]]. But also i´m no real expert in understanding what is graphic (or pc) performance heavy in civ4
     

Share This Page