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

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.

Spoiler for Image of imported Static (directly after import, no manual material changes):

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)

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).

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.

Spoiler for Image of new FH2 Animation Tools Dialog:

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.

Spoiler for 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.

Export

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.

Feedback, questions, bug reports and comments are always welcome!

Last edited by [R-CON]Harmonikater; 02-17-2018 at 04:51 PM..
Reason: New version

I quickly read through it and will for sure test most of this out! The only thing I can think of is when importing statics it skips destructible objects. Likely cause they have an additional geometry. Having these be imported and be possible to be lightmapped as well with all their geoms would be great.

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.

Apparently with the big UI change, the way to insert menus from maxscript that actually stick around also changed. (I could quite literally see Max18 make the BF2 Menu item disappear)

Anyway, I updated the link and it should work out of the box now.
If you don't want to redownload you can also enter the following in the maxscript mini listener (the small white box in the bottom left corner):

bf2Menu_add()

and hit enter

Quote:

Originally Posted by [R-DEV]Mineral

The only thing I can think of is when importing statics it skips destructible objects. Likely cause they have an additional geometry. Having these be imported and be possible to be lightmapped as well with all their geoms would be great.

I'll take a look at the destroyableObjects (not really something that's commonly used in fh2 hence they slipped my mind.)

Quote:

Originally Posted by [R-DEV]rPoXoTauJIo

How did you worked around sceneparser bin?

Fortunately, sceneparser doesn't actually interact with max. it just takes the .dat and .material files that max dumps out via maxscript. The only compiled max SDK code is bf2mdtOps, however during export all they do is create the material file (which is just a couple of ascii lines, so easy to reproduce in maxscript) and execute the dos command to run sceneparse (also easy to reproduce in maxscript).