• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days (this includes any time you see the message "account suspended"). For more updates please see here.

[Tutorial] Exporting models from 3DS MAX into Civ IV

  • Thread starter Thread starter Rabbit, White
  • Start date Start date
R

Rabbit, White

Guest
With the release of Civ4 Plugins for 3dsmax 6 and 7 we can start making new models for [civ4]. Unfortunately, all we got are the plugins and a nif viewer, with no tutorials, documentation or any instructions at all. Some people have been able to figure things out, some have not. In this tutorial I will attempt to provide some guidelines for properly exporting models from 3ds max and using them in game.

Please keep in mind, that like everyone else I am just starting to explore the possibilities, and doing it pretty much blindfolded, so there might be some errors or omissions, and this is definitely not the "Complete Guide to Creating New Models for Civilization IV" ;). If you know of a better way to do something, or have a solution to a problem I did not address, I encourage you to post your findings here.

UPDATE: Well the documentation for properly exporting models have been released. I recommend reading it first since it has a lot of useful information and especially directions for how to properly set up a model for export. Having said that, I don't think it makes this tutorial obsolete, it all depends on what exactly you want to do.

On to the tutorial...

What you will need

You will need to have 3D Studio MAX 6 or 7, there is a 30-day demo available.

You will need the Civ4 plugins, for 3ds max 6, or 3ds max 7. To install the plugin, simply unzip the contents of the file into the 3ds max installation folder.

You will need the NIF viewer. It comes with the plugin, it's the SceneViewer.exe file, also note the BoundShape.nif and BoundShape.tga files that come in the zip as well - you will, you guessed it, need them :).

In order to use the NIF viewer you might need the mfc71.dll file, you can get it here, instructions on how to install it are in the zip.

Finally, you will need some luck ;)

Preparing the model for export

I will use my P-51 model throughout this tutorial, and will occasionally reference the F-15 model, both are found in my sig.

I'm also assuming basic knowledge of 3ds max.

While Civ 4 can display very high-poly models it is recommended you stick to models with about 800-1000 triangles for multi-model units (e.g. most land units), and no more than 2000 triangles for single-model units (e.g. air/naval units). In general though, consider the scale of the units and don't use more detail than needed. For example the F-15 model I used is 1045 polygons, while the P-51 model is ~1400 polygons, and I don't see a reason to add any more detail, in fact I could cut another 200-250 polygons from the P-51 and most people will not notice it.

When creating models for Civ4, it's best to use the specific material made for it, called CivilizationIV XPLatform Material. Although I was able to export models just fine by using the default material, if there's one specifically designed for it, why not use it.
tutpic018cu.jpg


Said material allows you to choose between Next-gen XBox material (we don't need that), and PC/Generic material, and that's what we'll use. You can simply edit that material directly, but to keep things nicely organized I pointed to a material I already made, called p51_texture. The material is fairly simple and the screenshot is self-explanatory.


Note the glossmap part. By adjusting the Specular Level and Glossiness values I was able to give the plane a shiny look but I don't think that glossmap had any effect on the position and strength of the effect. Either I'm not using the right material property, or I'm missing something more.

Exporting

The export dialog is fairly simple.
tutpic030aj.jpg


Convert - uncheck Cameras and Lights, we don't need those.
Textures - select Original Images, that way the nif file simply uses a reference to the texture, and you can modify the image without touching the model, just like regular skinning.
Process Script - I find that the default script always works, the Stripped/NotStripped options refer to, I believe, the way model is handled by the engine (strip of triangles or a list). Once again, as long as the default one works there's no need to touch these.
File Export Script - you should use the default script if you're not exporting any animations. Personally I was unable to create animations that the exporter recognized and always ended up getting an error when trying to export them.
Leave rest of the options on default.

The only errors I got when exporting were when I tried to export animations. If you're exporting a static model using default script and having errors, I'm sorry but I can't help you with that.

Using the model in Civ 4

If everything went well then you should be able to use the nif file you just created in the game. The only thing of note here is that in the CIV4ArtDefines_Unit.xml file you will need to modify two entries, NIF and SHADERNIF, like so:
Code:
<UnitArtInfo>
	<Type>ART_DEF_UNIT_P51</Type>
	<fScale>0.5</fScale>
	<fInterfaceScale>1.0</fInterfaceScale>
	<NIF>Art/Units/p51mustang/p51mustang.nif</NIF>
	<KFM>Art/Units/Fighter/Fighter.kfm</KFM>
	<SHADERNIF>Art/Units/p51mustang/p51mustang.nif</SHADERNIF>
	<ShadowDef>
		<ShadowNIF>Art/Units/01_UnitShadows/FighterShadow.nif</ShadowNIF>
		<ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
		<fShadowScale>0.75</fShadowScale>
	</ShadowDef>
	<iDamageStates>4</iDamageStates>
	<fBattleDistance>0.35</fBattleDistance>
	<fRangedDeathTime>0.31</fRangedDeathTime>
	<bSmoothMove>1</bSmoothMove>
	<bActAsRanged>0</bActAsRanged>
	<TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
	<AudioRunSounds>
		<AudioRunTypeLoop/>
		<AudioRunTypeEnd/>
	</AudioRunSounds>
	<PatrolSound>AS3D_UN_FIGHTER_PATROL</PatrolSound>
	<SelectionSound>AS3D_UN_FIGHTER_COMMAND_PATROL</SelectionSound>
	<ActionSound>AS3D_UN_FIGHTER_COMMAND_PATROL</ActionSound>
</UnitArtInfo>
It appears that some people were able to get away with modifying only the NIF entry, but that hasn't been my case.

Using the model this way will give you static unit in Civ 4 with non-complete sounds, and no team colors (I couldn't figure out how to fix this). However, it will (well, should) work fine in every other way.

If you wish to add limited sounds, effects and animations to the model keep reading, but a friendly warning: from here on it gets more technical, complicated and in general less pleasant. :)
 
Adding sounds, effects and animations to the new unit

In order to add sounds, effects and animations to your new units you will need to "hack" or merge them together with an existing model. It's like skinning, but instead of making a copy of a unit's xml definition and replacing the texturing entry with your own texture, you'll be making a copy of an existing NIF file and replacing its model/mesh with your own. This method is obviously limited in the same way skinning is. To do this we'll need to know a bit more about NIF files.

(Almost) Everything you wanted to know about NIF files but were afraid to ask
(hey, if I didn't use it for the title of the thread, you knew I was going to use it somewhere down the line)

There is a lot of information contained in the NIF files beyond the structure of the mesh and reference to textures. I will only mention the parts, we're interested in.

NOTE: In order to open any of the unit files in NIF viewer you will need to put the BoundShape.nif and BoundShape.tga files in the same folder as the unit you're opening.

Open the fighter model (art/units/fighter/fighter.nif) in your NIF viewer. Make sure you have the Scene Graph Tree open (View -> Scene Graph) and expand all the branches below the NiNode "fighter.nif" entry.


Note the SOUND and EFFECTS nodes - in my semi-educated guess, these are required to properly play the sounds and the effects associated with the model. For example, when I first exported the F-15 model and put in the game (without modifying it), it would play a sound on selection, but when executing its missions, there were no sounds or any effects.

Also, note the Figter_Body and the FighterDeathModel nodes, they both contain the same (at least on first look) models of the fighter. Many mechanical units contain two similar nodes, i.e. "regular body" and "damaged/death body", I think the damaged/death node contains the model that uses the "damage" texture that some of these mechanical units have, but I haven't explored this any further.

Also note the BONE_Fighter_Propeller and FighterDeath_Propeller nodes. If you place a different mesh inside these, that mesh will be rotating in game. In this case, it appears that the propeller doesn't uses the regular animations (like in KF files) but rather a simple series of transformations that cause it to rotate (and that's good news for us :)).

You can tell a lot about a model from this scene graph tree. For example, the Inca Quechua model contains separate nodes for its spear and shield, which means that potentially the meshes used for them can be replaced with your own models. On the other hand the swordsman model only contains a separate node for its sword, but the shield is part of the main model. The jet fighter model, for example, contains separate nodes for its rockets and bombs, and by using those together with my F-15 model I was able to give it working bombs that actually fall when it performs a bombing run (once again, apparently they don't use regular animations for that but rather are just translated during the bombing run animation).

Merging new model with vanilla model

Obviously this step is only appropriate if there exists a model that is similar to yours in function, because while sounds can be further customized through XML files you are stuck with whatever animations and effects the vanilla unit has.

The most important part here is to replace the main model with your own, in my case I needed to replace the existing fighter mesh with that of P-51. To do this first open your model, then use Add File to open the vanilla model with which you want to merge your model.


Find the nodes in which the main model is located and remove these models/meshes (right-click->remove). Every time you remove an element of the tree like that it'll refresh and collapse, it's a bit annoying.
tutpic068xb.jpg


Then find the node in which the mesh of your model is located and move it (drag'n'drop) into one of the nodes where the original model was.
tutpic071kv.jpg


Side note: Obviously if there was only one such node then you just put it in there. In case of two nodes (like with fighter), sometimes it's important which node it is. When I merged F-15 model with Jet Fighter, I was able to put he F-15 mesh into either the jet fighter's "death" node or "regular" node and it worked fine. In case of P-51 and fighter however, it only works when putting it into the "Fighter_Body" node. You'll have to do a bit of experimentation to figure it out for each model.

When you do this you might end up with your model turned the wrong way, this is because its pivot's orientation is different than that of the model you just replaced.


In some cases it is possible to fix that by turning the pivot before exporting the model.


However, it doesn't always work, at least it didn't for me. So what you have to do is adjust the rotation of the model through the NIF viewer. To do that open the properties of the mesh (right-click -> properties), and adjust the Local Rotation, Local Translation and Local Scale entries until you're satisfied.
Update: If you're having trouble with the model's orientation, there is a more detailed discussion on the topic in post #17.


Now onto the propeller. It's basically the same idea - you need to replace the vanilla propeller with your own. (BTW, when I first replaced their propeller with mine, it wasn't properly rotated, but this time adjusting its pivot before exporting worked.) In my case I actually modified my propeller to include their texture (cause it's nice how it looks) and put it in. The result is a rotating propeller, the only catch is that since the original fighter hovers, i.e. goes up and down a bit, its propeller is doing the same. So, if you take a close look at my P-51 model in-game, you will see that the propeller wobbles a bit as it turns.

Don't forget that if you're replacing a separate mesh, like the propeller, you'll also need to export it separately. In my case I also re-exported the P-51 model without a propeller, since I was gonna put it in separately.

In case of F-15 model, I didn't need a propeller of course, but I needed to adjust the scale of the bombs and the rockets to fit the new model, but once done they worked beautifully. :)

Saving the model

I'm not sure how important it is but before saving the model I remove the node that contained the new model, and rename the root node of the vanilla model, fighter.nif in this case, to the new one, p51mustang.nif, and then save it. The save dialog is a bit weird but it does work.

Final words

Using the same technique you could replace weapons in models, e.g. swordsman. You'll just need to create and export the new weapon and then merge it into the unit's NIF file instead of the original weapon.

I hope this tutorial was useful and not too boring. With any luck it will fast become obsolete because Firaxis will release all their tools and documentation and this kind of "hacking" will be unnecessary. :)
 
Great tutorial, but when I installed 3ds max, I couldn't get it to start. It said that AcGe16.dll was not found. Any idea how to fix this?
 
Very good :goodjob: This will defintely save us some time while there're still so many units to do.
 
Great stuff ! Many thanks !
Now i gonna test myself in more complicate moding...
 
@ Rabbit, White: excellent work! Thank you very much for this!

@ Tricorder: thanks for posting that. I was just about to try it :D
 
Does anyone know where I can find a copy of 3ds Max 6, 7, or 8? I don't have 3.5K US to drop on the retail version from Autodesk, so I have been looking everywhere for something else. I checked ebay, but I still can't be sure of what I'm getting, if I even find anything useable in there.


If you can't post it here....Drop me a PM

Thanks
 
@Mr_Tricorder: wow, I didn't even know they already released version 8! It's becoming like sports games now, new version every year :)

@senwiz: there is a 30-day trial of 3ds max (not sure if it's full featured or not).
 
Okay, as this seems to be the best thread to post my question, here it comes:

I have installed 3dsmax 7, unzipped the plugin to the appropriate directory and didn't even have to install the .dll, because all programs work quite well.
I can view .nif-files with the scene viewer.
What i cannot do is load a model into 3dsmax.

What i want to accomplish: just modify the weapon of the jaguar. I thought it would be the best just to modify the original one.
Isn't that possible? And when no: how do I know which size the, let's say sword has to have?

Thanks for any reply.
 
@Notarzt

Unfortunately we can't import existing civ models into 3ds max, we can only export. The only way to modify a weapon would be to replace it, i.e. you would model it yourself and then insert it into the nif instead of the original sword. And as for size, it's trial an error really. Your best bet is to creat an item, put into a nif and see what scale adjustments are needed and then when creating new items use the first one as a scale reference.

I can tell you this though, if you're using the metric system in 3ds max I think the models are pretty much real-life scale, i.e. a human height would be around 180cm.
 
Yes, I have read your tutorial. But while exportign I encounter the "wrong direction" error and don't know how to turn my sword (see screenshot).

mesh.jpg

I tried to edit the shown "local rotation" numbers but the sword wont really rotate but only gets contorted.

And, big problem, I cannot find out how to change/modify the pivot point in 3dsmax 7.

Thanks for your reply.
 
@Notarzt

You'll be encountering the problem of orientation a lot, and unfortunately it's often times take a lot of trial & error to figure out the proper orientation. (I have yet to find a pattern to why some things are oriented as expected and others are out of whack).

To modify the pivot's orientation in 3dsmax go to the hierarchy tab (on the right side menu), select pivot and click the "affect pivot only" button. After that you can rotate and move the pivot just like anything else.

To be honest though, I'm starting to think that in the few times when I thought changing pivot's orientation helped, it was just my imagination (although modifying its position definitely has an effect).

As for your sword's orientation. First thing you want to try is to change it in 3dsmax, simply rotate it 180 degrees around it's x-axis (based on the perspective view in your screenshot). I find that in 90 percent of the cases that does the job (and that way you can also easily make small angle adjustments, which is tricky to do in viewer).

Sometimes however that doesn't work (and again I don't know why) and so you'll have to modify orientation in the viewer. The local rotation in the viewer is represented by a rotation matrix, here's a good place to learn more about that. As you can see, unless you are intimately familiar with matrix math, it gets quite complicated.

This (fixing orientation in viewer) is the least favorite part of the whole thing but the results are quite satisfying. :)
 
That rotation matrices made my day!!! :)

It's extremely easy to get your model in the correct position with that knowledge.

Thanks a lot!

berserk.jpg

Now I hope that it works correctly within CIV.

EDIT: and it does. for a finished model screen, check the "TAM"-thread.
 
Okay, I encounter a problem someone of you could probably help me with.
Every time I skin my models in 3dsmax i cannot export them.
I used 2-3 meshes/polys differently skinned and merged them via "boolean"
the result looks quite good in 3dsmax, but as I said, he won't export it.

I can only export single meshes/polys with a self designed one-colour material.

Would be great if I could skin it "the normal way" via .dds files and photoshop.
The tutorial here suggested that this is possible, but it doesn't work on my models.


Any suggestions?
 
Back
Top Bottom