sometime last year I started playing around with the 3ds Max tools code to accelerate my workflows. This somehow escalated into much more than just little tinkering and might now be useful to other modders out there as well. You can download the full install here: 3dsMaxBF2Tools046a.zip (for latest version check here)
Thanks to Worldlife, Mats, Remdul who wrote some of the scripts used in these additions. And of course to the devs and modders testing, reporting bugs and giving feedback!
To install, extract the contents of this folder into your "\Autodesk\3ds Max 9\" folder, overwriting anything you have there already in that folder and restart max.
If you want to use the tools is a different max version, you can just extract the contents into the appropriate folder as well. However I recommend (and prefer for myself as well) to instead create symbolic links for /plugins/bf2_mat_staticmesh2.ms and the entire /scripts/bf2/ folder (will add how to do this here later). This way settings will be carried over between max versions, and you don't need to worry about updating both independently.
Some of the changes require tutorials of their own (being worked on, will post them as soon as they're ready), but for now I can give a brief summary of the changes and additions:
- Support for other Max version newer than Max 9 (Tested so far with max15 and max16, anything in between 9 and 16 and probably also newer ones should also work)
- New Importer (for all other versions, selectable for Max 9)
Correct material import: Setup BundledMesh/StaticMesh Materials
- Only relative texture paths (-> Setup places mods folder in User External Paths)
- Alpha displayed after import (also for LMing)
- OG Import: Twosided and transparency for all materials with only base texture (also for LMing)
- Downside, however is that the new exporter (entirely in maxscript) is somewhat slower than the original importer (written in max SDK). However maxscript is compatible between almost all max versions, and is easily changed, while max SDK is compiled and therefore inaccessible.
- Alpha Selection in BF2 Materials
Alpha Transparency Modes (No Alpha, Alpha Blend and Alpha Test) can now be selected for each BF2 Material (BundledMesh and StaticMesh Materials).
The Material name is automatically appended with the correct prefix, and the transparency is displayed in the viewport.
- Changes to the Exporter:
Checkbox to not create a new directory during exports of bundledmeshes, staticmeshes (i.e. export directly into the current directory, as is default e.g. with animations)
Remove Root Bone Checkbox now stays saved for each scene. (Important during 3P animation export)
Lightmap Sample Generation: By default, Lightmap samples are now generated à la BfMeshView (by a small console app that contains BfMeshView's Sample generation code). Which Generator is used (BfMeshView or Original) can be selected in the Setup Menu.
With BfMeshView it's possible to generate custom sample sizes (e.g. 128*64) straight from the max scene, as well generate custom-defined different sizes for each LOD using the "User" option. In this case each LOD node has to be suffixed with the desired size (e.g. lod0_256 or lod2_64*32).
- Animating (FH2 Animation Tools in Utilities):
Easier Handheld Animation Import:
Pick Animation, (for 3P only: also lower body animation if required) and weapon mesh
-> Imports everything into one scene correctly aligned and animated
-> Also option to automatically set up IK chains and controllers (FH2-Style)
Short Tutorial for 1P/3P Animation Import and Setup:
This Tool is an extension of the existing Animation Import. In addition to importing the .baf it loads it straight into a hand/body scene, and additionally imports the requested handheld weapon mesh and aligns it to the .baf
The following steps make up the import process:
Click on the uppermost "Get" and navigate to the animation you want to import. (Both 1P and 3P are possible)
In this example I'll be importing a crouch movement animation for the Lee-Enfield No4.
- (Only applicable for 3P Animations)
Since most 3P animations are split into upper body (specific for each weapon) and lower body animation (shared among all weapons), it may be helpful to also import the corresponding lower body animation.
If a 3P animation was selected in the first step, the tool tries to find the corresponding lower body animation. If you want a different one, or it didn't find the correct one, you can still change it by clicking on the 2nd "Get".
In the example, it correctly picked the lower body baf, so I won't touch it.
After having selected an animation in step 1, the tool will look for what it thinks is the corresponding the weapon mesh.
If you want a different one, or it didn't find the correct one, you can still change it by clicking on the 3rd "Get".
In the example, I'll want to confirm if the No4 animations work fine for the No1 SMLE (since they share the same animations), so I'll change the automatically found No4 to the SMLE.
Click on import and a scene with all items will load. The scene is currently a bare-bones (no pun intended) animation setup, with none of the tools and controllers that are actually used during animating.
Before we can actually with an animation, we need those setup. This is usually the first step in creating any animation.
Luckily the tool can also take care of that for us. After importing, there will be a Message, asking whether we want to Setup Animation controllers.
This leads to the next step:
After clicking yes, we can setup animation hierarchies in the way we prefer. This is usually up to the animator's choice.
In the example, I'll want all weapon meshes, as well as the hand controllers (which the tool created after clicking on "Yes") to be parented under the main weapon mesh.
The hierarchies here can also be time-dependent, i.e. controlled through Link Constraints (Link Params Section in the Hierarchy Tab), e.g. for Reload Animations.
Note that until the hierarchies setup is complete, the hands movement might differ from the final animation.
Once the hierarchies are all setup, after clicking on "Continue" in the FH2 Animation Tools Dialog, we'll end up with the correct animation, as well as hand controllers (IK chains parented under hexagons, FH2-style).
There is of course still the issue that exported animations have keys on every frame. Unfortunately there's no magic solution to get the original keys back.
So you'll still have to reduce those manually (e.g. in trackview) to be able to change complex movements.
Alternatively you can try to use Soft Selection in the track view, or to superimpose new movements using dummies in the hiearchy.
Automation System for 3P animating: Derive Animation Systems from templates (e.g. one template for all handheld weapons) Basic Idea: General movements stay the same for almost all anims. Anims differ only in relative weapon position (to body), and hands and fingers on the weapon. -> Pick Template, define Still Weapon position, hand and finger positions. Tools then transfer those to an existing 3P Animation set exports and saves everything. Reload and zoom might (most probably) need manual correction, but over 90% of animations already done! (Tutorial also underway)
Plus some one-click buttons for common (in my workflow at least) operations during animating.
Lightmapping: Disclaimer: I don't have a mapping background and mostly stick to coding/modelling, so if somebody wants to weigh in on this process with requests or recommendations, they're more than welcome!
Following Rhino's excellent tutorial, the lightmap process is now a bit more streamlined. An updated tutorial, taking into account the new changes is in work, but for now the major changes:
Converting your Overgrowth to Static This step is no longer necessary, use the Load Overgrowth Button, then find Overgrowth/OvergrowthCollision.con to import OG straightaway.
3DsMax LMing Scene Setup The recommended unit setup is now set automatically when opening the LM dialog.
Importing Your Terrain into 3DsMax If a minimap exists, it is now automatically applied to the terrain. Note that a 2nd terrain is loaded and hidden in which the sealevel is applied automatically (which is needed later on).
Importing Your Statics into 3DsMax Static children are now loaded as well. Also, when using the alternate importer alpha textures are applied correctly automatically. There's also a bunch of new settings in _Settings/StaticObjects_Import.con which can be used to further the streamline the process (E.g. automatically create point light sources for specific object templates) DestroyableObjects are now loaded and lightmapped automatically as well.
Cleaning Up Your Objects OG and other objects that only cast but dont receive shadows are automatically stripped of their hierachies. BundledMeshes should now import correctly as well (and remain only with their lod0)
Creating Reference, Shadow Casting Objects and Replacing Objects with Reference Objects This should all be managed automatically with alternate import, so no need to manually apply alpha and instantiate objects anymore. OG leafs are imported with a two-sided material, meaning that cloning, detaching and inverting the faces is no longer necessary.
- Sorting out your Statics for Lightmapping
Upon Importing of StaticObjects, Lightmap sizes are now automatically assigned (if samples for each object are present).
Objects which have "GeometryTemplate.doNotGenerateLightmaps 1" set in their tweak file will automatically be prevented from lightmapping.
DestroyableObjects now also have their Geom1 displayed in the Lightmap size file. Geoms are separated by a "|".
Note that the tweak files are only read for those objects that are being imported. If the "Build Sizes File From:" button is used (which collects ALL sample files in the entire mod directory), .tweak files are not read and "GeometryTemplate.doNotGenerateLightmaps 1" is not handled.
Importing your Sun & Preparing your Lights
Sunlight, Skylight and Ambient Fill Lights are now loaded all at once, all with their colors already setup for simultaneous lightmap rendering.
Sunlight is fit according to the mapsize. Intensity parameters are estimated, however this should still be checked and determined by the user in most cases.
Note that a WaterLight (needed later) is also created and hidden.
Terrain Sun & Sky Lightmaps and Terrain Sea Water Depth/Transparency Lightmap
The "Render Terrain" Button now automatically creates a complete lightmap in the specified /terrain/ folder.
The generated .tga lightmap can then be split and converted into the terrain patches required for bf2 by using the "Split Terrain File" Button.
If uniform patches (i.e. no discernible differences over the entire image, e.g. for maps with lots of ocean floor) are found, they are automatically reduced to 8x8 textures.
- Overgrowth Lod Creator:
A small and lightweight tool to automatically create flat plane lods for overgrowth meshes.
UV layout is automatic as well though, which is often not very efficient.
Small tutorial for Overgrowth Lod creator:
This tool was created to quickly improve performance of overgrowth (OG) objects. Each OG object has a separate _lod model which is displayed from away. Since performance on OG-heavy maps can quickly go down the drain when these far away lods are too detailled, it's often the best to use a minimum amount of tris. Since vegetation is always rendered two-sided in the engine, we can easily reduce the lod to 2-3 flat planes onto which the tree geometry is projected, amounting to 4-6 tris. To do so, one would ordinarily create the planes manually, make them fit the tree, uv them, make the background color fit the color of the leaves (for better transparency) and finally bake do a projection bake.
Luckily, the tool can do all of this for us automatically.
For this example I'm going to look at jungle_tree_01 in \Vegitation\jungle-pr\jungle_trees_01 There's already a LOD for it, however it's coming in at 383 tris, so let's see whether we can reduce that.
- Startup Settings
First, we start the tool by clicking on "Overgrowth LOD Creator" in the utilities window.
A new dialog will appear on which we can pick some settings.
To quickly sum up the settings:
The texture size can be set to any Power of 2 combination, so e.g. 256 or 512*128.
If "Use Midplane" is checked, there will also be a horizontal plane so that the LOD is also well-visible from higher angles.
If "Auto Background Color" is checked, the tool will try to automatically select a background color that averages the leaf texture. If unchecked, the color can be chosen manually. Just keep in Mind that Max does its own gamma correction, so you'll have to correct values if you want to plugin RGB values from another source.
Finally, we can choose whether the non-leaf parts of the tree should be rendered with their base or detail channel displayed.
- Model and Texture Locations
Once we press on "Start", the tool will ask for the actual Overgrowth Model, so I'll navigate to and choose \Vegitation\jungle-pr\jungle_trees_01\jungle_tree_01.con
After some short renders, it will ask where to save the new lod texture, which in this example I'm going to save in \Vegitation\jungle-pr\textures\ .
- Texture Sizes
Now let's have a look at the texture first.
With the 256 size preset, there's a lot of unused UV space in the top right corner, so let's see whether we can improve that just by using a different size.
So I'm just going to go back and start the process again, but this time with Texture size set to 512*256.
Well, a bit better, so I'll accept that for now. If you want to manually do your UVs (and e.g. combine them with similar trees), after the tool is done, check the *_lod_bake.max file in the object folder.
You can re-bake the uvs here. In case you want the uncompressed images that were rendered before, check your 3dsmax image folder (usually Documents/3dsMax/sceneassets/images).
- Geometry Correction
Now the created geometry still looks a bit off:
We'll have to manually adjust the planes so that they match with the texture, i.e. move the planes such that they intersect in the tree trunk.
If you have a tree that's very curved (in this example the trunk is straight so thats no problem) you might have to add one or more edges to make the plane follow the curvature.
I'll do this for both the vertical planes, and then afterwards move the horiontal plane upwards into the leaf area.
Finally we have to export, but the tool has already prepared all the recommended settings for us anyway, so I can just click export.
And the final LOD looks like this:
At the distances we're talking about, it should look just fine. And we've reduced the amount of polys to 1.6% of the previous LOD, with similar texture load!
And it's a lot quicker than doing this by hand. Stubbfan (partner in crime in FH2 and CMP) smashed through a couple dozen overgrowth models in one short sitting.