Battlefield 2 invades the high-tech frontlines of modern warfare. The game brings the intensity and excitement of Battlefield 1942 into the modern era with enhanced team play and the latest, most technologically advanced vehicles and weapons systems available to man.
Tutorial by BEEX on the BFEditor Forums. How to Export a Soldier to BF2.
Posted by InSovietRussia on Apr 9th, 2011
Advanced Client Side Coding.
first up i need to explain a few things so you dont get too far into the process and realise youve made some horible mistakes...i'll do my best to explain.
3dsmax 7 or 8...with 3dsmax bf2 tools,or 3dsmax poe2 tools.
photoshop 7 or cs...with dds tools.
shadder wrapper/bf2 materials.exe
and obviously bf2..lol.
1.build the character mesh to fit the vanilla bf2 skeleton and animations...creating new skeletons means you need to make "alot" of animations and can also create a bigger issue due to the engine having strict guidlines on bones used on the ragdoll.
2.to avoid flipped polygons after export...create a box,set its pivot position at the origin (0/0/0 on the grid),reset transform and scale,convert it to editable poly,then attatch the soldier to the box,then delete the faces of the box.
3.in the skin modifier each vertex has a max influence of 2 bones per vertex.
4.maximum of 4 meshes per lod.
5.maximum of 26 bones used per mesh,this is why we break it down into 3 parts,body,head and hands,in some circumstances you may want to break it down in different ways,body,head and arms+hands.
6.to avoid floating body parts materials need to be named correctly and applied to coresponding meshes,1p material="tangent",3p body="body||tangent",3p head="head||tangent",3p hands= "hands||tangent"...the naming is mainly for 3dsmax to use,you will need to use the shader wrapper/material.exe to change the material after export so the OS normal maps work correctly...workaround thanx to mischo.
7.theres 2 ways to generate OS normals maps,1.you can create a tangent normal map with all minor details in photoshop and let the exporter merge the tangent normal with os normal,though this method will generate seems,2.create a highpolygon model and bake the OS normal map,then after export add the baked OS normal to the texture folder...NOTE,if using a baked OS normal map channels may need to be swapped and inverted in photoshop.
8.naming textures is very important for the OS maps to generate on export.
9.when testing the weighting on the soldier,set transform and rotate to "local".
10.when testing weighting,rotate the bone,or a few bones,but always undo the rotations so the skeleton is back to its correct bf2 pose,if you break the skeleton it means you will have to weight the 3p or 1p skeleton all over again and re-import the ske.
ill add more notes as i think of them.
----importing a soldier and repair----
to make things easier we will use the bf2 us light soldier for this tutorial...
1.extract the contents from the soldiers folder to anywhere on your pc,make sure both server and client files are extrated into to the same folder.
2.open 3dsmax,go to bf2 tools/bf2 utilities/mesh importer...assuming you have the poe2 3dsmax tools installed,if you are using rexmans 3dsmax tools hit f11 (maxscriptlistener)and insert this line...
and hit enter.
3.using either method go find where you extracted the soldier folder to,go find the us_light_soldier .con,and hit open.
4.the mesh will be broken down into incorrect elements so some minor work is required.
select all the meshes for geom0-lod0 and geom1-lod1 and lod2,now hide those meshes,also hide the geom and lod dummies.
5.select the us_light_soldier__Soldier mesh and convert it to editable poly,in the editable poly tools select the attatch button then in the viewport click on all the other meshes so it becomes just 1 mesh (us_light_soldier__Soldier).
6.now using editable poly /vertex tools,drag the selection tools so all verts are selected,now hit the settings button next to weld,set the weld threshhold to 0.01,if using a higher number it will weld verts you dont want welded.
7.create a box,set its pivot position at the origin (0/0/0 on the grid),reset transform and scale,convert it to editable poly,then attatch the soldier to the box,then delete the faces of the box.
8.now its one mesh we need to break it down into elements,in editable poly mode select the element tool and drag selection so the head,eyes and teeth are selected,then hit detatch button,rename to Mesh_2_3plod0 (remove the _3plod0 part when repair is complete),now select both hands and detatch,rename to Mesh_1_3plod0.
9.select the hands and head and link them to the body using the select and link tool.
10.rename the body to 3plod0_tut__soldier,then hide the body,hands and head.
11.now follow the same steps with the other 2 lods,rename mehses appropriately.
12.do the same steps for the 1p arms,but break the 1p arms into 2 meshes,name the right arm to 1p_tut__soldier,and name the whole left arm Mesh_1_1p
your heirachy should look like this...
the soldier is now repaired...
now its time to setup the materials...
the next step you will need to create a new mod,i sugest you do so for this tutorial to avoid confusion and problems related to other objects...after successful export of the soldier you can shift the files into another mod folder.
1.after you have created a new mod close the editor then open your mods folder,go to objects/soldiers,create a new folder with the name of your team (i used the name tut,dont use US in the name of a new team cuz of some odd hardcoding issues),then create a new folder called textures in the "tut" folder.
2.open the folder where you extracted the soldiers from the import step,go to US/textures and copy these textures into the texture folder you just created...
any instance of "US" in the above names change to "TUT" or your team name...exapmle:1p_TUT_body_B_os...naming of textures is very important,os maps will not be generated on export if incorrectly named.
you will also need to copy the _b_os textures and rename those to _b,after export the _b_os is generated,we will delete the _b textures after export is complete...also replace the _b_os maps with the original _b_os maps,because they wont look pretty. :P
3.open your reapired soldier scene in 3dsmax,then open the material editor.
4.we need to use 5 materials,1 for each mesh (except for lods),so select material 1,name it Rarm||tangent,to the right of where you just placed the name is a button that says standard,click on it and select the Bf2 BundledBesh shader.
5.under bundledmesh parameters,click on the "color" button and find the 1p_TUT_body_C,then click on the "normal" button to find the 1p_TUT_body_B..."DO NOT USE _B_os textures"
6.continue this process for the other 4 materials,name the others...
Larm||tangent , body||tangent , hands||tangent , head||tangent
7.material 1 apply it to the right 1p arm,material 2 apply it to the left 1p arm,material 3 and apply it the 3 3p bodies,material 4 apply it to the 3 3p hands,material 5 apply it to the 3 3p heads.
materials are now setup.
your scene should be something like so...
next step is to import the 1p and 3p skeletons and setup the heirachy before rigging can begin.
1.using the poe2 utilities,hit the "skeleton importer" button,go find the soldiers folder you extracted in the first step and go to soldiers/common/animations and select the 1p_setup.ske.
2.do the same thing for the 3p_setup.ske.
3.open the select and name list (heirachy),you will see its starting to get complicated..."never fear,beex is here" :lol:
4.some name changes need to be made and the heirachy needs to be changed...
geom0 ...rename to ...geom0_1P ...link it to root_skinnedmesh_tut_soldier
geom1 ...rename to ...geom1_3P ...link it to root_skinnedmesh_tut_soldier
root_skeleton_1p_setup ...rename to... ske::root_skeleton_1p_setup ...link it to geom_1P
root_skeleton_3p_setup ...rename to... ske::root_skeleton_3p_setup ...link it to geom_3P
clone the root_skinnedmesh_tut_soldier ...rename to ... ske:root_skeleton link it to geom0/lod0
clone the ske:root_skeleton ...keep same name ...link it to geom0/lod0 ,then link 1p_tut_soldier to ske:root_skeleton.
1p_tut_soldier ...rename to ... tut_soldier__Soldier
clone the ske:root_skeleton ...keep same name ...link it to geom1/lod0 ,then link 3plod0_tut_soldier to ske:root_skeleton.
3plod0_tut_soldier ...rename to ... tut_soldier__Soldier
clone the ske:root_skeleton ...keep same name ...link it to geom1/lod1 ,then link 3plod1_tut_soldier to ske:root_skeleton.
3plod1_tut_soldier ...rename to ... tut_soldier__Soldier
clone the ske:root_skeleton ...keep same name ...link it to geom1/lod2 ,then link 3plod2_tut_soldier to ske:root_skeleton.
3plod2_tut_soldier ...rename to ... tut_soldier__Soldier
Mesh_1_1p ...to... Mesh_1
Mesh_1_3p ...to... Mesh_1
Mesh_2_3p ...to... Mesh_2
you get the idea,dont change the bones named mesh1,mesh2.
heres how the heirachy should look...
next step is to rig the soldier using the skin modifier.
using the skin modifier is a big task with alot of messing with numbers in the weight table,so theres no way i can guide you through the entire process of weighting every vertex.
1.first we will rig the 3p lod0 tut_solider mesh,its a good idea to hide the other meshes,hide the 1p arms and the 3p lods,leaving only 3p lod0 meshes in the viewport,leave the dummies and bones as is...
so select 3p body mesh,convert it to editable mesh,then go to modifiers/animation/skin.
2.now you add the bones you need for the body...remember 26 bones maximum
under parameters you will see "bones:"and an add button,hit the add button and add the...
3.hit the "Edit Envelopes" button....i need to run you through some skin modifier settings now.
uncheck "cross sections"
scroll down to "display"...
check "colored vertices"
check "colored faces"
check "color all weights"
check "show all envelopes"
check "show all vertices"
check "show all gizmos"
check "show no envelopes"
check "cross sections"
now under "advanced parameters" set the "bone affect limit" to 2
4.do steps 1 to 3 for the other 2 3p lods
5.now its time for the weight table...
for some odd reason all verts have been weighted to the root bone,usually after hitting the edit envelopes button the body will be roughly weighted to all bones...nevermind,this could be a good thing,if you weight all verts to the root bone it will mean the export will work and the game wont crash from vertices not being weighted.
the fun begins here,with many hours of hair pulling goodness...suckers!. :lol:
6.you will need to turn on "edged faces" in the viewport so you can see the verts,also to make things easier in the material editor turn off the "show map in viewport" button,now you can clearly see the weights being coloured.
7.just to be sure we dont have any un-weighted verts,drag select all vertices,you will see all verts now have a white box around them,the white box obviously means selected verts.
hit the "weight table" button.
first hit the button where it says "root" this will set which bone is being used to weight the selected vertices,at the bottom left of the weight table change to "selected vertices",for this part we go to edit/select all,the table will turn dark grey.
hold the mouse pointer over where its says 1.000 and drag to the right a few times,to make sure all verts have full influence.
you might have noticed a cross has appeared to the left of the numbers,i am not quite sure what this is,but from what i can tell it shows the verts are fully influenced.
because we checked "coloured verts" you can see all weighted verts are now red.
heres a pic of where you should be at...
8.do the same for the other 2 3p lods.
9.now we need to weight the 3p hands so first up select the Mesh_1 mesh,convert it to "editable mesh",go to modifiers/animation/skin...(same as we did before) hit the "bones:add button",then add these bones to the list...
10.hit "edit envelopes",now change the settings we did earlier.
11.this time around the verts have influence from all the bones,but the weighting will be terrible,it will do for now.
12.do the same for the other 2 3p hand lods,but with lod2 hands dont worry about adding all the bones,just add R_wrist and L_wrist.
13.hide all other meshes leaving only the 3p lod0 head,convert it to editable mesh,go to modifier/animation/skin.
14.for this tutorial i wont go into facial animations,well cuz i dont know too much about it...lol...anyways we will rig the head to only the neck and head bones...
so add the neck and head dones to the list.
15.change the settings same as before.
16.drag selection so all verts of the head are selected,open the weight table and weight all verts to the head bone.
17.to make things easier use the left or right viewport and zoom in so all the head and neck is visible,select the verts on the neck area,open the weight table and weight the selected verts to the neck bone.
heres where you should be at...
18.do the same for the other 2 3p head lods.
19.hide all 3p meshes and unhide both 1p arms
20.select the right arm and convert it to editable mesh,go to modifiers/animation/skin.
then add these bones to the list...
21.hit edit envelopes,change the settings again.
22.the mesh should be roughly weighted again,it will do for now.
23.select the left arm,convert it to editable mesh,go to modifiers/animation/skin.
then add these bones to the list...
24.hit edit envelopes,change the settings again.
at this stage you can export the soldier and its a good idea to do so,to make sure the heirachy is ok...if you want to export it...
1.select the "root_skinnedmesh_tut_soldier",
2.in 3dsmax go to bf2/bf2 exporter.
3."run setup" make sure your mod name is in both the output files directory and added to the lower section.
4.the objects sub-folder path: should be /Soldiers/tut/ (instead of tut your team name).
REST OF TUTORIAL: Bfeditor.org