project reality header
Go Back   Project Reality Forums > PR:BF2 Mod Forums > PR:BF2 Community Modding > Modding Tutorials
20 Sep 2024, 00:00:00 (PRT)
Register Developer Blogs Members List Search Quick Links
Modding Tutorials Information and tutorials related to modding BF2.

Reply
 
Thread Tools Display Modes
Old 2017-03-13, 04:49   #1
Ratface
Retired PR Developer

Ratface's Avatar
Lightbulb Exporting A Tracked Vehicle


Introduction

DISCLAIMER: In the majority of my pictures, my PlayerControlObjects for the turrets and MG positions share the same name as the rotational bundle meshes they are parent of. This should not be the case! They should have different description names or else the BF2 editor will crash on loading the vehicle!

Lastly, you'll see I named by Engine "zMotor__Engine". It should be pre-pended with the vehicles name first as with any other mesh. Please keep that in mind, I'll update the pictures accordingly when I have time!

Hello again! This tutorial will teach you how to export a tracked vehicle. In this tutorial, I will be using a WIP version of PR:WW2's new M4A3 Sherman tank as an example of how to:

Set up the export hierarchy, complete with naming conventions,
Create "bones" for your mesh so that wheels and tracks behave realistically in the BF2 editor,
Set up your vehicle's tracks to make use of BF2's Animated UV system using the POE2 Tools,
How to skin your tracks to your vehicle's bones, and lastly
How to export your vehicle and test it before you begin coding.

For reference, I used the following tutorial when I exported my first tracked vehicle a while back. You will see a lot of similarities with it since it's what I learned from, so if you have any issues understanding what I'm explaining try checking this tutorial out as well!

Exporting a Tank for BF2/2142 - Battlefield SinglePlayer Forum

Also, I am assuming that at this point you already have your vehicle's mesh and textures (including your tracks) set up and ready to go. For help in setting up easy tracks, be sure to check my previous tutorial on the subject:

https://www.realitymod.com/forum/f18...ml#post2159417

Lastly, special thanks to Zemciugas for the model being shown today, and to CTRifle for the current texture! The model of course being PRWW2's new version of the M4 Sherman, the M4A3. Now, without further ado, let's begin!



Naming Conventions
To begin, let's go over naming conventions for when you export your vehicle. There may be more than what I list here, so if anyone comes across any new ones let me know and I will add them!

The basic naming convention I go with for PR vehicles is: [faction]_[vehicle type]_[vehicle name]_[description]__[object type]. Emphasis on the double underscores just before object type! This is so the editor knows what type to assign your mesh when it is exported!

The one exception to this is your main mesh, in my case "us_tnk_m4a3_75mm__PlayerControlObject". You'll notice I don't include a "description", and that is because this name before the object type is what the exported vehicle is named. See the image below to get an idea of the different types, and then we'll go over what each object type is.



"PlayerControlObject"
Also known as "PCO", this mesh is specifically used to control itself and children mesh by way of a player. In the case of our hull, the entire mesh is a PCO. In the case of other PCO's that control say, our hull MG or our turret, they are simple 3 sided faces that the player gives commands to which in turn control their children meshes. We'll get into that later.



"RotationalBundle"
Specifies that the mesh can be rotated. For example, our turret of our tank is a rotational bundle. Later on our "road-wheels" will be turned into rotational bundles as well, but we'll come back to that. Our wheels that will spin but stay static (front and rear) will also be regular rotational bundles.



"GenericFireArm"
Specifies that the mesh can be fired and cause recoil. For example, our cannon of our tank is a "GenericFireArm". As a note, you'll notice our Hull MG is only a rotational bundle. It will indeed shoot, but as we won't have it recoiling we won't worry about giving it this object type.



"Spring"
Specifies that the mesh can be moved up and down in a spring motion. In this case, our wheels (for the time being) will be considered sprints as they will do exactly that.



"Engine"
Specifies the object (usually a simple 3 sided face) that will control the vehicle's wheel movements and power.

This info should do for our tutorial for the time being.

Organizing Your Initial Hierarchy
Alright, now that we have our meshes named correctly, let's organize them!

Starting at the top of our hierarchy will be our main PCO, "us_tnk_m4a3_75mm__PlayerControlObject". This is what the driver of the tank will control.

Now, as I explained earlier, our other PCO's will be simple 3 sides faces. If you haven't made this yet, go ahead and do it now, and apply your vehicle's texture to it. No need for UV's since it won't be seen! This should be hidden inside of the mesh it will be controlling, as seen below:



What we'll do now is do the following links: Hull MG -> Hull MG PCO, then Hull MG PCO -> Main PCO. You can do this by clicking the button showed below, clicking and holding on the "child" mesh, then dragging your cursor to it's "parent" and releasing. If you select the wrong parent mesh, you can select your child and then click the "unlink" button showed below and try again.

Protip: Selecting your child, then clicking the "Select By Name" button described earlier lets you select a parent mesh to link to easily! Select the parent, press link, and done!)



Now, after doing what I've described, our hierarchy should look like this:



Now, following the same rules, let's do the same with our turret, 50 cal mount, mantle and cannon. Doing so you should get this:



Alright, so now to the parts that will make our vehicle move! What I'm going to do first is create another triangular face and name it "us_tnk_m4a3_75mm_zMotor__Engine". The "z" is just so it shows up last in our hierarchy as it is sorted alphabetically. I'll hide it in the rear of the tank's mesh and link it to my main PCO, as seen below.



Now what we'll do for the time being is link the rest of our wheels (both road wheels and rotation wheels) to our engine. What happens in code is the driver controls the engine, which in turn controls its children to turn. Now our hierarchy should be as seen below:





Creating Bones

Alright, now let's get on to creating bones for our vehicle. The bones will allow our vehicle's road wheels to move up and down, as well as deform our tracks later down the line once we skin the tracks to our bones.

As a quick definition, we are not creating a literal "Bone" object in 3dsMax, we are going to be using a regular "Pyramid" object that can be found by going to the "Create" tab, clicking the "Geometry" button, selecting "Standard Primitives" from the drop down menu, and then clicking the "Pyramid" button. Doing so will get you something like below:



Here is what we're going to do, and I'm sorry I didn't mention is earlier. There are two techniques for animating road wheels: the original I found from the reference tutorial in the intro animated the UV's for the road-wheels rather than animating the mesh. As such, the wheels themselves don't have to spin, and can be used as springs.

However, what we're going to do a technique where we animate our road wheels as rotational bundles. What that means is the following:

We are going to take our current road wheels and replace them with 3 sided faces (similar to what we used for our PCOs in our turret, or our Engine mesh). We will make 2 copies of our wheels (left facing and right facing) and export them as their own object. When we get to the editor, we will add these wheels in manually.

This may seem confusing but I'll walk you through this. First, let's do this. We will take one wheel, right click, clone it to a copy, name it "us_tnk_m4a3_75mm_rdwl_right__RotationalBundle ". I will do the same thing with a wheel facing left. Assuming it's center-point is in the center of the mesh already, I'll go ahead and center both at 0,0 of my scene. See below.

Don't forget to unlink your new clones from any parental mesh at this point!




With this done, let's go back to our current road wheels. What I'm going to do is create a small 3 sided face to act as my "Spring", center it to one of my road wheels, clone it, center it to the next, etc. until I have a 3 sided face inside each of my road wheels. You can center your face to your wheels by having your face selected, clicking the "Quick Align" button, then selecting the road wheel you want to align to. See below:



Alright, now that we've got our faces, let's go ahead and rename them all. What I'm going to do is first select the road wheel associated with the face, copy its name, delete it, then paste the name into the name of my face. Finally, I'll link all my new springs back to my engine. In the end, you should have the following:



Now, getting back to our bone discussion, we will do something similar to what we just did. What I'm going to do is create a small upside down pyramid, and give it the following name: "l1Bone" (My front left "spring's" bone). I don't believe naming convention matters here, but this keeps in organized.

Basically I'll create this first one, name it, quick align it to its associated spring face, clone it, and continue. I'm making my bone 1in X 1in x -1.5in.
Don't forget to give it your tank's texture!.
At the end, I'll go ahead and link each bone to whatever face it is related to. Do this until we reach this point:



And voila! Our bones have been created! We'll be coming back later to give these collisions, but I'll save all collision talk for later on.
VERY IMPORTANT NOTE: DO NOT convert your pyramids to anything! Leave them as pyramid objects! Converting them to anything else will cause your bones to export as mesh, not as bones!



Setting Up Our Animated UVs

Alright, let's work now on setting up our treads to animate correctly once we export them to the BF2 Editor! To, do this, we're going to select our main PCO (which should include your tracks). What we'll need to do first (if it isn't already) is convert our main PCO to an "Editable Mesh", then we'll select our tracks and teeth elements only. We'll go to our "BF2" menu item in the top bar, select "BF2 Utilities", and then click "Tank Wheels / Treads". And that's it! Easy right? Now, let's start skinning our tracks!

As a quick important note, if you ever have to make changes to the mesh in Editable Poly, your tread info will be lost! Be sure to convert back to Editable Mesh and do the same technique above to add the track information back.





Skinning Our Tracks

Alright, so this part is a tiny bit tricky, but well worth the effort. What we're going to do is skin our track mesh to our bones. Basically, our collision mesh will affect our bones, which in turn affect our wheels and tracks causing them to bounce up and down with the terrain!

What we'll do first is add a "Skin" modifier to our mesh. We will then add our bones to it to let it know what to have affect our mesh. Finally, we'll set our "Bone Affect Limit" to 1. (See below).



Next, click the "Edit Envelopes" button, check the "Verticies" checkbox, and uncheck "Envelopes" and "Cross Sections" checkboxes.



Next, we need to set what verticies from our tracks will affect our bones. To do this, we first neext to zero out all existing weights. To do so, click the "Weight Table" button, Click the "Edit" menu item, then go across the top row, inputting "0", then hitting tab. Doing so will zero out every weight below each column. After you do this, close the weight table, uncheck the "weight all verticies" checkbox, and click the "Remove Zero Weights" button.



Now, open up the weight table one more time. What we're going to do is select each bone in our skin modifier and one at a time, do the following:

Select all vertices we want to be affected by the bone,
In the drop down at the bottom of our weight table, select "Selected vertices",
Click "Edit" in the top menu and "Select All",
Input "1" into the column that is associated with our bone and hit tab,
Select the next bone and repeat.

Once we've done this for each bone, our skinning should be complete! Be sure not to collapse your Skin modifier, as you work will be erased with the collapse! See below for my example skinning my first bone.



And that's it! We have no completed our model! However, we do need to go into a few things regarding collision meshes. Let's hit that up first before doing out actual export to the BF2 Editor.

This is the end of part one! I will continue the rest in the next post when I've finished it, stay tuned! This will go over how to set up your textures, collisions, and how to export your vehicle! Cheers!

Ratface is offline
Last edited by [R-DEV]Ratface; 2017-03-13 at 05:01..
Reply With Quote
Old 2017-03-13, 04:50   #2
Ratface
Retired PR Developer

Ratface's Avatar
Default Re: Exporting A Tracked Vehicle


Part 2
Currently WIP, will add annotations shortly!
Alright, this begins part 2! In this second half, I'm going to cover the following:

Doing a practice export from where we left off in part 1,
Creating and linking our collisions for our tank,
Setting up our textures,
Exporting our vehicle for coders to begin their work!

Now, let's go ahead and get started.

Doing a practice export

We left off with our tracks now being skinned and our hierarchy being set up. At this point we should be set to do a practice export to the BF2 editor!

What I'm going to do is show you my current hierarchy. Remember that as of right now my road wheels are going to be exporter as separate objects, this I have one for the left side and one for the right. We'll add those in the editor later. Here is my current hierarchy from where we left off:



What I'm going to do now is use the POE2 tools to set up my tank for export. For this I'm going to first select every part of my mesh (Excluding my road wheels!). I'll then go to my BF2 menu item, click "BF2 Utilities", and click the "BundledMesh" button.



Doing this will do a few things. First, it will create a root helper object prepended with "root_bundledMesh_" followed by the name of your vehicle. Secondly, it will create 4 other helpers, being "geom0", "lod0", "geom1", and "lod0", as seen below. It will also copy all selected mesh and copy it to the geom1 helper.

geom0 is your export's 1st person mesh (what the players will see from inside the vehicle), geom1 is the 3rd person mesh, and geom2 (not automatically created) is the destroyed mesh.

lod0 refers to your first "Level Of Detail". Levels of detail (as you should know by now) are switched out at certain distances to cut down on the cost of displaying more geometry than is needed. Typically lod0 is for when you near the vehicle, lod1 is for a bit further away (OR for near the vehicle for low-end graphic users!!), etc. After doing as instructed, you're hierarchy should look like mine below.



From here, we can actually export our vehicle! Now something to keep in mind is that the export functions are VERY picky as to what they want, so it's very easy to miss a step from our previous tutorial and have a broken export that you'll have to debug. We can go more into that later.

What I'm going to do is select my root helper, click my "BF2" menu item, and select the "BF2 Exporter" tool. I am assuming you already have exported things in the past, if not I suggest seeing this tutorial: [INSERT TUTORIAL HERE]. I'm going to go ahead and change my object name as well to take off the "__PlayerControlObject", as that field is autofilled based on the root name. See below.



From there, I'll hit "Export", give it a few seconds to export the model, and then assuming everything went correctly your vehicle should be exported! See the picture below for where my export went. It should have created a "Meshes" folder with a bundledmesh file inside, as well as a CON file in the main export folder as well.

What I recommend now that you do is copy your textures (assuming they don't already exist in your mod folder somewhere), create a "textures" folder within your new export folder and place them in there. I would then reassign your textures in 3ds Max to point to these images instead, and export one more time. This way your export is pointing to these rather than your local computer's copy.



Now what I'm going to do is load up the BF2 editor, load whichever mod I exported to (in my case, pr_ww2_repo), and let the editor do it's thing. Once it'd ready, I'm going to open up my export by being in the "Object Editor", clicking the "plus" sign, "Load Resource"< then select my export as seen below.



If everything went good, we should be able to drag our vehicle from the "Resources" menu into the main viewport to view it. What you'll notice in my export is that the tracks are missing. We'll come to that in a bit. What I have now is what you see below:



Looking good! Everything seems to be positioned correctly. So, let's go ahead and start looking into our collisions now. We'll come back to the invisible tracks in the texturing section.

Setting up collisions
At this point I'm assuming you've done some collision work before. If not then I suggest checking out some other basic tutorials that cover this topic. For us right now I'll just throw out a reminder that we'll be using these collisions:

col0 (decal mesh), col1 (vehicle mesh) and col2 (soldier mesh).

I won't show how to make the collisions, however I would use these guidelines: Your col0 should be basically the same as your lod0 (maybe a bit optimized if possible), your col1 should be basic rectangles and cylinders that cove the majority of your vehicle, and col2 should be a much more optimized version of col0. We'll see an example of that at the end.

What I'm going to do is copy my lod0 helper and name it "nonvis_". This specifies that the mesh you child to this helper will not be shown but used for calculations. I will then child this helper to my main PCO, as seen below:



I will then copy my main PCO mesh, name it "col0" and child it to my nonvis_ helper. I'll do this with all my meshes until I have what you see below (we'll go over the spring collisions next). Just make sure before childing your collision to your helper than you align your helper to whatever mesh it's going to be chided to first. Note that for the time being I'm just doing this in geom0. I'll go over more on the near the end of the tutorial.

Now, for the time being, here is what I have. We'll be doing the springs next:



Now, the next part we'll do is create collisions for our main drive wheels / springs. For our wheels I'm going to do the same as above. For the springs, what I'm going to do is create a cylinder the same size as my road wheels and align it to each of my wheel bones. Basically our road wheels we'll add later will be purely visual, while the collisions will be part of the main mesh. This is because anything added via template will not have it's collisions work correctly (to my knowledge). See below:



Next, let's do our col1 (vehicle mesh). There are a few cases to remember here:
-For the main mesh (hull, turret, cannons, etc), we'll do these like normal for any other mesh we've made collisions for in the past.
-For the road wheels, our col1 (vehicle mesh) will be used to move our bones rather than to collide with other vehicles. I'll explain that more in a moment.

Below I've moved aside my vehicle collision meshes to the side for the picture. I've only added collision where it will actually make sense, so I haven't for instance added any vehicle collisions to the 50 cal mount or the mantle as they won't make any contact with other vehicles.



Now, let's do the vehicle collisions for our springs. For these all I'm going to do is create a 3 sided face and place it at the bottom of each track, linking it to the bone it should be childed to. What I've done on my side is copied col0 (cylinder), deleted all but the bottom face, welded the front two verts together and then made sure it was on the edge of the track. See below:



I'm going to go ahead and copy this similar how we did our road wheels for col0 until I finally have the following hierarchy:



Lastly, I'm going to go ahead and make my col2 mesh (soldier mesh) for anything that needs it. Note that in this case, I'm only going to make this mesh for my hull, my turret, my mantlet and my cannon. Also, note that for the time being I've placed a default material onto my collisions to differentiate them.



Right, now that should do it for the time being for out meshes. Congrats! Now let's begin looking at our textures and setting them up correctly.

Setting up textures

Alright, now let's talk textures! This should be fairly quick and painless to do. I have 3 main textures that I'm using for my actual mesh, those being the main texture sheet, a texture sheet for the wheels, and lastly the pre-existing track texture sheet. What I'm going to do is set up a multi-material material and set up my materials. I assume you've probably already done this by this point, but I want to bring up a few important things.

First, I'll set up my main texture (ID 1). This will be my simple BF2 BundledMesh texture. Again, if you aren't familiar with this I suggest looking at some basic PR modelling and export tutorials.


Second, I want to set up my wheels texture. For this I'll use a standard texture name it "Alpha Test". I suggest you check out this tutorial, it will explain how to handle textures with alpha maps quite well: [INSERT TUTORIAL HERE]. Using "Alpha Test" will either fully hide or show my alpha maps rather than make them partially opaque. I suggest using this technique. See below for my settings:

My material settings:


My diffuse settings (same as bump map but the bump uses my normal map):


My opacity settings:


Lastly, I will set up my track texture. You'll recall that previously we had issues seeing our track texture. This is because I used the "Alpha Test" naming technique. I have recently found this other technique (Thanks, Mats!) called "AnimatedUVAlpha_TestColormapGloss". I set up my tracks the same way I did with my wheels but use this name instead. You'll see next time we export that it'll work correctly.



Now, I believe we're almost done! Let's done one more export. Mine turns out like this:



Now, at this point, I'm going to do something that shouldn't be too confusing, but here we go. This entire time I've been working with geom0 lod0. What I'm going to do now is I'm going to delete "lod0" and it's children from geom1, unlink my first lod0 from geom0 and link it to geom1. Like so:



I will then take only what I think people will see from the interior of the vehicle, clone it, and remake my hierarchy in geom0. It is important as always that 1) you keep names and hierarchies in-tact! and 2) that you keep at least one face with any textures that are used in geom0. Meaning we might not see a track from any view, but we need to keep at least 1 face using track. This is just a restriction for exporting, so I won't go into detail on it. See below for my example.

Note: depending on your model you may have some custom interior, such as I had for my Tiger tank (leeks!!). I've included a picture of my 1st person mesh for a partial portion of the tiger. Your geom0 is however you want to make it, so if you really want to have fun and do some intense interior stuff have at it! Just know that it'll cost you in performance if you go too crazy.





Alright, so we're so close, one last part!! We need to export our wheels. This is really simple. What I'm going to do is select one of my road wheels, use my utilities to set up a bundlemesh, and done! Do this for the other as well. I'll go ahead and export these to the same folder as my Sherman, and export my Sherman one more time.



As a quick note! This is the last time I'm going to be in max for this tutorial For LODs (not shown here), I recommend you have LOD0 and LOD1 skinned for your tracks. Afterwards you can remove your skin modifier.


Adding our Road Wheels, Testing Export

Alright, so I've booted up the BF2 editor after exporting all my mesh. What I've got now is as you see below, What I'm missing are my road wheels though!



What I'm going to do is find my road wheel springs in my hierarchy on the left, right click, "Add Existing Child", and find my road wheel I exported and add it. Easy enough! Do that for each road wheel until you get have them all added (see second image).





From here, the only thing I'm really going to test is that our tracks are deforming correctly. To check this I'm going to select my spring and move it up and down. The tracks and wheel should deform with it. Do this for each wheel and make sure everything was skinned correclty. If so, congrats, you've exported your first tracked vehicle!

I won't be going into coding, but I will update the following post with troubleshooting advice in the future. Cheers and thanks to everyone for sticking along this far!

-[R-DEV]Ratface


Ratface is offline
Last edited by [R-DEV]Ratface; 2017-03-20 at 03:13..
Reply With Quote
Old 2017-03-13, 04:50   #3
Ratface
Retired PR Developer

Ratface's Avatar
Default Re: Exporting A Tracked Vehicle

[Reserved just in case]

Ratface is offline Reply With Quote
Old 2019-06-17, 11:29   #4
RestyBohol61
Default Re: Exporting A Tracked Vehicle

Quote:
Originally Posted by Ratface View Post
...

I'm trying to export my first tracked vehicle (an LVTH) using the tutorial you posted . I've followed everything but when I export it, no .con file generated, only the collision and bundlemesh generated. Am i missing something ?
RestyBohol61 is offline
Last edited by Mineral; 2019-06-17 at 12:10..
Reply With Quote
Reply


Tags
exporting, tracked, vehicle

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 11:27.