Exporting units with 3D Studio Max 2009 & NifTools and NifSkope.

El_Salmun

Chieftain
Joined
May 5, 2010
Messages
23
Location
Belgium
EDIT: POST QUESTIONS ABOUT MODELING WITH LATER VERSIONS OF 3D STUDIO MAX AND NIFTOOLS HERE.

This thread is a work in progress. Thanks to The_Coyote I've figured out how to make exported meshes from Max 2009 work in Civ IV. I'll be testing some models with animations in the near future.
When I have enough experience with and enough information about different model types (infantry, horse mount, vehicles etc.) and animations I'll try to slap together a tutorial about modeling with Max 2009. In the meanwhile feel free to post your questions here. If I can't help you than maybe Coyote will.

__________________________________________

Hello,

I'm not the type to start new threads lightly but I have a problem that's been busting my bawlz :mad: all week. I can't get a unit I've made to work in Civ BTS. I've been all over the forums and read the tutorials and modiki about unit creation and exporting but they're all for Max 6 and 7. The dedicated exporter from firaxis only works with these versions and I use Max 2009, which means I have to use NifTools. I've read this "resolved" thread: http://forums.civfanatics.com/showthread.php?p=8524104 but it din't resolve the problem for me.

Here's the sequence of what I did and the problems I had:
1) Imported Vanilla infantry with niftools importer (see image for params).
2) I created a new unit german infantry partly from the vanilla infantry mesh but edited its geometry.
3) I reset X-form and collapse to editable mesh and build a whole new skin modifier (complete reskin) that works perfectly in max.
4) Export everything to nif (see image for params).
Tested the model in Civ: only the gun shows, the soldier is invisible.
5) Nifswap my geometry branch with the infantry branch in the vanilla nif as suggested in the thread mentioned above. Tested the model in civ. Civ crashes when adding the unit in worldbuilder, when opening the civopedia entry it doesn't show any information about the unit (only icon).
6) Tried painstakingly copying every branch of the geometry tree to its corresponding entries in th vanilla nif (including skindatas for every bone...:crazyeye:). When testing in civ the model shows but verts are flying all over the place and the skinning is screwy.

http://img535.imageshack.us/img535/6295/sitrep.jpg

Apparently there's a major problem importing or exporting models for civ with the niftools. It's so frustrating that the official plugin from firaxis only works with older versions...:thumbsdown:. I'm at a loss now, I don't know what else I can try anymore. Perhaps the problem is solveable by tweaking the nif or something but I don't know squat about the format or its intimacies so I'd rather not screw around and waste time not knowing what I'm doing.
Perhaps the problem is unsolveable and my model's lost or has to be rebuilt from scratch :cry:, I really haven't got the faintest.

Nevertheless I hope there's someone :bowdown: out there who can give me some answers or direct me to someone / some thread with the right stuff. It might be handy to have this thread around because I'm sure there's other modders out there with newer max versions who face the same problems.

So, help would be greatly appreciated! Thx in advance :help:.
 
not using max, but it seems you export the model has a shader skin partition (18 Bones per Partition, max 4 bones per vertices), i´m not sure if the niftools export script also sets the than needed shader name. Crashes and distorted meshes can be a result from a missing shader with shader skin partition (as quick test you could remove the skin partition in the exported nif - a nifswap [simply copy your entire mesh from the exported nif to the nif of the unit which animation you want to use and bone structure you have - no idea how exact the script mimics the civ4 nif structure] couldn´t harm)

No more ideas without seeing the unit (considering if the model is fixable)
 
Hmmm... I believe it was a bad idea to make a completely new skin modifier. That drove me into trouble with earlier versions as well. You should edit it only IMO. At least as long as you haven't got a single unit to work. You may come back to that issue later, but for now I suggest you keep the count of 'error sources' minimal.

Besides of this, newer versions of 3dsmax seem to be tricky for civ4 modding in-deed. There as another thread similar to this one recently. I'm not aware of that the guy got his problem solved.
 
not using max, but it seems you export the model has a shader skin partition (18 Bones per Partition, max 4 bones per vertices), i´m not sure if the niftools export script also sets the than needed shader name. Crashes and distorted meshes can be a result from a missing shader with shader skin partition (as quick test you could remove the skin partition in the exported nif - a nifswap [simply copy your entire mesh from the exported nif to the nif of the unit which animation you want to use and bone structure you have - no idea how exact the script mimics the civ4 nif structure] couldn´t harm)

No more ideas without seeing the unit (considering if the model is fixable)
Thx for the replies. I tried what you suggested and removed the skininstance, then did a nifswap. Now the soldier mesh shows but is unskinned naturally, it stays rigid. See photo - i know they're red but that's because i haven't fixed the material properties in this quick test (once again the mateial settings for the niftools work differently then for the civ exporter).



It's obvious now that niftools doesn't export the skin correctly. IMO this blows. Not being able to use self-built meshes is a serious drawback. Perhaps I'd better wait for civ 5 to come out and hope Firaxis will have an updated exporter for later max versions... so i can get modding...
 
Hmmm... I believe it was a bad idea to make a completely new skin modifier. That drove me into trouble with earlier versions as well. You should edit it only IMO. At least as long as you haven't got a single unit to work. You may come back to that issue later, but for now I suggest you keep the count of 'error sources' minimal.

Besides of this, newer versions of 3dsmax seem to be tricky for civ4 modding in-deed. There as another thread similar to this one recently. I'm not aware of that the guy got his problem solved.
Perhaps you're referring to this post by coffee_junkie: http://forums.civfanatics.com/showthread.php?t=360320.
I already tried playing with the export settings. Disabling export skin modifier won't do any good since it is needed to export your skinning data. Without it you can't rebuild skin partirions in nifskope. But without it, as it is in my case, you can see the model in game... :cringe:
Getting custom skins to work seems like big issue here. The more I dig into it the more it seems like this isn't going to work without the firaxis exporter.
 
ok that at least seems the model is fixable - i didn´t said remove the skininstance, try to remove only the skinpartition (child node of the skininstance)

[it´s only the first test - the skinInstance ahs the rigging and the shader Partition information of the mesh, it will work without the last - but will perform a bit worser - but if this is the error a shader can be add later again]

Also the model seems skinned (i clearly see details) - only has a dominating red color over the base texture [you could try to deactivate - if it is activated - vertex color in the nif]

again, if you upload the model i can try a lot more than only guessing ...
 
ok that at least seems the model is fixable - i didn´t said remove the skininstance, try to remove only the skinpartition (child node of the skininstance)

[it´s only the first test - the skinInstance ahs the rigging and the shader Partition information of the mesh, it will work without the last - but will perform a bit worser - but if this is the error a shader can be add later again]

Also the model seems skinned (i clearly see details) - only has a dominating red color over the base texture [you could try to deactivate - if it is activated - vertex color in the nif]

again, if you upload the model i can try a lot more than only guessing ...
Oh thanks,

I'm relatively new to this forum so where should I upload the model?
and, - is it the max file you're talking about or the nif?
 
i´m not sure if you already allowd to attach files with your postcount [if you go to answer below you have a manage attachments button] - if not try a free upload portal. (if here you can only attach zips). I can only use the the nif (please the directly exported one with skinInstance)
 
The thread you linked, is the one I was thinking about. You can upload your files as an attachment. When writing a post, scroll down. Unde the icons, there is a section called additional options. Click on manage attachments. There you can upload up to 3 files (in you case, you may compress it to zip or 7z, so you'll have only one upload). Alternatively, you can use an external server and provide a link. I use mediafire for instance, but it certainly has flaws. In your case, an attachment will do it. Note, that you can't upload any type of file - another reason why to provide a compressed archive.
 
i´m not sure if you already allowd to attach files with your postcount [if you go to answer below you have a manage attachments button] - if not try a free upload portal. (if here you can only attach zips). I can only use the the nif (please the directly exported one with skinInstance)
I'm not yet allowed to attach with posts, so i'll use a ziddu-link:
http://www.ziddu.com/downloadlink/9756127/ger_infantry.zip contains nif and texture.
here are the export settings i used:
http://www.ziddu.com/downloadlink/9756130/1expsetts.jpg

Thanks a lot for yur interest, I hope u can help me out! :thumbsup:
 
seems good - you can try at first the attached file - i will edit this post a bit later with the information for you how to fix your exported files

(it´s nothing serious - but will take some time to write)
 

Attachments

  • motivation_fix.zip
    34.1 KB · Views: 84


This is really tremendous stuff Coyote! The skinning behaviour is not a 100% as I designed it in Max (vert weights on chin are a little lower than designed) but these are mere trifles compared to this EXCELLENT progress! Love to know how you fixed it, might even write a tutorial for posterity!

:hatsoff: :worship: :salute:
 
more or less the mesh you uploaded had two problems to solve:

  • the mesh had a shader SkinPartition
    Considering Civ4 units there are two different skin Partitions, one with max 18 bones per partition for shader models and one with max 4 bones for non shader models. Because i 'think' the used algorithm is similar, the non shader partition algorithm is a bit broken and not usable. Therefore to have a non shader mesh you have to remove the SkinPartition (not the entire SkinInstance), if you wan´t ot use the 'non shader' shader (needed to display damage stats etc) you can use NiTriStrips instead of NiTriShape (in Nifskope (there is a nifskope tutorial from me in the tutorial section if you aren´t familiar with this tool) - RMB on the mesh, mesh and triangulate or stripify allows you to change the type). In this case i only removed the skinpartition to test if the model itself is ok
    More general you have two options, remove the skinpartition and have only non shader meshes or add the shader to the model (than with 18 bones skin partiton), for this, if you scroll down in the block details of your mesh in nifskope you will see an field 'has shader'. Change the value to 'yes', add the name of the wanted shader below and set the unknown value below to '-1'. If you look in the tutorial section there is a tutorial from Refar about the possible shaders and the needed textures (for sceneviewer, but if you know waht to do, it´s also doiable in nifskope). In general you can also look to a similar unit in civ4, shader untis have the suffix '_fx'​
  • the red mesh
    This was only a slightly wrong texture assigment. If you check the textures (NiTexturingProperty of the mesh) of your version you will see that the unit has two texture assigned. The model itself only needs the base texture slot (what´s is needed can depend of the effect you want, also most shaders need more texturers). Your base texture was 'Torp_Fire.dds' which caused the red shining. Your diff texture was assigned to the detail texture slot (the path in front of the texture in nifskope only causes trouble there, civ4 only uses the name, but i prefer nobody knows my 'internal structure'). I simply removed the base texture and set your detail texture as base texture. Afterwards i 'removed' the detail textures slot.​

Nothing more was needed. But two addtitional hints
  • set the name of your mesh to exact the name of the original unit, also copy properties - like alpha property, material property (or if you create a mechanical unit and want also damage stats the texture property and only change the texture names) - in the animation the model fading eg is controlled via the name of the model and added modifiers to this property (you will see what i mean, if you look at some vanilla units)
  • if you remove mesh parts or meshes inside check if this part was not needed in some animation. Eg in the fidget animation the infantry units looks at a map / paper. If you don´t have the this mehs inside oyur nif, the sequence will look a bit strange. Also there are some other placehodler nodes, eg for effects, attachables, in the nif. Therefore the hint with nifswapping the model.
  • the heads from civ4 units i saw so far had a 100% rigging to the head bone, even if the effect of your rigging was quite funny to look in nifskope while attacking (it looked like a 'ultra cool chewing gum chewing chin disease' guy ;) )

like said, nothing really serious
 
"it looked like a 'ultra cool chewing gum chewing chin disease' guy" :lmao:

I tested your procedure, tried it myself and something funny occurred:
* Apparently, if I leave my freshly exported nif as it is and simply remove the skin partition bit as you said, the model works in Civ. :banana:
* However... if I start nifswapping my unpartitioned mesh to the base infantry.nif and copying material and texture stats etc. ... the model makes civ crash again like before :eek2:. So I checked your motivation_fix.nif and I noticed all branches are perfectly in order (when I nifswap the mesh it gets added at the bottom of the stack within the hierarchy node).

There is something about the nifswap that I'm still doing wrong, u have any idea what that might be (I'v added my swappy nif via the link below)?

http://www.ziddu.com/download/9757420/Nifswapped.zip.html

* Do you know how I can solve the chinny chinchin problem with my dood? Maybe I should reskin with manual weights in Max or is there more Nifmagic involved?

But all that being said, fantastic progress

:thanx:

Thanks a million for your help, :jesus:! I'm going to read those nif tutorials as soon as I can spare the time. Don't feel rushed by my questinspamming, take it easy, I'm a patient guy (sorta ;)). Good :sleep:
 
i would change the weights in max (to be honest, i´m not aware a method you can change the rigging outside 3D progs for Civ4 models)

the crash is the result of an unfriendly behaviour of Civ4. While in most cases it doesn´t matter if an array has empty slots, considering the properties of meshes it causes crashes (your soldier, gear and the weapon had two open - but empty - property array slots)

i attached a shader version of your nif, so that you have master (you see the model again has a skinpartition [can be created in Nifskope, but the one from the export script should work also], has a shader name, and for the TCiv4Skinning shader you must have the diff texture in the base slot [transparency would control teamcolor])

btw in the current setup with the gear as indepent model which doesn´t fade the model has imo a really interesting death sequence

Edit: Considering the texture setup of non shader meshes a small addition: if a unit has teamcolor the base texture is teamcolor.bmp while the diff textures is in the decal slot (the second is applied over the first, therefore parts with transparency are displayed in teamcolor). If you don´t want or have teamcolor you can simply put your diff texture in the base slot and remove the decal slot
 

Attachments

  • nifswapped2.zip
    42.6 KB · Views: 92
While in most cases it doesn´t matter if an array has empty slots, considering the properties of meshes it causes crashes (your soldier, gear and the weapon had two open - but empty - property array slots))

Ah, you're talking about this I suppose:



1) How did you remove these empty array slots (I can't seem to do that with nifskope)?

i attached a shader version of your nif, so that you have master (you see the model again has a skinpartition [can be created in Nifskope, but the one from the export script should work also], has a shader name, and for the TCiv4Skinning shader you must have the diff texture in the base slot [transparency would control teamcolor])
:goodjob:

2) With which settings did you make the partition (# bones per vert / # bones per partition)?

3) So you made the shader as explained before, by simply changing the bool "has shader" to yes, giving it a name and changing the un kn. int to -1 - and that's all there is to it?

btw in the current setup with the gear as indepent model which doesn´t fade the model has imo a really interesting death sequence
I can live with it...:lol: or I could integrate the gear with the soldier mesh, will make skinning a little tougher unfortunately.

BTW I noticed the normal behaviour of your revised model is a lot better than the original, is that because of the added shader? Or did you change something else (like face normals etc. I tried it but it doesn't improve the mesh visually).

I'll just recapitulate what I think that has to be done when exporting a model from max, considering all the info:
- Export with all options (skin info, partition etc.).
- Nifswap the meshes within vanilla nif.
- Copy material and texturing properties from vanilla mesh to custom mesh.
- Check mesh properties array for empty slots and remove them (how?).
- Rebuild skin partition with nifskope?
- Add shader with manual nif editing of Nitrishape properties.

Let me know what u think :cheers:
 
enter the number of the properties in the open slots in front of them, so that the open properties are the last two one, afterwards reduce the number of properties (the value over the property array) to 3 and update the array (click on the green circle double arrow)

shader skin Partitions 18 / 4 (like in the export setting from max). And yes adding the shader name (and if needed change the textures) is all you have to. Also in most cases the unit costs less performance and looks a bit better ingame

i think your step to step is good, beside
i think the max skin partition should work (i only explained the non shader version first, because if this method work, all is possible, also to have both version is good, if you want to publish the model there are still person with grafic cards wihtout shader support here), if not rmb on the mesh - mesh - make skin partition

:)
 
OMG this is so awesome... The step to step guide totally works :clap: but for shading a little more detailed work was necessary.
Muchos kudos@El_Coyote!

So here's the start of a step by step guide and the absolute awesomeness that ensued:

1) Open the exported custom nif in nifskope.
2) Nifswap all the custom meshes you made in the correct position in the node hierarchy. There's actually no need to rename them to the nitrishape name of the vanilla mesh you're replacing. I've tested it, the name of the nitrishapes themselves are irrelevant (but all bones must have the vanilla names of course).
3) Nifswap the nimaterialproperty branches and the nitextureproperty branches from the vanilla meshes to the custom meshes. Replace the texture link if needed.
4) Check your custom nitrishapes block for empty property array slots (fold-out "properties" slot). Mostly, they contain 3 properties: alpha, texture and material. Insert the numbers for these properties in the first slots (put them in order) so the last ones are the empty ones (this is absolutely necessary). Reduce the number of properties in the Num Properties slot above the properties to how many props there are (mostly 3). Press the green arrows next to Properties and voila, no empty properties. This should keep Civ from crashing when using the new model.
5) Remove the skin partition. At this stage, the model works and the skinned meshes are visible in Civ. I think one can make a skin partition with 4 bones per vertex and 4 and 4 bones per partition. I tried this however and my mesh was screwed in Civ. Don't know why, maybe I'll figure it out. Maybe it's safer (and easier) to make a non-shader unit without any skin partitions.
6) You can build a shader version by rebuilding the skin partition in Nifskope using 4 bones per vertex and 18 bones per partition. then, change the "Has Shader" bool of the shadeable nitrishape slot, insert a shader name on the "Shader Name" slot below (like "TCiv4Skinning") and finally change the "Unknown Integer" below to -1.
I tested the model after this phase. It shows but without texture. So I checked the nitexturinproperty branch and found that in that branch the slot "Had Base Texture" didn't have a source (the block number of my nisourcetexture). Instead, the "Has Decal0 Texture" slot referred to the texture (I think decal0 - 3 are damage textures). The shader needs the base texture so I adjusted it. Now, the model works fine. :woohoo:

At least for me, this is an extremely useful thread so i'd like to keep it open for future questions with max 2009 exporting and modmodeling in general. Perhaps custom animations in the near future (I know that with niftools you have to work with keynotes and that it's extrmely tricky... typical me taking the easiest paths :p).
Maybe it's a good idea to make the thread a sticky? Also, perhaps it should be renamed to "modeling with later 3D studio max versions" or "modeling witn NifTools" or something because the "keeps failing" component in the title has now become obsolete :w00t:.

Does anyone know how I can do that? Do I have to contact an admin?

----
PS hav I told any1 this thred roxx?
 
some additions
2) not really, i know kfs who refer to the meshes by name, eg the fading of the mesh while dying is one of them [it´s not necessary for the movement of the bones, but if the uv is changed, like for damage stats or tracks of tanks, of the change of the alpha value the mesh is refered by name]

5) unfortunally it´s correct we can´t create non shader mesh partitions (4 bones per vertices), therefore non shader can have one. (it´s also not possible to create shader skin partitions for leaderheads), but if you stripify your mesh (will cause a rise of the polycount, but shall perform i think something like 20 - 30 % was acceptable, but in other cases it will be the only way) you can also use the non shader shader (sounds a bit strange, but if you look at some mechanical units you will se this shader and recognize quite easy). There seems to be a bug in the algorithm, but because after we discovered this bug prefered to make shader models we didn´t begged for a fix so far

6) to create shader meshes it could be better to copy the texture properties of the shader version of the vanilla mesh (or even use the vanilla mesh as base). If the model has gloss (eg knights) there will some other differences (the enviromental texture is added a different way, as effect to the master node of the mesh in the non shader case, as glow texture in the shader case).
The reason with the diff texture in the decal 0 slot i have posted in the edit of post 15 (has something to do how teamcolor works in the non shader case [teamcolor.bmp as base texture, diff texture in the decal 0 slot] and the shader case [diff texture in the base slot], in both cases the transparency of the diff textures controls where you will see the teamcolor)

i can at least say animation are possible with blender (there exists also a tutorial about this), so i think it could be possible with max, it´s the same team behind both scripts. But you must do again some steps afterwards with the exported kfs

and before you ask, vanilla models have sometimes some strange nif with the suffix "_freeze". They are used for person who play with frozen animations and are refered by name of the kf (so because your model uses the infantry.kfm and somebody plays with with frozen animation the model will switch from your model to the basic infantry model). To avoid this you would need to make a complete copy of the animation and also create the freeze nifs (basicly the mesh deformed to stand (buth without rigging and armature) in the starting pose of the animation). But tbh most model creaters - including me - don´t create this nifs.

if you want this thread open you could ask a moderator (simply pm one) to move this thread to the tutorials section (thread name - a title like special steps max2009 for civ4 modelling). if you go the the main Civ4 - Creation & Customization you will in top of the threads the mods of this forum (but it seems that woodelf is offline a bit longer - haven´t seen him here for a while)
 
Thanks for the feedback again. I can't PM anyone yet since my account's too fresh. I met one of the junior mods on the forums and she suggested I use the exlamation triangle to contact the admins for changing the thread, so I did that. We'll see what happens...
 
Top Bottom