Setting Up Custom Objects for Battlefield 1942 -Uncle Sam

Written by Uncle Sam of www.battlefield1942.co.uk Mapping & Editing Forum

Compiled by Perfectionist aka Mr_Perfect 13/03/03
http://www.planetbattlefield.com/perfectionist
Email via Support on site please

 

Setting Up Custom Objects - Uncle Sam

For awhile there’s been a misconception that you can’t use custom objects and textures without making your map into a mod. But that is not the case. It’s actually a pretty simple process that can be done by making your own CON files. In this tutorial we’re going to go over how it’s done.

 

Setting Up your folders

Since we’re going to be adding in custom models with their own textures we’re going to need 3 new folders. In your map’s main directory, create 3 folders with the following names:

Setting up the objects

Open your CustomObjects folder. This is where the CON information is going to go for your object. Make a new text document. In the document, put in this line:

(Assuming the name of your object will be called “myobject”)

run myobject/myobject

Save the file. For the “Save as type” parameter, set this to “All Files”. Now for the name, put in “INIT.con(Figure 1)

(Figure 1)

Now, make a new folder called “myobject” inside this folder. Open the new folder and make a new text document in it. Put in these lines”

run objects
run geometries

Save this file as “myobject.con” using the same method described before. Now make another text document and put in these lines:

ObjectTemplate.create SimpleObject myobject
ObjectTemplate.geometry myobject
ObjectTemplate.setHasCollisionPhysics 1
objectTemplate.cullRadiusScale 3.0
ObjectTemplate.aiTemplate myobject

Save the file as “objects.con” I know this is getting to be a drag, but yes, make another text document and put in the following lines:

GeometryTemplate.create StandardMesh myobject
GeometryTemplate.file ../bf1942/levels/my_map/CustomMeshes/myobject
GeometryTemplate.setLodDistance 0 0
GeometryTemplate.setLodDistance 1 50
GeometryTemplate.setLodDistance 2 75
GeometryTemplate.setLodDistance 3 100
GeometryTemplate.setLodDistance 4 125
GeometryTemplate.setLodDistance 5 150

Set the LOD settings to whatever your model requires. Any LOD levels that are not used will not be counted so you can leave those lines there and you don’t have to worry about getting an error. Save this file as “geometries.con”. We’re done with this folder now.

 

Custom Textures

This one is a no-brainer. Open up the CustomTextures folder. This is where custom textures that your models use will be placed. Go ahead and copy over any DDS files that you’ll be using to this folder.

 

Custom Meshes

Now we’re going to set up the actual models. Copy your custom SM and RS files to this directory. In this case, the files would be “myobject.sm” and “myobject.rs”.

Open up the RS file with a text editor. When you exported your model with Rex’s tools, the paths for your textures were pointed to the default texture directory in BF1942. We need to change those paths to point to the ones in your CustomTextures directory. Assuming this model uses 3 custom textures (roof, door, windows), you would have them set up like this:

subshader "myobject_Material0" "StandardMesh/Default"
{
lighting true;
materialDiffuse 1 1 1;
lightingSpecular false;
texture "bf1942/levels/my_map/CustomTextures/roof";
}
subshader "myobject_Material1" "StandardMesh/Default"
{
lighting true;
materialDiffuse 1 1 1;
lightingSpecular false;
texture "bf1942/levels/my_map/CustomTextures/door";
}
subshader "myobject_Material2" "StandardMesh/Default"
{
lighting true;
materialDiffuse 1 1 1;
lightingSpecular false;
texture " bf1942/levels/my_map/CustomTextures/windows";
}

 

Finishing Touches

One last thing to do at this point. Open the “INIT.CON” file in your map’s main directory. At the end of the file, add this line:

run CustomObjects/INIT

You will only need to add this line once, even if you add more custom objects to your map. Your custom objects should work perfectly inside your map. You can distribute this map to anyone and your custom objects will work without any additional RFA files needed because they will have been compiled along with the rest of the map.

If you get confused as to how the process works, examine the flowchart I have provided (Figure 2) to see how it works. This is quite a handy feature and you can do a lot with your map once you understand how it works.

(Figure 2)

Good luck out there. - Uncle Sam

 

Written by Uncle Sam of www.battlefield1942.co.uk Mapping & Editing Forum

Compiled by Perfectionist aka Mr_Perfect 13/03/03
http://www.planetbattlefield.com/perfectionist